From 1d6334b64f75586927c4b9fbc62bdf453334e249 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Fri, 11 Apr 2014 21:17:38 +0200 Subject: Drop all the logging stuff if we only care about cost. --- planning/planning.cpp | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'planning/planning.cpp') 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 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"); -- cgit v1.2.3