chiark / gitweb /
routesearch: event counters
[ypp-sc-tools.db-live.git] / yarrg / rsmain.c
1 /**/
2
3 #include "rscommon.h"
4
5 int o_quiet= 0;
6 double max_mass=-1, max_volu=-1, max_capi=-1;
7 double distance_loss_factor_per_league;
8 int max_dist= -1;
9
10 #define CTR(x) int ctr_##x;
11   COUNTER_LIST
12 #undef CTR
13
14 int main(int argc, const char **argv) {
15   const char *arg;
16
17 #ifndef debug_flags
18   debug_flags= ~( dbg_sql2 );
19 #endif
20   sysassert( !setvbuf(debug,0,_IOLBF,0) );
21   
22   for (;;) {
23     arg= *++argv;
24     if (arg[0] != '-') break;
25 #ifndef debug_flags
26     if (!strcmp(arg,"-DN")) {
27       debug_flags= 0;
28     } else
29 #endif
30     {
31       abort();
32     }
33   }
34
35   max_mass= atof(*argv++);
36   max_volu= atof(*argv++);
37   max_capi= atof(*argv++);
38   double loss_per_league= atof(*argv++);
39
40   if (!loss_per_league) loss_per_league= 1e-7;
41   distance_loss_factor_per_league= 1.0 - loss_per_league;
42
43   setup_sql();
44   setup_value();
45   setup_search();
46
47   fprintf(stderr,"setup complete, starting search\n");
48   
49   arg= *argv++;
50   if (!strcmp(arg,"specific")) {
51     int ia[argc], ni=0;
52     while ((arg= *argv++))
53       ia[ni++]= atoi(arg);
54
55     double val= value_route(ni, ia, 0);
56     printf("route value is %g\n", val);
57   } else if (!strcmp(arg,"search")) {
58     max_dist= atoi(*argv++);
59     while ((arg= *argv++))
60       search(atoi(arg));
61   } else {
62     abort();
63   }
64
65 #define CTR(x) fprintf(stderr,"  %-30s %10d\n",#x,ctr_##x);
66   COUNTER_LIST
67 #undef CTR
68
69   return 0;
70 }