#undef CTR
#undef CTRA
-static PotentialResult ****results[STRATS];
- /* results[STRATS][start_isle_ix][finalisle][midisle]-> */
+static Bucket ****results[GRANUS];
+ /* results[GRANUS][start_isle_ix][finalisle][midisle]-> */
static pid_t debugoutpid;
int main(int argc, const char **argv) {
const char *arg;
int i, ap;
- int strati;
+ int granui;
+ const char *database=0;
#ifndef debug_flags
debug_flags= ~( dbg_sql2 );
for (;;) {
arg= *++argv;
if (arg[0] != '-') break;
+ if (!strcmp(arg,"-d")) {
+ database= *++argv;
+ } else if (!strcmp(arg,"-g")) {
+ granus= atoi(*++argv);
+ assert(granus>=1 && granus<=GRANUS);
#ifndef debug_flags
- if (!strcmp(arg,"-DN")) {
+ } else if (!strcmp(arg,"-DN")) {
debug_flags= 0;
- } else
+ } else if (!strcmp(arg,"-D1")) {
+ debug_flags= ~(dbg_sql2|dbg_lp|dbg_value2);
+ } else {
#endif
- {
abort();
}
}
debug_file= stderr;
}
- const char *database= *argv++;
-
sysassert( !setvbuf(debug,0,_IOLBF,0) );
max_mass= atof(*argv++);
double val= value_route(ni, ia, 0);
fprintf(output, "route value is %g\n", val);
} else if (!strcmp(arg,"search")) {
- for (strati=0; strati<STRATS; strati++)
- MCALLOC(results[strati], argc);
+ for (granui=0; granui<GRANUS; granui++)
+ MCALLOC(results[granui], argc);
max_dist= atoi(*argv++);
for (ap=0; ap<AP; ap++) {
int nhs= atoi(*argv++);
- for (strati=0; strati<STRATS; strati++) {
- nhighscores[strati][ap]= nhs;
- MCALLOC(highscores[strati][ap], nhs);
+ for (granui=0; granui<GRANUS; granui++) {
+ nhighscores[granui][ap]= nhs;
+ MCALLOC(highscores[granui][ap], nhs);
}
}
const char *final_isle_spec= *argv++;
else final_isle= atoi(final_isle_spec);
assert(final_isle);
- PotentialResult ****strat_base_io[STRATS];
- for (strati=0; strati<STRATS; strati++)
- strat_base_io[strati]= &results[strati][resultsix];
+ Bucket ****buckets_base_io[GRANUS];
+ for (granui=0; granui<GRANUS; granui++)
+ buckets_base_io[granui]= &results[granui][resultsix];
- search(init_isle, final_isle, strat_base_io);
+ search(init_isle, final_isle, buckets_base_io);
resultsix++;
}
int mid, fin;
- for (strati=minstrat; strati<STRATS; strati++) {
+ for (granui=0; granui<granus; granui++) {
fprintf(output,"\n");
for (i=0; i<resultsix; i++) {
- tabdebugf("========== start #%d strati%d %s [PARTIAL] ==========\n",
- i, strati, argv[i]);
- PotentialResult ***strat_resultsix= results[strati][i];
- if (!strat_resultsix) continue;
+ tabdebugf("========== start #%d granui%d %s ==========\n",
+ i, granui, argv[i]);
+ Bucket ***buckets_resultsix= results[granui][i];
+ if (!buckets_resultsix) continue;
tabdebugf(" ");
- for (mid=0; mid<stratsz_mid[strati]; mid++) {
+ for (mid=0; mid<granusz_mid[granui]; mid++) {
tabdebugf("| m%-3d ",mid);
}
tabdebugf("\n");
- for (fin=0; fin<stratsz_fin[strati]; fin++) {
- PotentialResult **strat_fin= strat_resultsix[fin];
- if (!strat_fin) continue;
+ for (fin=0; fin<granusz_fin[granui]; fin++) {
+ Bucket **buckets_fin= buckets_resultsix[fin];
+ if (!buckets_fin) continue;
tabdebugf("f%-3d",fin);
- for (mid=0; mid<stratsz_mid[strati]; mid++) {
- PotentialResult *result= strat_fin[mid];
+ for (mid=0; mid<granusz_mid[granui]; mid++) {
+ Bucket *result= buckets_fin[mid];
if (!result) {
tabdebugf("| ");
} else {
- tabdebugf("|%5d",(int)(result->value[A]));
+ tabdebugf("|%5d",(int)(result->prs[A].value[A]));
tabdebugf(" ");
- tabdebugf("%4d",(int)(result->value[P]));
+ tabdebugf("%4d",(int)(result->prs[P].value[P]));
}
}
tabdebugf("\n");
for (ap=0; ap<AP; ap++) {
int pos;
- fprintf(output,"============== strati%d ap=%d ==============\n",
- strati, ap);
- for (pos=0; pos<nhighscores[strati][ap]; pos++) {
- HighScoreEntry *hs= &highscores[strati][ap][pos];
- PotentialResult *pr= hs->pr;
- if (!pr) continue;
- const int *const ports= pr->ports[ap];
+ fprintf(output,"============== granui%d ap=%d ==============\n",
+ granui, ap);
+ for (pos=nhighscores[granui][ap]-1; pos>=0; pos--) {
+ HighScoreEntry *hs= &highscores[granui][ap][pos];
+ Bucket *bucket= hs->bucket;
+ if (!bucket) continue;
+ OnePotentialResult *pr= &bucket->prs[ap];
+ const int *const ports= pr->ports;
int nports;
for (nports=0; nports<MAX_ROUTELEN && ports[nports]>=0; nports++);
int finisle= ports[nports-1];
int midisle= ports[nports/2];
int midarch= route2midarch(ports,nports);
fprintf(output,
- " @%2d #%2d | start%3d mid%d:%3d f%d:%3d | %5d %5d %4d |",
- pos, nhighscores[strati][ap] - 1 - pos,
+ " @%2d %c#%2d | start%3d mid%d:%3d f%d:%3d | %5d %5d %4d |",
+ pos, "ap"[ap], nhighscores[granui][ap] - pos,
ports[0], midarch,midisle, finarch,finisle,
(int)hs->value, (int)pr->value[A], (int)pr->value[P]);
for (i=0; i<nports; i++) fprintf(output," %d",ports[i]);
fprintf(output,"\n");
} /* pos */
} /* ap */
- } /* strati */
+ } /* granui */
fprintf(output,"\n");
} else {