aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteinar H. Gunderson <sgunderson@bigfoot.com>2014-04-11 21:17:38 +0200
committerSteinar H. Gunderson <sgunderson@bigfoot.com>2014-04-11 21:17:38 +0200
commit1d6334b64f75586927c4b9fbc62bdf453334e249 (patch)
treea9b42ed84f82378a5d58d786d9da695cd5d9b461
parent14329321c1850af613b6e4d25db9bf616b107e04 (diff)
Drop all the logging stuff if we only care about cost.
-rw-r--r--planning/planning.cpp34
1 files changed, 20 insertions, 14 deletions
diff --git a/planning/planning.cpp b/planning/planning.cpp
index dd22620..6901966 100644
--- a/planning/planning.cpp
+++ b/planning/planning.cpp
@@ -563,6 +563,26 @@ int Planner::do_work(int distro_placements[NUM_DISTRO])
find_mincost_maxflow(&g);
map<int, int> switches_to_distros = find_switch_distro_map(g);
+ for (unsigned i = 0; i < switches.size(); ++i) {
+ const auto distro_it = switches_to_distros.find(i);
+ if (distro_it == switches_to_distros.end()) {
+ total_cost += _INF;
+ continue;
+ }
+ int distro = distro_it->second;
+ total_cost += find_cost(switches[i], distro);
+ int this_distance = find_distance(switches[i], distro);
+ Inventory this_inv = find_inventory(switches[i], distro);
+ total_slack += find_slack(this_inv, this_distance);
+ total_inv += this_inv;
+ }
+
+#if !OUTPUT_FILES
+ if (log_buf == NULL) {
+ return total_cost;
+ }
+#endif
+
for (unsigned row = 1; row <= NUM_ROWS; ++row) {
// Figure out distro markers.
char distro_marker_left[16] = " ";
@@ -615,20 +635,6 @@ int Planner::do_work(int distro_placements[NUM_DISTRO])
}
logprintf("[%u;22m\n", 37);
- for (unsigned i = 0; i < switches.size(); ++i) {
- const auto distro_it = switches_to_distros.find(i);
- if (distro_it == switches_to_distros.end()) {
- total_cost += _INF;
- continue;
- }
- int distro = distro_it->second;
- int this_distance = find_distance(switches[i], distro);
- Inventory this_inv = find_inventory(switches[i], distro);
- total_cost += find_cost(switches[i], distro);
- total_slack += find_slack(this_inv, this_distance);
- total_inv += this_inv;
- }
-
#if OUTPUT_FILES
FILE *patchlist = fopen("patchlist.txt", "w");
FILE *switchlist = fopen("switches.txt", "w");