help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] help to get dual solution from glp_simplex


From: Andrew Makhorin
Subject: Re: [Help-glpk] help to get dual solution from glp_simplex
Date: Fri, 07 Oct 2011 01:43:12 +0400

> I'm using glpk with linux, writing in C++.
>  
> I succeeded in getting results of Simplex by using glp_simplex.
> The results are the primal solution.
>  
> Now I need to get the dual solution (also known as shadow price).
> I tried the code below (simplified)
>  
> ////////////////////////////////////////////////////////// begin
>  
> // load data to lp ....
>  
> // create param setting method to DUAL
>     glp_smcp parm;
>     glp_init_smcp(&parm);
>     parm.meth = GLP_DUAL;
>  
> // call simplex
>     glp_simplex(lp, &parm);
>  
> ////////////////////////////////////////////////////////// end
>  
> The glp_simplex function returns the same solution as it the method was
> GLP_PRIMAL.

The GLP_DUAL option tells glp_simplex to solve the lp instance with the
dual simplex rather than with the primal one. This option does not mean
that your lp is somehow converted to its dual counterpart.

>  
> I would appreciate if someone could give me an example of how to write code
> to get the dual solution (shadow price).

You need to use the routines glp_get_row_dual and glp_get_col_dual.
For more details please see the glpk reference manual (doc/glpk.pdf)
included in the distribution.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]