chiark / gitweb /
WIP routesearch: trade value; before separate query for qties
authorIan Jackson <ian@liberator.(none)>
Fri, 2 Oct 2009 20:47:33 +0000 (21:47 +0100)
committerIan Jackson <ian@liberator.(none)>
Fri, 2 Oct 2009 20:47:33 +0000 (21:47 +0100)
yarrg/rssetup.c
yarrg/rsvalue.c

index 88b6fc6851a91a6775160d20ac454daec788670a..dadeca6bda4509eff3a17008be0cfefafb9d237d 100644 (file)
@@ -48,7 +48,8 @@ int sql_step_wrap(sqlite3_stmt *ssh, const char *ssh_string,
        fprintf(stderr,"SQL %s R",ssh_string);
        for (i=0; i<sqlite3_column_count(ssh); i++) {
          fputc('\t',stderr);
        fprintf(stderr,"SQL %s R",ssh_string);
        for (i=0; i<sqlite3_column_count(ssh); i++) {
          fputc('\t',stderr);
-         fputs((char*)sqlite3_column_text(ssh,i),stderr);
+         const char *txt= (const char*)sqlite3_column_text(ssh,i);
+         fputs(txt ? txt : "<null>", stderr);
        }
        fputs("\n",stderr);
       }
        }
        fputs("\n",stderr);
       }
index 9cc9ec757987ce9230380ab02381bed496a1d5f3..ad301b0b135fe13cb6602800c54208d3c39583fb 100644 (file)
@@ -108,6 +108,7 @@ static int setup_leg_constraints(double max_thing, int legs, const char *wh) {
 
 static void add_leg_c(int startrow, int leg, double value) {
   if (startrow<=0) return;
 
 static void add_leg_c(int startrow, int leg, double value) {
   if (startrow<=0) return;
+  assert(value > 0);
   add_constraint(startrow+leg, value);
 }
 
   add_constraint(startrow+leg, value);
 }
 
@@ -243,6 +244,7 @@ void value_route(int nislands, const int *islands) {
        if (islands[already_d] == di)
          /* visited this island already since we left s, uninteresting */
          goto next_d;
        if (islands[already_d] == di)
          /* visited this island already since we left s, uninteresting */
          goto next_d;
+
       if (d>s && di==si)
        /* route has returned to si, no need to think more about s */
        goto next_s;
       if (d>s && di==si)
        /* route has returned to si, no need to think more about s */
        goto next_s;
@@ -252,6 +254,9 @@ void value_route(int nislands, const int *islands) {
       IslandPair *ip= ipair_get(islands[s], islands[d]);
       TradesBlock *block= ip->trades;
       int tradestodo= ip->ntrades;
       IslandPair *ip= ipair_get(islands[s], islands[d]);
       TradesBlock *block= ip->trades;
       int tradestodo= ip->ntrades;
+      if (!tradestodo)
+       goto next_d;
+
       int inblock= 0;
       int col= lpx_add_cols(lp,ip->ntrades);
 
       int inblock= 0;
       int col= lpx_add_cols(lp,ip->ntrades);