Debugging: New value2 debug flag, new option -D1 for medium debug output, etc.
Rename PotentialResult to a Bucket of two OnePotentialResults (no intended
change in behaviour for this)
Fix granularity full test to work correctly
DF(sql) \
DF(sql2) \
DF(value) \
DF(sql) \
DF(sql2) \
DF(value) \
DF(search) \
DF(filter) \
DF(check) \
DF(search) \
DF(filter) \
DF(check) \
typedef struct {
double value[AP];
typedef struct {
double value[AP];
- int ports[AP][MAX_ROUTELEN];
-} PotentialResult;
+ int ports[MAX_ROUTELEN];
+} OnePotentialResult;
+
+typedef struct {
+ OnePotentialResult prs[AP];
+} Bucket;
void setup_search(void);
void search(int start_isle, int final_isle /* -1 means any */,
void setup_search(void);
void search(int start_isle, int final_isle /* -1 means any */,
- PotentialResult ****buckets_base_io[GRANUS]
+ Bucket ****buckets_base_io[GRANUS]
/* bucket_base[granui][finalthing][midthing]-> */);
extern double max_mass, max_volu, max_capi;
/* bucket_base[granui][finalthing][midthing]-> */);
extern double max_mass, max_volu, max_capi;
typedef struct {
double value;
typedef struct {
double value;
} HighScoreEntry;
extern int granus;
} HighScoreEntry;
extern int granus;
-static PotentialResult ****results[GRANUS];
+static Bucket ****results[GRANUS];
/* results[GRANUS][start_isle_ix][finalisle][midisle]-> */
static pid_t debugoutpid;
/* results[GRANUS][start_isle_ix][finalisle][midisle]-> */
static pid_t debugoutpid;
#ifndef debug_flags
if (!strcmp(arg,"-DN")) {
debug_flags= 0;
#ifndef debug_flags
if (!strcmp(arg,"-DN")) {
debug_flags= 0;
+ } else if (!strcmp(arg,"-D1")) {
+ debug_flags= ~(dbg_sql2|dbg_lp|dbg_value2);
else final_isle= atoi(final_isle_spec);
assert(final_isle);
else final_isle= atoi(final_isle_spec);
assert(final_isle);
- PotentialResult ****buckets_base_io[GRANUS];
+ Bucket ****buckets_base_io[GRANUS];
for (granui=0; granui<GRANUS; granui++)
buckets_base_io[granui]= &results[granui][resultsix];
for (granui=0; granui<GRANUS; granui++)
buckets_base_io[granui]= &results[granui][resultsix];
for (granui=0; granui<granus; granui++) {
fprintf(output,"\n");
for (i=0; i<resultsix; i++) {
for (granui=0; granui<granus; granui++) {
fprintf(output,"\n");
for (i=0; i<resultsix; i++) {
- tabdebugf("========== start #%d granui%d %s [PARTIAL] ==========\n",
+ tabdebugf("========== start #%d granui%d %s ==========\n",
- PotentialResult ***buckets_resultsix= results[granui][i];
+ Bucket ***buckets_resultsix= results[granui][i];
if (!buckets_resultsix) continue;
tabdebugf(" ");
for (mid=0; mid<granusz_mid[granui]; mid++) {
if (!buckets_resultsix) continue;
tabdebugf(" ");
for (mid=0; mid<granusz_mid[granui]; mid++) {
}
tabdebugf("\n");
for (fin=0; fin<granusz_fin[granui]; fin++) {
}
tabdebugf("\n");
for (fin=0; fin<granusz_fin[granui]; fin++) {
- PotentialResult **buckets_fin= buckets_resultsix[fin];
+ Bucket **buckets_fin= buckets_resultsix[fin];
if (!buckets_fin) continue;
tabdebugf("f%-3d",fin);
for (mid=0; mid<granusz_mid[granui]; mid++) {
if (!buckets_fin) continue;
tabdebugf("f%-3d",fin);
for (mid=0; mid<granusz_mid[granui]; mid++) {
- PotentialResult *result= buckets_fin[mid];
+ Bucket *result= buckets_fin[mid];
if (!result) {
tabdebugf("| ");
} else {
if (!result) {
tabdebugf("| ");
} else {
- tabdebugf("|%5d",(int)(result->value[A]));
+ tabdebugf("|%5d",(int)(result->prs[A].value[A]));
- tabdebugf("%4d",(int)(result->value[P]));
+ tabdebugf("%4d",(int)(result->prs[P].value[P]));
granui, ap);
for (pos=nhighscores[granui][ap]-1; pos>=0; pos--) {
HighScoreEntry *hs= &highscores[granui][ap][pos];
granui, ap);
for (pos=nhighscores[granui][ap]-1; pos>=0; pos--) {
HighScoreEntry *hs= &highscores[granui][ap][pos];
- PotentialResult *pr= hs->pr;
- if (!pr) continue;
- const int *const ports= pr->ports[ap];
+ 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 nports;
for (nports=0; nports<MAX_ROUTELEN && ports[nports]>=0; nports++);
int finisle= ports[nports-1];
-static PotentialResult ***buckets_base[GRANUS];
+static Bucket ***buckets_base[GRANUS];
static double process_route(int nports, int totaldist,
static double process_route(int nports, int totaldist,
- if (guess[A] <= highscores[GRANUS-1][A][0].value &&
- guess[P] <= highscores[GRANUS-1][P][0].value) {
+ if (guess[A] <= highscores[granus-1][A][0].value &&
+ guess[P] <= highscores[granus-1][P][0].value) {
ctr_routes_quickelim++;
debugf(" QELIM %f %f\n", guess[A], guess[P]);
return guess[A];
ctr_routes_quickelim++;
debugf(" QELIM %f %f\n", guess[A], guess[P]);
return guess[A];
int midisle= ports[nports/2];
int midarch= route2midarch(ports,nports);
int midisle= ports[nports/2];
int midarch= route2midarch(ports,nports);
- PotentialResult *buckets[GRANUS];
+ Bucket *buckets[GRANUS];
int granui;
for (granui=0; granui<granus; granui++) {
int granui;
for (granui=0; granui<granus; granui++) {
- PotentialResult **buckets_fin;
int mid, fin;
switch (granui) {
case 0: fin=finarch; mid=midarch; break;
int mid, fin;
switch (granui) {
case 0: fin=finarch; mid=midarch; break;
- if (guess[A] <= buckets[0]->value[A] &&
- guess[P] <= buckets[0]->value[P]) {
+ if (guess[A] <= buckets[0]->prs[A].value[A] &&
+ guess[P] <= buckets[0]->prs[P].value[P]) {
ctr_routes_bucketelim++;
debugf(" ELIM %f %f\n", guess[A], guess[P]);
return guess[A];
ctr_routes_bucketelim++;
debugf(" ELIM %f %f\n", guess[A], guess[P]);
return guess[A];
}
for (granui=granus-1; granui>=0; granui--) {
}
for (granui=granus-1; granui>=0; granui--) {
- PotentialResult *bucket= buckets[granui];
+ Bucket *bucket= buckets[granui];
- if (value[A] <= bucket->value[A] &&
- value[P] <= bucket->value[P])
+ if (value[A] <= bucket->prs[A].value[A] &&
+ value[P] <= bucket->prs[P].value[P])
continue;
debugf(" SOMEHOW %d BEST\n",granui);
continue;
debugf(" SOMEHOW %d BEST\n",granui);
- fildebugf("final %d:%3d mid %d ",finarch,finisle,midarch);
- int relevant=0;
+ fildebugf("granu %d f%d:%3d mid%d:%3d ",granui,
+ finarch,finisle,midarch,midisle);
for (ap=0; ap<AP; ap++) {
HighScoreEntry *scores= highscores[granui][ap];
for (ap=0; ap<AP; ap++) {
HighScoreEntry *scores= highscores[granui][ap];
- int *nscores= &nhighscores[granui][ap];
+ int nscores= nhighscores[granui][ap];
fildebugf("ap=%d %15f", ap, value[ap]);
fildebugf("ap=%d %15f", ap, value[ap]);
- if (value[ap] < bucket->value[ap]) {
+ if (value[ap] < bucket->prs[ap].value[ap]) {
debugf(" ");
} else {
int pos;
ctr_newbests_granu[granui*AP+ap]++;
debugf(" ");
} else {
int pos;
ctr_newbests_granu[granui*AP+ap]++;
- bucket->value[ap]= value[ap];
- memcpy(bucket->ports[ap], ports, sizeof(*ports) * nports);
- if (nports < MAX_ROUTELEN-1) bucket->ports[ap][nports]= -1;
+ memcpy(bucket->prs[ap].value, value, sizeof(value));
+ memcpy(bucket->prs[ap].ports, ports, sizeof(*ports) * nports);
+ if (nports < MAX_ROUTELEN-1) bucket->prs[ap].ports[nports]= -1;
- for (pos=0; pos < *nscores; pos++)
- if (scores[pos].pr == bucket) goto found;
+ for (pos=0; pos < nscores; pos++)
+ if (scores[pos].bucket == bucket) goto found;
/* not found */
pos= -1;
found:
for (;;) {
pos++;
/* not found */
pos= -1;
found:
for (;;) {
pos++;
- if (pos >= *nscores-1) break; /* new top */
+ if (pos >= nscores-1) break; /* new top */
if (scores[pos].value >= value[ap]) break; /* found spot */
if (pos>0)
scores[pos-1]= scores[pos];
if (scores[pos].value >= value[ap]) break; /* found spot */
if (pos>0)
scores[pos-1]= scores[pos];
pos--;
if (pos>0) {
scores[pos].value= value[ap];
pos--;
if (pos>0) {
scores[pos].value= value[ap];
- scores[pos].pr= bucket;
- relevant=1;
+ scores[pos].bucket= bucket;
+ if (granui < granus-1 &&
+ highscores[granui][A][0].bucket &&
+ highscores[granui][P][0].bucket) {
+ /* both absolute and perleague are full at this granularity,
+ * so we don't care about anything more granular */
+ fildebugf("\n STOP-GRANU ");
+ granus= granui+1;
+ }
- fildebugf("@%2d", pos);
+ fildebugf("@%2d/%2d ", pos, nscores);
} /* new best */
} /* ap */
} /* new best */
} /* ap */
- if (!relevant)
- /* both absolute and perleague are full at this granularity,
- * so we don't care about anything more granular */
- granus= granui+1;
} /* granui */
fildebugf(" route");
} /* granui */
fildebugf(" route");
}
void search(int start_isle, int final_isle_spec,
}
void search(int start_isle, int final_isle_spec,
- PotentialResult ****buckets_base_io[GRANUS]) {
+ Bucket ****buckets_base_io[GRANUS]) {
int granui;
for (granui=0; granui<GRANUS; granui++)
buckets_base[granui]=
int granui;
for (granui=0; granui<GRANUS; granui++)
buckets_base[granui]=
int islandtablesz;
DEBUG_DEFINE_DEBUGF(sql);
int islandtablesz;
DEBUG_DEFINE_DEBUGF(sql);
+DEBUG_DEFINE_SOME_DEBUGF(sql,debug2f);
static int busy_handler(void *u, int previous) {
debugf("[[DB BUSY %d]]",previous);
static int busy_handler(void *u, int previous) {
debugf("[[DB BUSY %d]]",previous);
void sql_bind(sqlite3_stmt *ss, int index, int value,
const char *ss_what, const char *val_what) {
void sql_bind(sqlite3_stmt *ss, int index, int value,
const char *ss_what, const char *val_what) {
- debugf("SQL BIND %s #%d = %d = %s\n", ss_what, index, value, val_what);
+ debug2f("SQL BIND %s #%d = %d = %s\n", ss_what, index, value, val_what);
int sqr= sqlite3_bind_int(ss, index, value);
if (sqr) sql_fatal(ss_what, sqr,
masprintf("bind #%d (%s)", index, val_what));
int sqr= sqlite3_bind_int(ss, index, value);
if (sqr) sql_fatal(ss_what, sqr,
masprintf("bind #%d (%s)", index, val_what));
sqr= sqlite3_step((ssh));
switch (sqr) {
case SQLITE_DONE:
sqr= sqlite3_step((ssh));
switch (sqr) {
case SQLITE_DONE:
- debugf("SQL %s DONE\n",ssh_string);
+ debug2f("SQL %s DONE\n",ssh_string);
return 0;
case SQLITE_ROW:
return 0;
case SQLITE_ROW:
int i;
fprintf(debug,"SQL %s R",ssh_string);
for (i=0; i<sqlite3_column_count(ssh); i++) {
int i;
fprintf(debug,"SQL %s R",ssh_string);
for (i=0; i<sqlite3_column_count(ssh); i++) {
#include "rscommon.h"
DEBUG_DEFINE_DEBUGF(value);
#include "rscommon.h"
DEBUG_DEFINE_DEBUGF(value);
+DEBUG_DEFINE_SOME_DEBUGF(value2,debug2f);
typedef struct { int mass, volu; } CommodInfo;
static int commodstabsz;
typedef struct { int mass, volu; } CommodInfo;
static int commodstabsz;
if (si==di) ctr_islands_arbitrage++;
else ctr_ipairs_relevant++;
if (si==di) ctr_islands_arbitrage++;
else ctr_ipairs_relevant++;
- debugf("VALUE ipair_get(i%d,i%d) running...\n", si,di);
+ debug2f("VALUE ipair_get(i%d,i%d) running...\n", si,di);
SQL_MUST( sqlite3_bind_int(ss_ipair_dist, 1, si) );
SQL_MUST( sqlite3_bind_int(ss_ipair_dist, 2, di) );
assert(SQL_STEP(ss_ipair_dist));
SQL_MUST( sqlite3_bind_int(ss_ipair_dist, 1, si) );
SQL_MUST( sqlite3_bind_int(ss_ipair_dist, 2, di) );
assert(SQL_STEP(ss_ipair_dist));
lpx_delete_prob(lp);
lp= 0;
lpx_delete_prob(lp);
lp= 0;
+ debugf(" %s %f\n",
+ exclude_arbitrage ? "base value" : "route value",
+ profit);
-set args -DN OCEAN-Midnight.db 13460 20210 -1 0.0005 search 10 20 20 circ 4 19 134 32 13 24 36
+set args OCEAN-Midnight.db 13470 20220 -1 0.0005 search 10 10 30 any 34 7 5 10 35 24 2 2>u
+#break rssearch.c:179 if ports[0]==24 && ports[1]==21