chiark / gitweb /
WIP routesearch; route tail guesswork pruning optimisation
[ypp-sc-tools.db-test.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 #ifndef debug_flags
14   debug_flags= ~( dbg_sql2 );
15 #endif
16   sysassert( !setvbuf(debug,0,_IOLBF,0) );
17   
18   for (;;) {
19     arg= *++argv;
20     if (arg[0] != '-') break;
21 #ifndef debug_flags
22     if (!strcmp(arg,"-DN")) {
23       debug_flags= 0;
24     } else
25 #endif
26     {
27       abort();
28     }
29   }
30
31   setup_sql();
32   setup_value();
33   setup_search();
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   arg= *argv++;
44   if (!strcmp(arg,"specific")) {
45     int ia[argc], ni=0;
46     while ((arg= *argv++))
47       ia[ni++]= atoi(arg);
48
49     double val= value_route(ni, ia, 0);
50     printf("route value is %g\n", val);
51   } else if (!strcmp(arg,"search")) {
52     max_dist= atoi(*argv++);
53     while ((arg= *argv++))
54       search(atoi(arg));
55   } else {
56     abort();
57   }
58   return 0;
59 }