chiark / gitweb /
WIP routesearch; route tail guesswork pruning optimisation
[ypp-sc-tools.db-live.git] / yarrg / rsmain.c
index 00e918e8aedbfe320bdd7628d35f35c694b66086..0982889c8b3f8fc34d2c25e9fb4fe314f3d79a84 100644 (file)
@@ -2,12 +2,58 @@
 
 #include "rscommon.h"
 
+int o_quiet= 0;
+double max_mass=-1, max_volu=-1, max_capi=-1;
+double distance_loss_factor_per_league;
+int max_dist= -1;
+
 int main(int argc, const char **argv) {
-  int ia[argc], ni=0;
   const char *arg;
-  while ((arg= *++argv)) {
-    ia[ni++]= atoi(arg);
+
+#ifndef debug_flags
+  debug_flags= ~( dbg_sql2 );
+#endif
+  sysassert( !setvbuf(debug,0,_IOLBF,0) );
+  
+  for (;;) {
+    arg= *++argv;
+    if (arg[0] != '-') break;
+#ifndef debug_flags
+    if (!strcmp(arg,"-DN")) {
+      debug_flags= 0;
+    } else
+#endif
+    {
+      abort();
+    }
+  }
+
+  setup_sql();
+  setup_value();
+  setup_search();
+
+  max_mass= atof(*argv++);
+  max_volu= atof(*argv++);
+  max_capi= atof(*argv++);
+  double loss_per_league= atof(*argv++);
+
+  if (!loss_per_league) loss_per_league= 1e-7;
+  distance_loss_factor_per_league= 1.0 - loss_per_league;
+  
+  arg= *argv++;
+  if (!strcmp(arg,"specific")) {
+    int ia[argc], ni=0;
+    while ((arg= *argv++))
+      ia[ni++]= atoi(arg);
+
+    double val= value_route(ni, ia, 0);
+    printf("route value is %g\n", val);
+  } else if (!strcmp(arg,"search")) {
+    max_dist= atoi(*argv++);
+    while ((arg= *argv++))
+      search(atoi(arg));
+  } else {
+    abort();
   }
-  value_route(ni, ia);
   return 0;
 }