Added options (display, tree type...)
This commit is contained in:
28
best.c
28
best.c
@@ -13,7 +13,10 @@ static int bestops=MAXINT;
|
||||
|
||||
static BEST bests[1024*10]; /* TODO: should be dynamic */
|
||||
static int nbests=0;
|
||||
extern int displaytimer;
|
||||
int sigint_received=0;
|
||||
int displayintermediate=0;
|
||||
int displaytype=0;
|
||||
|
||||
#define DIFF(a, b) ((a)>(b)?(a)-(b):(b)-(a))
|
||||
|
||||
@@ -73,14 +76,16 @@ int check_best(res, nops, node, values, ops)
|
||||
bests[nbests].oper=ops;
|
||||
bests[nbests].root=dup_node(node);
|
||||
bests[nbests].values=values;
|
||||
# ifdef DEBUG_BEST
|
||||
// printf("NEW BEST! res=%d diff=%d nops=%d\n", res, diff, nops);
|
||||
printf("%.5f: diff=%d nops=%d %d=", get_timer(bests[nbests].timer),
|
||||
diff, nops, res);
|
||||
print_node(node, TREE_TOP, 0, 4);
|
||||
putchar('\n');
|
||||
if (displayintermediate) {
|
||||
if (displaytimer) {
|
||||
printf("%.5f secs: ", get_timer(bests[nbests].timer));
|
||||
}
|
||||
printf("diff=%d nops=%d %d=", diff, nops, res);
|
||||
print_node(node, TREE_TOP, 0, displaytype);
|
||||
putchar('\n');
|
||||
}
|
||||
//printf("check_best: res=%d diff=%d nops=%d\n", res, diff, nops);
|
||||
# endif
|
||||
nbests++;
|
||||
return diff;
|
||||
}
|
||||
@@ -115,12 +120,15 @@ void print_best(node, values, pops, depth)
|
||||
|
||||
void print_bests()
|
||||
{
|
||||
int i;
|
||||
printf("BEST SOLUTION: diff=%d ops=%d\n", bestdiff, bestops);
|
||||
int i=0;
|
||||
printf("BEST SOLUTION: res=%d diff=%d ops=%d ", bests[i].res, bestdiff, bestops);
|
||||
if (displaytimer)
|
||||
printf("after %.5f secs.", get_timer(bests[i].timer));
|
||||
putchar('\n');
|
||||
for (i=0; i<nbests; ++i) {
|
||||
//print_best(bests[i].root, bests[i].values, bests[i].oper, 0);
|
||||
printf("%.5f secs: %5d = ", get_timer(bests[i].timer), bests[i].res);
|
||||
print_node(bests[i].root, TREE_TOP, 0, 4);
|
||||
//printf("%5d =", bests[i].res);
|
||||
print_node(bests[i].root, TREE_TOP, 0, displaytype);
|
||||
putchar('\n');
|
||||
//printf("%3d: %d = ", i, bests[i].res);
|
||||
//print_node(bests[i].root, TREE_TOP, 0, 1);
|
||||
|
Reference in New Issue
Block a user