chiark / gitweb /
report some more stuff in stderr output
[matchsticks-search.git] / main.c
diff --git a/main.c b/main.c
index f0bb84f497f12d91f9a1f4416643d80aee002c09..fb270e0d75ccf61d6f07917a5e432b37860fe409 100644 (file)
--- a/main.c
+++ b/main.c
@@ -8,6 +8,10 @@
  * The arguments must be ordered so that n > m:
  *   n is the number of (more, shorter) input matches of length m
  *   m is the number of (fewer, longer) output matches of length n
+ *
+ * Options:
+ *  -j<jobs>     run in parallel on <jobs> cores
+ *  -b<best>     search only for better than <best>
  */
 
 /*
@@ -683,6 +687,14 @@ static void iterate(void) {
 
 static void report(void) {
   fprintf(stderr, "\n");
+  if (best_adjmatrix) {
+    int i;
+    fprintf(stderr,"  ");
+    for (i=0; i<n; i++) fprintf(stderr, " %"PRADJ, best_adjmatrix[i]);
+  }
+  fprintf(stderr, " best=%-12.8f nf<=%d mf<=%d\n",
+         best, n_max_frags, m_max_frags);
+  printf("%d into %d: ", n, m);
   if (best_prob) {
     double min = glp_get_obj_val(best_prob);
     double a[n][m];
@@ -697,7 +709,7 @@ static void report(void) {
         continue;
       a[x][y] = min + glp_get_col_prim(best_prob, i);
     }
-    printf("%d into %d: min fragment %g   [%s]\n", n, m, min, VERSION);
+    printf("min fragment %g", min);
     for (i = 0; i < n; i++) {
       for (j = 0; j < m; j++) {
         if (a[i][j])
@@ -708,6 +720,7 @@ static void report(void) {
       printf("\n");
     }
   }
+  printf("   [%s]\n", VERSION);
   if (ferror(stdout) || fclose(stdout)) { perror("stdout"); exit(-1); }
 }
  
@@ -716,6 +729,7 @@ int main(int argc, char **argv) {
   while ((opt = getopt(argc,argv,"j:")) >= 0) {
     switch (opt) {
     case 'j': ncpus = atoi(optarg); break;
+    case 'b': set_best(atof(optarg)); break;
     case '+': assert(!"bad option");
     default: abort();
     }