From 22f2c2e0c21461f4a5e78b9735bf6395cb7a367f Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 2 Oct 2009 23:12:51 +0100 Subject: [PATCH] Can compute route value --- yarrg/rscommon.h | 2 +- yarrg/rsvalue.c | 8 ++++++-- yarrg/x.gdb | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/yarrg/rscommon.h b/yarrg/rscommon.h index 860409e..d068fa0 100644 --- a/yarrg/rscommon.h +++ b/yarrg/rscommon.h @@ -51,6 +51,6 @@ void setup_commods(void); extern double max_mass, max_volu, max_capi; extern double distance_loss_factor_per_league; -#define LOSS_FACTOR_PER_DELAY_SLOT (1-1e8) +#define LOSS_FACTOR_PER_DELAY_SLOT (1-1e-8) #endif /*RSCOMMON_H*/ diff --git a/yarrg/rsvalue.c b/yarrg/rsvalue.c index 135583e..f1a8d22 100644 --- a/yarrg/rsvalue.c +++ b/yarrg/rsvalue.c @@ -299,11 +299,15 @@ double value_route(int nislands, const int *islands) { add_leg_c(capi_constraints, leg, t->src_price); } + 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, - (t->dst_price - t->src_price) * loss_factor); + 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); diff --git a/yarrg/x.gdb b/yarrg/x.gdb index 3e4083f..c3fc638 100644 --- a/yarrg/x.gdb +++ b/yarrg/x.gdb @@ -1,5 +1,5 @@ file routesearch -set args 34 36 +set args -1 -1 -1 0 34 36 34 36 break value_route run finish -- 2.30.2