chiark / gitweb /
routesearch: give tableau its own debug flag
[ypp-sc-tools.web-live.git] / yarrg / rscommon.h
index bdcc15759705bb5667d26583bdbd63315536d642..5da0721dbec588b8d004e7d2c2f4110de01c238e 100644 (file)
    DF(search)                                  \
    DF(filter)                                  \
    DF(check)                                   \
+   DF(tableau)                                 \
    DF(lp)
 
-#define debug stdout
-#define DEBUG_DEV "/dev/stdout"
+#define debug debug_file
 
 #include "common.h"
 
+extern FILE *debug_file;
+#define DEBUG_DEV "/dev/stdout" /* just for glpk */
+
 
 #define COUNTER_LIST                           \
    CTR(commodities_loaded)                     \
    CTR(ipairs_relevant)                                \
    CTR(quantities_loaded)                      \
    CTR(routes_considered)                      \
+   CTR(routes_wrongfinalelim)                  \
    CTR(routes_quickelim)                       \
    CTR(routes_stratelim)                       \
    CTR(routes_valued)                          \
+   CTR(routes_wrongfinal)                      \
    CTR(newbests_strat_absolute)                        \
-   CTR(newbests_strat_perleague)                       \
+   CTR(newbests_strat_perleague)               \
    CTR(subroute_tails_valued)                  \
    CTR(subroutes_valued)                       \
    CTR(subroutes_nonempty)
@@ -42,9 +47,9 @@
      * chk1 and chk2 are blocks using sqe and  int sqr; */              \
     const char *sql_must_call_string= #call;                            \
     int sqr;                                                            \
-    if (DEBUGP(sql2)) fprintf(stderr,"SQL %s", sql_must_call_string);   \
+    if (DEBUGP(sql2)) fprintf(debug,"SQL %s", sql_must_call_string);    \
     sqr= (call);                                                        \
-    if (DEBUGP(sql2)) fprintf(stderr," = %d\n", sqr);                   \
+    if (DEBUGP(sql2)) fprintf(debug," = %d\n", sqr);                    \
     if (sqr) sql_fatal("(unknown)", sqr, sql_must_call_string);                 \
   })                                                                    \
 
@@ -112,8 +117,9 @@ typedef struct {
 } PotentialResult;
 
 void setup_search(void);
-void search(int start_isle, PotentialResult ****strat_base_io
-                                /* strat_base[finalarch][midarch]-> */);
+void search(int start_isle, int final_isle /* -1 means any */,
+           PotentialResult ****strat_base_io
+               /* strat_base[finalarch][midarch]-> */);
 
 extern double max_mass, max_volu, max_capi;
 extern double distance_loss_factor_per_league;
@@ -128,6 +134,9 @@ extern char **archnames;
 extern int *islandid2arch;
 
 
+extern FILE *output;
+
+
 #define NEW(ptr) ((ptr)= mmalloc(sizeof(*ptr)))
 
 #define MCALLOC(array, count) ((array)= mcalloc(sizeof(*(array)) * (count)))
@@ -163,5 +172,15 @@ static inline int isle2arch(int isle) {
   return arch;
 }
 
+static inline int route2midarch(const int *ports, int nports) {
+  int archs[nports], last_arch=-1, narchs=0, i;
+  for (i=0; i<nports; i++) {
+    int arch= isle2arch(ports[i]);
+    if (arch==last_arch) continue;
+    archs[narchs++]= last_arch= arch;
+  }
+  return archs[narchs/2];
+}
+
 
 #endif /*RSCOMMON_H*/