X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=matchsticks-search.git;a=blobdiff_plain;f=main.c;h=d923704f3962c805984567e957e1b02bbcfb2a7d;hp=0967442c5a425f5d7c414c39be6b971b571753fc;hb=9ec76da798715053418c6cac1baf7e0632cfc145;hpb=fd709c59f86b3d8ddd270157cf602c3c6abc094d diff --git a/main.c b/main.c index 0967442..d923704 100644 --- a/main.c +++ b/main.c @@ -11,6 +11,7 @@ * * Options: * -j run in parallel on cores + * -b search only for better than */ /* @@ -114,7 +115,7 @@ static double best; static glp_prob *best_prob; static AdjWord *best_adjmatrix; -static int n_max_frags, m_max_frags; +static int n_max_frags=INT_MAX, m_max_frags=INT_MAX; static int *weight; static unsigned printcounter; @@ -262,6 +263,8 @@ static void multicore_outer_iteration(int i, AdjWord min) { } static void mc_iterate_worker(void) { + static time_t lastprint; + for (;;) { mc_rwvsetup_outer(); ssize_t r = readv(mc_work[0], mc_iov, mc_niovs); @@ -271,8 +274,12 @@ static void mc_iterate_worker(void) { bool ok = maxhamweight_ok(); if (!ok) continue; - ok = preconsider_ok(multicore_iteration_boundary, 1); - progress_eol(); + time_t now = time(0); + bool doprint = now != lastprint; + lastprint = now; + + ok = preconsider_ok(multicore_iteration_boundary, doprint); + if (doprint) progress_eol(); if (!ok) continue; /* stop iterate_recurse from trying to run multicore_outer_iteration */ @@ -383,8 +390,6 @@ static void prep(void) { glp_term_out(GLP_OFF); setlinebuf(stderr); weight = calloc(sizeof(*weight), m); assert(weight); - n_max_frags = INT_MAX; - m_max_frags = INT_MAX; } #if 0 @@ -686,6 +691,14 @@ static void iterate(void) { static void report(void) { fprintf(stderr, "\n"); + if (best_adjmatrix) { + int i; + fprintf(stderr," "); + for (i=0; i= 0) { + while ((opt = getopt(argc,argv,"j:b:")) >= 0) { switch (opt) { case 'j': ncpus = atoi(optarg); break; + case 'b': set_best(atof(optarg)); break; case '+': assert(!"bad option"); default: abort(); }