chiark / gitweb /
WIP routesearch; debugging is optional; bugfixes fixed the bug in TODO
[ypp-sc-tools.main.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 int main(int argc, const char **argv) {
11   const char *arg;
12
13   debug_flags= ~( dbg_sql2 );
14   sysassert( !setvbuf(debug,0,_IOLBF,0) );
15   
16   for (;;) {
17     arg= *++argv;
18     if (arg[0] != '-') break;
19     if (!strcmp(arg,"-DN")) {
20       debug_flags= 0;
21     } else {
22       abort();
23     }
24   }
25
26   setup_sql();
27   setup_value();
28   setup_search();
29
30   max_mass= atof(*argv++);
31   max_volu= atof(*argv++);
32   max_capi= atof(*argv++);
33   double loss_per_league= atof(*argv++);
34
35   if (!loss_per_league) loss_per_league= 1e-7;
36   distance_loss_factor_per_league= 1.0 - loss_per_league;
37   
38   arg= *argv++;
39   if (!strcmp(arg,"specific")) {
40     int ia[argc], ni=0;
41     while ((arg= *argv++))
42       ia[ni++]= atoi(arg);
43
44     double val= value_route(ni, ia);
45     printf("route value is %g\n", val);
46   } else if (!strcmp(arg,"search")) {
47     max_dist= atoi(*argv++);
48     while ((arg= *argv++))
49       search(atoi(arg));
50   } else {
51     abort();
52   }
53   return 0;
54 }