+
+ double loss_factor= delay_slot_loss_factor * ip->distance_loss_factor;
+ debugf(" SOME i%d#%d..i%d#%d dslf=%g dlf=%g lf=%g\n",
+ si,s, di,d,
+ delay_slot_loss_factor, ip->distance_loss_factor, loss_factor);
+
+ TradesBlock *block;
+ for (block=ip->trades; block; block=block->next) {
+ int inblock;
+ for (inblock=0; inblock<block->ntrades; inblock++) {
+ Trade *t= &block->t[inblock];
+
+ debugf(" TRADE i%d#%d..i%d#%d c%d %d-%d ",
+ si,s, di,d, t->commodid, t->src_price, t->dst_price);
+
+ nconstraint_rows=0;
+
+ avail_c(t, &itradeends[si].src, t->src_price, "src", si,ss_ite_sell);
+ avail_c(t, &itradeends[di].dst, t->dst_price, "dst", di,ss_ite_buy);
+
+ int leg;
+ for (leg=s; leg<d; leg++) {
+ add_leg_c(mass_constraints,leg, commodstab[t->commodid].mass*1e-3);
+ add_leg_c(volu_constraints,leg, commodstab[t->commodid].volu*1e-3);
+ add_leg_c(capi_constraints,leg, t->src_price);
+ }
+
+ double unit_profit= t->dst_price * loss_factor - t->src_price;
+ debugf(" unit profit %f\n", unit_profit);
+ if (unit_profit <= 0) continue;
+
+ int col= lpx_add_cols(lp,1);
+ lpx_set_col_bnds(lp, col, LPX_LO, 0, 0);
+ lpx_set_obj_coef(lp, col, unit_profit);
+ lpx_set_mat_col(lp, col, nconstraint_rows,
+ constraint_rows, constraint_coeffs);
+
+ if (DEBUGP(value)) {
+ char *name= masprintf("c%d_p%d_%d_p%d_%d", t->commodid,
+ s, t->src_price, d, t->dst_price);
+ lpx_set_col_name(lp, col, name);
+ free(name);
+ }
+ } /* inblock */
+ } /* block */
+
+ /*----- that's done adding these trades to the LP problem -----*/