#include #include "aztec.hpp" int main(int argc, char* argv[]) { unsigned n = 100; int opt; while ((opt = getopt(argc, argv, "n:")) != -1) { switch (opt) { case 'n': n = atoi(optarg); break; default: exit(1); } } Rng r; AztecDiamond G(n); G.setWeights(r); PerfectMatching pm = findGroundState(G); std::cout << n << std::endl; for (unsigned i = 0; i < G.vertices.size() / 2; i++) { unsigned j1 = pm.GetMatch(i); std::cout << G.vertices[i].coordinate[0] << " " << G.vertices[i].coordinate[1] << " " << G.vertices[j1].coordinate[0] << " " << G.vertices[j1].coordinate[1] << std::endl; } std::vector matching(G.edges.size()); for (unsigned i = 0; i < G.edges.size(); i++) { matching[i] = edgeMatched(pm, G.edges[i]); } while (true) { unsigned eFlip = r.variate(0, G.edges.size() - 1); while (!matching[eFlip]) { eFlip = r.variate(0, G.edges.size() - 1); } pm.StartUpdate(); pm.UpdateCost(eFlip, 1e10); pm.FinishUpdate(); pm.Solve(); unsigned m = 0; for (unsigned i = 0; i < G.edges.size(); i++) { if (!matching[i] && edgeMatched(pm, G.edges[i])) { m++; } } if (m > 4 * n) { std::cerr << "Size of excitation: " << m << std::endl; break; } else { pm.StartUpdate(); pm.UpdateCost(eFlip, -1e10); pm.FinishUpdate(); pm.Solve(); } } for (unsigned i = 0; i < G.edges.size(); i++) { if (!matching[i] && edgeMatched(pm, G.edges[i])) { std::cout << G.edges[i].tail->coordinate[0] << " " << G.edges[i].tail->coordinate[1] << " " << G.edges[i].head->coordinate[0] << " " << G.edges[i].head->coordinate[1] << std::endl; } } return 0; }