From 2083cff9581c3953ebdfa9a9ff951016c0ffc8b5 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Tue, 11 Oct 2022 11:49:46 +0200 Subject: More fixes. --- excitation.cpp | 19 ++++++++++++------- free_energy.cpp | 2 +- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/excitation.cpp b/excitation.cpp index 05cb8c6..be1acc1 100644 --- a/excitation.cpp +++ b/excitation.cpp @@ -2,6 +2,10 @@ #include "rbmp.hpp" +bool edgeMatched(PerfectMatching& pm, const AztecDiamond::Edge& e) { + return e.tail->index == pm.GetMatch(e.head->index); +} + int main(int argc, char* argv[]) { unsigned n = 100; @@ -18,12 +22,13 @@ int main(int argc, char* argv[]) { } Rng r; - Graph G(n, r); + AztecDiamond G(n); + G.setWeights(r); PerfectMatching pm(G.vertices.size(), G.edges.size()); - for (const Edge& e : G.edges) { - pm.AddEdge(e.halfedges[0].getHead().index, e.halfedges[0].getTail().index, e.weight); + for (const AztecDiamond::Edge& e : G.edges) { + pm.AddEdge(e.head->index, e.tail->index, e.weight); } pm.options.verbose = false; @@ -83,10 +88,10 @@ int main(int argc, char* argv[]) { for (unsigned i = 0; i < G.edges.size(); i++) { if (!matching[i] && edgeMatched(pm, G.edges[i])) { std::cout - << G.edges[i].halfedges[0].getTail().coordinate[0] << " " - << G.edges[i].halfedges[0].getTail().coordinate[1] << " " - << G.edges[i].halfedges[0].getHead().coordinate[0] << " " - << G.edges[i].halfedges[0].getHead().coordinate[1] << std::endl; + << 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; } } diff --git a/free_energy.cpp b/free_energy.cpp index 6bfdf19..2bc2a0e 100644 --- a/free_energy.cpp +++ b/free_energy.cpp @@ -36,12 +36,12 @@ int main(int argc, char* argv[]) { Rng r; AztecDiamond a(n); + a.setWeights(r); for (Real T = T0; T <= T1; T += ΔT) { Real avgFreeEnergy = 0; for (unsigned i = 0; i < m; i++) { - a.setWeights(r); a.computeWeights(T); avgFreeEnergy += a.computeProbabilities(); } -- cgit v1.2.3-54-g00ecf