From 1b72f7ac0adb1b2ed007ad9cfaf4e7092679e4fa Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Fri, 30 Sep 2022 14:33:51 +0200 Subject: Added routine to try perturbations until a large one is found. --- rbmp.cpp | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/rbmp.cpp b/rbmp.cpp index e677a11..8ddc591 100644 --- a/rbmp.cpp +++ b/rbmp.cpp @@ -132,22 +132,41 @@ int main(int argc, char* argv[]) { matching[i] = edgeMatched(pm, G.edges[i]); } - unsigned eFlip = r.variate(0, G.edges.size() - 1); - while (!matching[eFlip]) { - eFlip = r.variate(0, G.edges.size() - 1); - } + while (true) { + unsigned eFlip = r.variate(0, G.edges.size() - 1); - pm.StartUpdate(); - pm.UpdateCost(eFlip, 1e10); - pm.FinishUpdate(); + while (!matching[eFlip]) { + eFlip = r.variate(0, G.edges.size() - 1); + } - pm.Solve(); + 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(); + } + } - unsigned m = 0; for (unsigned i = 0; i < G.edges.size(); i++) { if (!matching[i] && edgeMatched(pm, G.edges[i])) { - m++; std::cout << G.edges[i].halfedges[0].getTail().coordinate[0] << " " << G.edges[i].halfedges[0].getTail().coordinate[1] << " " @@ -156,7 +175,5 @@ int main(int argc, char* argv[]) { } } - std::cerr << "Size of excitation: " << m << std::endl; - return 0; } -- cgit v1.2.3-70-g09d2