Adrien Varet
Adrien Varet

Reputation: 433

[Java][Glpk]Solve dual solution

I have a linear problem and I want to get optimal dual solution with GLPK on Java. I tried this :

parm = new glp_smcp();
parm.setMeth(GLPKConstants.GLP_DUAL);
GLPK.glp_init_smcp(parm);
ret = GLPK.glp_simplex(lp, parm);

but it seems there I always have primal Solution. Someone can help me ?

Upvotes: 0

Views: 682

Answers (1)

Erwin Kalvelagen
Erwin Kalvelagen

Reputation: 16782

The line

 parm.setMeth(GLPKConstants.GLP_DUAL);

will select the dual simplex method. It does not give you the dual solution per se. (To be precise: afterwards you can retrieve both the primal and dual solution).

The way to retrieve the solution after solving is:

GLPK.glp_get_col_prim(lp,j)   // retrieve primal solution
GLPK.glp_get_row_dual(lp,i)   // retrieve duals 

Remember in linear programming

  • Dual Simplex Method
  • The Dual of an LP problem
  • Duals in a solution

are all different things. For more information please consult a book on Linear Programming (e.g. Vanderbei).

Upvotes: 1

Related Questions