static pbqp_node **reduced_bucket = NULL;
static int buckets_filled = 0;
+#if KAPS_STATISTIC
static int dump = 0;
+#endif
/* Forward declarations. */
static void apply_Brute_Force(pbqp *pbqp);
fputs("edge has been eliminated<br>\n", pbqp->dump_file);
}
+#if KAPS_STATISTIC
+ if (dump == 0) {
+ pbqp->num_edges++;
+ }
+#endif
+
delete_edge(edge);
reorder_node(src_node);
reorder_node(tgt_node);
}
}
-num determine_solution(FILE *file)
+static num determine_solution(pbqp *pbqp)
{
unsigned node_index;
unsigned node_len;
num solution = 0;
+ FILE *file;
+
+ assert(pbqp);
+ file = pbqp->dump_file;
if (file) {
dump_section(file, 1, "4. Determine Solution/Minimum");
/* Solve trivial nodes and calculate solution. */
node_len = node_bucket_get_length(node_buckets[0]);
+
+#if KAPS_STATISTIC
+ if (dump == 0) {
+ pbqp->num_r0 = node_len;
+ }
+#endif
+
for (node_index = 0; node_index < node_len; ++node_index) {
pbqp_node *node = node_buckets[0][node_index];
assert(node);
/* ... and put node into bucket representing their degree. */
fill_node_buckets(pbqp);
+#if KAPS_STATISTIC
FILE *fh = fopen("solutions.pb", "a");
fprintf(fh, "Solution");
fclose(fh);
+#endif
apply_heuristic_reductions(pbqp);
- pbqp->solution = determine_solution(pbqp->dump_file);
+ pbqp->solution = determine_solution(pbqp);
+#if KAPS_STATISTIC
fh = fopen("solutions.pb", "a");
- fprintf(fh, ": %lld\n", pbqp->solution);
+ fprintf(fh, ": %lld RE:%u R0:%u R1:%u R2:%u RN/BF:%u\n", pbqp->solution,
+ pbqp->num_edges, pbqp->num_r0, pbqp->num_r1, pbqp->num_r2,
+ pbqp->num_rn);
fclose(fh);
+#endif
/* Solve reduced nodes. */
back_propagate(pbqp);
reorder_node(other_node);
+#if KAPS_STATISTIC
+ if (dump == 0) {
+ pbqp->num_r1++;
+ }
+#endif
+
/* Add node to back propagation list. */
node_bucket_insert(&reduced_bucket, node);
}
disconnect_edge(src_node, src_edge);
disconnect_edge(tgt_node, tgt_edge);
+#if KAPS_STATISTIC
+ if (dump == 0) {
+ pbqp->num_r2++;
+ }
+#endif
+
/* Add node to back propagation list. */
node_bucket_insert(&reduced_bucket, node);
node->index, min_index);
}
- FILE *fh = fopen("solutions.pb", "a");
- fprintf(fh, "[%u]", min_index);
- fclose(fh);
+#if KAPS_STATISTIC
+ if (dump == 0) {
+ FILE *fh = fopen("solutions.pb", "a");
+ fprintf(fh, "[%u]", min_index);
+ fclose(fh);
+ pbqp->num_rn++;
+ }
+#endif
/* Now that we found the local minimum set all other costs to infinity. */
select_alternative(node, min_index);
select_alternative(node_buckets[3][bucket_index], node_index);
apply_brute_force_reductions(pbqp);
- value = determine_solution(pbqp->dump_file);
+ value = determine_solution(pbqp);
if (value < min) {
min = value;
pbqp_dump_graph(pbqp);
}
+#if KAPS_STATISTIC
dump++;
+#endif
+
min_index = get_minimal_alternative(pbqp, node);
node = pbqp->nodes[node->index];
node->index, min_index);
}
+#if KAPS_STATISTIC
dump--;
if (dump == 0) {
FILE *fh = fopen("solutions.pb", "a");
fprintf(fh, "[%u]", min_index);
fclose(fh);
+ pbqp->num_bf++;
}
+#endif
/* Now that we found the minimum set all other costs to infinity. */
select_alternative(node, min_index);
/* ... and put node into bucket representing their degree. */
fill_node_buckets(pbqp);
+#if KAPS_STATISTIC
FILE *fh = fopen("solutions.pb", "a");
fprintf(fh, "Solution");
fclose(fh);
+#endif
apply_brute_force_reductions(pbqp);
- pbqp->solution = determine_solution(pbqp->dump_file);
+ pbqp->solution = determine_solution(pbqp);
+#if KAPS_STATISTIC
fh = fopen("solutions.pb", "a");
- fprintf(fh, ": %lld\n", pbqp->solution);
+ fprintf(fh, ": %lld RE:%u R0:%u R1:%u R2:%u RN/BF:%u\n", pbqp->solution,
+ pbqp->num_edges, pbqp->num_r0, pbqp->num_r1, pbqp->num_r2,
+ pbqp->num_bf);
fclose(fh);
+#endif
/* Solve reduced nodes. */
back_propagate(pbqp);
static const num INF_COSTS = INTMAX_MAX;
+#define KAPS_STATISTIC 0
+
struct pbqp {
struct obstack obstack; /* Obstack. */
num solution; /* Computed solution. */
size_t num_nodes; /* Number of PBQP nodes. */
pbqp_node **nodes; /* Nodes of PBQP. */
FILE *dump_file; /* File to dump in. */
+#if KAPS_STATISTIC
+ unsigned num_bf; /* Number of brute force reductions. */
+ unsigned num_edges; /* Number of independent edges. */
+ unsigned num_r0; /* Number of trivial solved nodes. */
+ unsigned num_r1; /* Number of R1 reductions. */
+ unsigned num_r2; /* Number of R2 reductions. */
+ unsigned num_rn; /* Number of RN reductions. */
+#endif
};
#endif /* KAPS_PBQP_T_H */