chiark / gitweb /
WIP routesearch; stratify by archipelagoes - much better
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Wed, 7 Oct 2009 23:58:45 +0000 (00:58 +0100)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Wed, 7 Oct 2009 23:58:45 +0000 (00:58 +0100)
yarrg/rscommon.h
yarrg/rsmain.c
yarrg/rssearch.c

index f0215b2..79f38a4 100644 (file)
@@ -108,7 +108,7 @@ typedef struct {
 
 void setup_search(void);
 void search(int start_isle, PotentialResult ****strat_base_io
-                                /* strat_base[finalisle][midisle]-> */);
+                                /* strat_base[finalarch][midarch]-> */);
 
 extern double max_mass, max_volu, max_capi;
 extern double distance_loss_factor_per_league;
index 2fc2bdf..a498022 100644 (file)
@@ -66,22 +66,22 @@ int main(int argc, const char **argv) {
       resultsix++;
     }
 
-    int i, midisle, finisle;
+    int i, midarch, finarch;
     for (i=0; i<resultsix; i++) {
       fprintf(stderr,"================== start #%d ==================\n",i);
       PotentialResult ***strat_resultsix= results[i];
       if (!strat_resultsix) continue;
-      fprintf(stderr,"    ");
-      for (midisle=0; midisle<islandtablesz; midisle++) {
-       fprintf(stderr,"|mi%-3d",midisle);
+      fprintf(stderr,"  ");
+      for (midarch=0; midarch<narches; midarch++) {
+       fprintf(stderr,"| mid %d ",midarch);
       }
       fprintf(stderr,"\n");
-      for (finisle=0; finisle<islandtablesz; finisle++) {
-       PotentialResult **strat_finisle= strat_resultsix[finisle];
-       if (!strat_finisle) continue;
-       fprintf(stderr,"f%-3d",finisle);
-       for (midisle=0; midisle<islandtablesz; midisle++) {
-         PotentialResult *result= strat_finisle[midisle];
+      for (finarch=0; finarch<narches; finarch++) {
+       PotentialResult **strat_finarch= strat_resultsix[finarch];
+       if (!strat_finarch) continue;
+       fprintf(stderr,"f%d",finarch);
+       for (midarch=0; midarch<narches; midarch++) {
+         PotentialResult *result= strat_finarch[midarch];
          if (!result) {
            fprintf(stderr,"|       ");
          } else {
index fa43d89..0286584 100644 (file)
@@ -39,6 +39,12 @@ static Neighbour *get_neighbours(int isle) {
 static PotentialResult ***strat_base;
 
 
+static inline int isle2arch(int isle) {
+  int arch= islandid2arch[isle];
+  assert(arch>=0);
+  return arch;
+}
+
 static double process_route(int nports, int totaldist,
                            double overestimate_excepting_tail) {
   int i;
@@ -51,11 +57,11 @@ static double process_route(int nports, int totaldist,
     debugf(" %d",ports[i]);
   debugf("\n");
 
-  int finalisle= ports[nports-1];
-  int midisle= ports[nports/2];
+  int finisle= ports[nports-1]; int finarch= isle2arch(finisle);
+  int midisle= ports[nports/2]; int midarch= isle2arch(midisle);
 
-  PotentialResult **strat_fin= ONDEMAND(strat_base[finalisle], islandtablesz);
-  PotentialResult *strat= ONDEMAND(strat_fin[midisle], 1);
+  PotentialResult **strat_fin= ONDEMAND(strat_base[finarch], narches);
+  PotentialResult *strat= ONDEMAND(strat_fin[midarch], 1);
 
   if (nports>=2) {
     int pair[2], i;
@@ -94,7 +100,7 @@ static double process_route(int nports, int totaldist,
 
   debugf(" SOMEHOW BEST\n");
 
-  fildebugf("final %3d mid %3d ",finalisle,midisle);
+  fildebugf("final %d:%3d mid %d:%3d ",finarch,finisle,midarch,midisle);
 
 #define CHK(absperl)                                                   \
   fildebugf(#absperl " %15f", absperl);                                        \
@@ -136,7 +142,7 @@ static void recurse(int last_isle,
 }
 
 void search(int start_isle, PotentialResult ****strat_base_io) {
-  strat_base= ONDEMAND(*strat_base_io, islandtablesz);
+  strat_base= ONDEMAND(*strat_base_io, narches);
   recurse(start_isle,0,0,1e6);
 }