From eb41301f24f983c738bb6d5d63e98c5fb0f80aaa Mon Sep 17 00:00:00 2001 From: Sebastian Buchwald Date: Sat, 13 Dec 2008 12:12:05 +0000 Subject: [PATCH] Dump pbqp solution to file... [r24594] --- heuristical.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/heuristical.c b/heuristical.c index 6226c79ec..f34926a2c 100644 --- a/heuristical.c +++ b/heuristical.c @@ -18,6 +18,8 @@ static pbqp_node **node_buckets[4]; static pbqp_node **reduced_bucket = NULL; static int buckets_filled = 0; +static int dump = 0; + /* Forward declarations. */ static void apply_Brute_Force(pbqp *pbqp); @@ -517,11 +519,17 @@ void solve_pbqp_heuristical(pbqp *pbqp) /* ... and put node into bucket representing their degree. */ fill_node_buckets(pbqp); + FILE *fh = fopen("solutions.pb", "a"); + fprintf(fh, "Solution"); + fclose(fh); + apply_heuristic_reductions(pbqp); pbqp->solution = determine_solution(pbqp->dump_file); - //printf("solution: %lld\n", pbqp->solution); + fh = fopen("solutions.pb", "a"); + fprintf(fh, ": %lld\n", pbqp->solution); + fclose(fh); /* Solve reduced nodes. */ back_propagate(pbqp); @@ -838,6 +846,10 @@ void apply_RN(pbqp *pbqp) node->index, min_index); } + FILE *fh = fopen("solutions.pb", "a"); + fprintf(fh, "[%u]", min_index); + fclose(fh); + /* Now that we found the local minimum set all other costs to infinity. */ select_alternative(node, min_index); } @@ -953,6 +965,7 @@ void apply_Brute_Force(pbqp *pbqp) pbqp_dump_graph(pbqp); } + dump++; min_index = get_minimal_alternative(pbqp, node); node = pbqp->nodes[node->index]; @@ -961,6 +974,13 @@ void apply_Brute_Force(pbqp *pbqp) node->index, min_index); } + dump--; + if (dump == 0) { + FILE *fh = fopen("solutions.pb", "a"); + fprintf(fh, "[%u]", min_index); + fclose(fh); + } + /* Now that we found the minimum set all other costs to infinity. */ select_alternative(node, min_index); } @@ -973,11 +993,17 @@ void solve_pbqp_brute_force(pbqp *pbqp) /* ... and put node into bucket representing their degree. */ fill_node_buckets(pbqp); + FILE *fh = fopen("solutions.pb", "a"); + fprintf(fh, "Solution"); + fclose(fh); + apply_brute_force_reductions(pbqp); pbqp->solution = determine_solution(pbqp->dump_file); - //printf("solution: %lld\n", pbqp->solution); + fh = fopen("solutions.pb", "a"); + fprintf(fh, ": %lld\n", pbqp->solution); + fclose(fh); /* Solve reduced nodes. */ back_propagate(pbqp); -- 2.20.1