[Coin-discuss] How to get dual values.
Heesu Hwang
hxh9528 at exchange.uta.edu
Tue May 31 23:28:30 EDT 2005
My problem is to get maximum profit over feasible paths.
So, I found profit for each variable(path) and multiplied them by -1,
in order that I can solve minimization problem as you stated.
I am using CPLEX to solve the LP, and following is my problem as a MPS
format (I've got this using, lp->writeMps("lpnode", "mps", 0.0);).
I don't know why I can't get positive dual values. (Sorry, I stated wrong
before as negative)
Even I could get primal solutions and objective value.
###########################
NAME
ROWS
N obj
L c1
L c2
L c3
L c4
L c5
L c6
L c7
L c8
L c9
L c10
L c11
L c12
L c13
L c14
L c15
L c16
L c17
L c18
L c19
L c20
L c21
L c22
L c23
L c24
L c25
L c26
L c27
L c28
L c29
L c30
COLUMNS
x1 obj -142021.7 c1 1
x1 c23 1 c30 1
x2 obj -118833.72 c2 1
x2 c12 1 c26 1
x3 obj -87084.5 c3 1
x3 c17 1 c28 1
x4 obj -119134.6 c4 1
x4 c11 1 c27 1
x5 obj -132824.7 c5 1
x5 c13 1 c25 1
x6 obj -101743.82 c6 1
x6 c16 1 c29 1
x7 obj -86235.28 c7 1
x7 c24 1
x8 obj -84456.7 c8 1
x8 c21 1
x9 obj -85000.6 c9 1
x9 c15 1
x10 obj -65504.8 c10 1
x10 c14 1
RHS
rhs c1 1 c2 1
rhs c3 1 c4 1
rhs c5 1 c6 1
rhs c7 1 c8 1
rhs c9 1 c10 1
rhs c11 1 c12 1
rhs c13 1 c14 1
rhs c15 1 c16 1
rhs c17 1 c18 1
rhs c19 1 c20 1
rhs c21 1 c22 1
rhs c23 1 c24 1
rhs c25 1 c26 1
rhs c27 1 c28 1
rhs c29 1 c30 1
RANGES
BOUNDS
UP bnd x1 1
UP bnd x2 1
UP bnd x3 1
UP bnd x4 1
UP bnd x5 1
UP bnd x6 1
UP bnd x7 1
UP bnd x8 1
UP bnd x9 1
UP bnd x10 1
ENDATA
############################################################
I'm sorry if the documentation is not clear on this, but BCP treats every
problem as a minimization problem for now. You have to multiply all your
objective coefficients with -1.
--Laci
On Tue, 31 May 2005, Heesu Hwang wrote:
> Hi, all
> I am solving maximization problem, so my objective has all negative
> coefficients.
> Also, I want to generate variables using dual values, thus I've tried to
get
> the dual values in
>
> double DCG_lp::compute_lower_bound(const double old_lower_bound,
> const BCP_lp_result& lpres,
> const BCP_vec<BCP_var*>& vars,
> const BCP_vec<BCP_cut*>& cuts){
>
> cout << "# of constraints: " << cuts.size() << endl;
> int cs = cuts.size();
>
> const double * pitmp = lpres.pi();
> for(int i=0; i<cs; i++)
> cout << "(" << i+1 << ")" << pitmp[i] << " ";
> cout << endl;
>
> }
>
> However, result was strange, i.e., I can't get negative dual values, but
all
> 0's.
>
> LP: *** Starting iteration 1 ***
> DCG_lp::modify_lp_parameters
> LP node written in file lpnode.mps
> LP: Matrix size: 11 vars x 30 cuts
> LP: Solution value: -1022840.4200 / 2 , 0
> LP: Default display_lp_solution() executed.
> LP : Displaying LP solution (RelaxedSolution) :
> LP : Displaying solution :
> Algo var (internal index: 1 ) at 1.0000
> Algo var (internal index: 2 ) at 1.0000
> Algo var (internal index: 3 ) at 1.0000
> Algo var (internal index: 4 ) at 1.0000
> Algo var (internal index: 5 ) at 1.0000
> Algo var (internal index: 6 ) at 1.0000
> Algo var (internal index: 7 ) at 1.0000
> Algo var (internal index: 8 ) at 1.0000
> Algo var (internal index: 9 ) at 1.0000
> Algo var (internal index: 10 ) at 1.0000
> .........................................
> # of constraints: 30
> (1)0 (2)0 (3)0 (4)0 (5)0 (6)0 (7)0 (8)0 (9)0 (10)0 (11)0 (12)0 (13)0 (14)0
> (15)0 (16)0 (17)0 (18)0 (19)0 (20)0 (21)0 (22)0 (23)0 (24)0 (25)0 (26)0
> (27)0 (28)0 (29)0 (30)0
>
> Help me to get dual values.
>
> Thanks in advance,
>
> Peter.
>
> _______________________________________________
> Coin-discuss mailing list
> Coin-discuss at list.coin-or.org
> http://list.coin-or.org/mailman/listinfo/coin-discuss
>
_______________________________________________
Coin-discuss mailing list
Coin-discuss at list.coin-or.org
http://list.coin-or.org/mailman/listinfo/coin-discuss
More information about the Coin-discuss
mailing list