summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rbmp.cpp41
1 files 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<unsigned, std::uniform_int_distribution>(0, G.edges.size() - 1);
- while (!matching[eFlip]) {
- eFlip = r.variate<unsigned, std::uniform_int_distribution>(0, G.edges.size() - 1);
- }
+ while (true) {
+ unsigned eFlip = r.variate<unsigned, std::uniform_int_distribution>(0, G.edges.size() - 1);
- pm.StartUpdate();
- pm.UpdateCost(eFlip, 1e10);
- pm.FinishUpdate();
+ while (!matching[eFlip]) {
+ eFlip = r.variate<unsigned, std::uniform_int_distribution>(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;
}