From 71253f39cdc8e8c86d8855ec65119da07f2ccd44 Mon Sep 17 00:00:00 2001 From: Robert Ricci Date: Thu, 10 Jul 2003 16:26:12 +0000 Subject: [PATCH] Add a much needed 'try harder' feature - pass, on the command line, a floating point number that, roughly, scales the runtime. --- assign/anneal.cc | 7 ++++++- assign/anneal.h | 2 +- assign/assign.cc | 13 +++++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/assign/anneal.cc b/assign/anneal.cc index 8013d0975..0a67ff165 100644 --- a/assign/anneal.cc +++ b/assign/anneal.cc @@ -181,7 +181,7 @@ REDO_SEARCH: /* When this is finished the state will reflect the best solution found. */ -void anneal(bool scoring_selftest) +void anneal(bool scoring_selftest, double scale_neighborhood) { cout << "Annealing." << endl; @@ -294,6 +294,11 @@ void anneal(bool scoring_selftest) if (neighborsize < min_neighborhood_size) { neighborsize = min_neighborhood_size; } + + // Allow scaling of the neighborhood size, so we can make assign try harder + // (or less hard) + neighborsize = (int)(neighborsize * scale_neighborhood); + #ifdef CHILL double scores[neighborsize]; #endif diff --git a/assign/anneal.h b/assign/anneal.h index 517297805..49b1a0c1e 100644 --- a/assign/anneal.h +++ b/assign/anneal.h @@ -72,6 +72,6 @@ inline int accept(double change, double temperature); tb_pnode *find_pnode(tb_vnode *vn); /* The big guy! */ -void anneal(bool scoring_selftest); +void anneal(bool scoring_selftest, double scale_neighborhood); #endif diff --git a/assign/assign.cc b/assign/assign.cc index 3b5bcc23d..eb0a370e9 100644 --- a/assign/assign.cc +++ b/assign/assign.cc @@ -83,6 +83,9 @@ switch_dist_map_map switch_dist; // Time started, finished, and the time limit double timestart, timeend, timelimit, timetarget; +// An amount to scale the neighborhood size by +double scale_neighborhood = 1.0; + #ifdef GNUPLOT_OUTPUT FILE *scoresout, *tempout, *deltaout; #endif @@ -303,6 +306,7 @@ void print_help() cerr << " -P - Prune unusable pclasses." << endl; #endif cerr << " -T - Doing some scoring self-testing." << endl; + cerr << " -H - Try times harder." << endl; exit(2); } @@ -534,7 +538,7 @@ int main(int argc,char **argv) char ch; timelimit = 0.0; timetarget = 0.0; - while ((ch = getopt(argc,argv,"s:v:l:t:rpPTd")) != -1) { + while ((ch = getopt(argc,argv,"s:v:l:t:rpPTdH:")) != -1) { switch (ch) { case 's': if (sscanf(optarg,"%d",&seed) != 1) { @@ -570,6 +574,11 @@ int main(int argc,char **argv) scoring_selftest = true; break; case 'd': dynamic_pclasses = true; break; + case 'H': + if (sscanf(optarg,"%lf",&scale_neighborhood) != 1) { + print_help(); + } + break; default: print_help(); } @@ -657,7 +666,7 @@ int main(int argc,char **argv) } timestart = used_time(); - anneal(scoring_selftest); + anneal(scoring_selftest, scale_neighborhood); timeend = used_time(); #ifdef GNUPLOT_OUTPUT -- GitLab