#include "common.h"
+#define COUNTER_LIST \
+ CTR(commodities_loaded) \
+ CTR(trades_loaded) \
+ CTR(quantities_loaded) \
+ CTR(routes_considered) \
+ CTR(routes_eliminated) \
+ CTR(routes_valued) \
+ CTR(subroute_tails_valued) \
+ CTR(subroutes_valued) \
+ CTR(subroutes_nonempty)
+#define CTR(x) extern int ctr_##x;
+ COUNTER_LIST
+#undef CTR
+
#define SQL_MUST( call ) ({ \
/* `call' is an expression returning result, using const char *sqe; \
* chk1 and chk2 are blocks using sqe and int sqr; */ \
double distance_loss_factor_per_league;
int max_dist= -1;
+#define CTR(x) int ctr_##x;
+ COUNTER_LIST
+#undef CTR
+
int main(int argc, const char **argv) {
const char *arg;
setup_sql();
setup_value();
setup_search();
+
+ fprintf(stderr,"setup complete, starting search\n");
arg= *argv++;
if (!strcmp(arg,"specific")) {
} else {
abort();
}
+
+#define CTR(x) fprintf(stderr," %-30s %10d\n",#x,ctr_##x);
+ COUNTER_LIST
+#undef CTR
+
return 0;
}
int i;
int leagues_divisor= totaldist + nports;
+ ctr_routes_considered++;
+
debugf("========== ROUTE");
for (i=0; i<nports; i++)
debugf(" %d",ports[i]);
pair[0]= ports[i];
IslandPair *ip= ipair_get_maybe(pair[0], pair[1]);
if (!ip) continue;
- if (ip->route_tail_value < 0)
+ if (ip->route_tail_value < 0) {
+ ctr_subroute_tails_valued++;
ip->route_tail_value= value_route(2, pair, pair[0]!=pair[1]);
+ }
guess_absolute += ip->route_tail_value;
}
double guess_perleague= guess_absolute / leagues_divisor;
if (guess_absolute <= best_absolute && guess_perleague <= best_perleague) {
+ ctr_routes_eliminated++;
debugf(" ELIM %f %f\n", guess_absolute, guess_perleague);
return guess_absolute;
}
debugf(" COMPUTE %f %f\n", guess_absolute, guess_perleague);
}
+ ctr_routes_valued++;
+
double absolute= value_route(nports, ports, 0);
double perleague= absolute / leagues_divisor;
static sqlite3_stmt *ss_ipair_dist;
static sqlite3_stmt *ss_ite_buy, *ss_ite_sell;
+
#define MAX_LEGS (MAX_ROUTELEN-1)
typedef struct {
double value_route(int nislands, const int *islands, int exclude_arbitrage) {
int s,d;
+ ctr_subroutes_valued++;
+
/* We need to construct the LP problem. GLPK talks
* about rows and columns, which are numbered from 1.
*
double profit= 0;
if (lpx_get_num_cols(lp)) {
+ ctr_subroutes_nonempty++;
+
if (DEBUGP(lp))
lpx_write_cpxlp(lp, (char*)DEBUG_DEV);
SQL_DISTINCT_DECL(cols,5);
while (SQL_DISTINCT_STEP(ss_trades,cols,5)) {
+ ctr_trades_loaded++;
IslandPair *ip= ipair_get_create(cols[1], cols[3]);
TradesBlock *block= ip->trades;
if (!block || ip->trades->ntrades >= TRADES_PER_BLOCK) {
SQL_DISTINCT_DECL(cols,5);
while (SQL_DISTINCT_STEP(ss,cols,3)) {
+ ctr_quantities_loaded++;
IslandTradeEnd *search;
int commodid= cols[0];
SQL_PREPARE(sst,
"SELECT commodid,unitmass,unitvolume FROM commods");
while (SQL_STEP(sst)) {
+ ctr_commodities_loaded++;
int id= sqlite3_column_int(sst,0);
assert(id>=0 && id<commodstabsz);
commodstab[id].mass= sqlite3_column_int(sst,1);