X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.web-live.git;a=blobdiff_plain;f=yarrg%2Frsmain.c;h=2fc2bdfaeb7819bae3a3993155eb19ecaa99e23c;hp=7e5e5e8a2af2b06c5e1199ae075c31eb3f0e658c;hb=2204eb5e3fb843a426dbc0858fa91ce72d63cc73;hpb=b5f936bf08ab82b34f9529b72946c0cd66ef5a62 diff --git a/yarrg/rsmain.c b/yarrg/rsmain.c index 7e5e5e8..2fc2bdf 100644 --- a/yarrg/rsmain.c +++ b/yarrg/rsmain.c @@ -7,38 +7,101 @@ double max_mass=-1, max_volu=-1, max_capi=-1; double distance_loss_factor_per_league; int max_dist= -1; +#define CTR(x) int ctr_##x; + COUNTER_LIST +#undef CTR + +static PotentialResult ****results; + /* results[start_isle_ix][finalisle][midisle]-> */ + int main(int argc, const char **argv) { const char *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(); + } + } + + 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; 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; + fprintf(stderr,"setup complete, starting search\n"); - arg= *++argv; + arg= *argv++; if (!strcmp(arg,"specific")) { int ia[argc], ni=0; - while ((arg= *++argv)) + while ((arg= *argv++)) ia[ni++]= atoi(arg); - double val= value_route(ni, ia); + 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)); + results= mcalloc(sizeof(*results)*argc); + max_dist= atoi(*argv++); + int resultsix= 0; + while ((arg= *argv++)) { + search(atoi(arg), &results[resultsix]); + resultsix++; + } + + int i, midisle, finisle; + for (i=0; iabsolute < 100) fprintf(stderr,"| ."); + else fprintf(stderr,"|%3d",(int)(result->absolute / 100)); + fprintf(stderr," "); + if (result->perleague < 10) fprintf(stderr," ."); + else fprintf(stderr,"%3d",(int)(result->perleague / 10)); + } + } + fprintf(stderr,"\n"); + } + } } else { abort(); } + +#define CTR(x) fprintf(stderr," %-30s %10d\n",#x,ctr_##x); + COUNTER_LIST +#undef CTR + return 0; }