TradesBlock *trades;
} IslandPair;
-int nislands;
IslandPair ***ipairs; /* ipairs[sislandid][dislandid] */
typedef struct IslandTradeEnd {
int leg, startrow;
if (max_thing < 0 || !legs) return -1;
startrow= lpx_add_rows(lp, legs);
- for (leg=0; leg<nislands-1; leg++) {
+ for (leg=0; leg<legs; leg++) {
int row= leg+startrow;
lpx_set_row_bnds(lp, row, LPX_UP, 0, max_thing);
if (DEBUGP(value)) {
static IslandPair *ipair_get(int si, int di) {
IslandPair *ip, **ipa;
- assert(si < nislands);
- assert(di < nislands);
+ assert(si < islandtablesz);
+ assert(di < islandtablesz);
if (!(ipa= ipairs[si])) {
- ipa= ipairs[si]= mcalloc(sizeof(*ipa) * nislands);
+ ipa= ipairs[si]= mcalloc(sizeof(*ipa) * islandtablesz);
}
if ((ip= ipa[di]))
return ip;
double unit_profit= (t->dst_price - t->src_price) * loss_factor;
debugf(" unit profit %f\n", unit_profit);
-assert(unit_profit < 1e6);
lpx_set_col_bnds(lp, col, LPX_LO, 0, 0);
lpx_set_obj_coef(lp, col, unit_profit);
next_s:;
} /* for (s) */
- if (DEBUGP(lp))
- lpx_write_cpxlp(lp, (char*)"/dev/stdout");
+ double profit= 0;
- int ipr= lpx_interior(lp);
- assert(ipr==LPX_E_OK);
+ if (lpx_get_num_cols(lp)) {
+ if (DEBUGP(lp))
+ lpx_write_cpxlp(lp, (char*)DEBUG_DEV);
- if (DEBUGP(lp))
- lpx_print_ips(lp, (char*)"/dev/stdout");
+ int ipr= lpx_interior(lp);
+ assert(ipr==LPX_E_OK);
- assert(lpx_ipt_status(lp) == LPX_T_OPT);
- double profit= lpx_ipt_obj_val(lp);
+ if (DEBUGP(lp))
+ lpx_print_ips(lp, (char*)DEBUG_DEV);
+
+ assert(lpx_ipt_status(lp) == LPX_T_OPT);
+ profit= lpx_ipt_obj_val(lp);
+ }
lpx_delete_prob(lp);
lp= 0;
sqlite3_stmt *sst;
int i;
- nislands= sql_single_int("SELECT max(islandid) FROM islands") + 1;
- debugf("VALUE nislands=%d\n",nislands);
-
commodstablesz= sql_single_int("SELECT max(commodid) FROM commods") + 1;
commodstable= mmalloc(sizeof(*commodstable)*commodstablesz);
for (i=0; i<commodstablesz; i++)
BS(sell)
#undef BS
- ipairs= mcalloc(sizeof(*ipairs) * nislands);
+ ipairs= mcalloc(sizeof(*ipairs) * islandtablesz);
}