CVXOPT + GLPK - Extract lagrange multiplier from LP solution

900 views Asked by At

I'm trying to solve a generic optimization problem with both inequality and equality constraints using CVXOPT's solvers.lp and GLPK.

Everything works fine but i'm not able to extract the Lagrangian multipliers.

This is my code:

  # Convert numpy matrices to cvxopt matrices
  c = cvxopt.matrix(c)         #(2666x4)
  A_in = cvxopt.matrix(A_in)
  b_in = cvxopt.matrix(b_in)

  A_eq = cvxopt.matrix(A_eq)
  b_eq = cvxopt.matrix(b_eq)

  # set glpk optimiser settings
  cvxopt.solvers.options['glpk'] = {'msg_lev': 'GLP_MSG_OFF'}
  cvxopt.solvers.options['msg_lev'] = 'GLP_MSG_OFF'
  cvxopt.solvers.options['LP_K_MSGLEV'] = 0
  cvxopt.solvers.options['abstol'] = 1e-3
  cvxopt.solvers.options['reltol'] = 1e-2
  cvxopt.solvers.options['feastol'] = 1
  cvxopt.solvers.options['refinement'] = 1

  # solve the problem using glpk
  res = cvxopt.solvers.lp(c, A_in, b_in, A=A_eq, b=b_eq, solver='glpk')

Which returns:

res = {
 'dual infeasibility': 3.405900733836188e-17,
 'dual objective': -146734334.08,
 'dual slack': -0.0,
 'gap': 0.0,
 'primal infeasibility': 9.663381206337363e-12,
 'primal objective': -146734334.08,
 'primal slack': 0.0,
 'relative gap': 0.0,
 'residual as dual infeasibility certificate': None,
 'residual as primal infeasibility certificate': None,
 's': <5367x1 matrix, tc='d'>,
 'status': 'optimal',
 'x': <2666x1 matrix, tc='d'>,
 'y': <1x1 matrix, tc='d'>,
 'z': <5367x1 matrix, tc='d'>
}

I don't feel that comfortable with the math behind simplex optimization and its implementation in CVXOPT's solver, but as far as i know, the lp method doesn't use Lagrange multipliers at all to minimize the objective function.

Is there a way to extract/calculate them from the result object?

What i need is something similar to lambda property returned by MATLAB's linprog:

[x,fval,exitflag,output,lambda] = linprog(c, A_in, b_in, A_eq, b_eq, lb, ub, [], opt);
0

There are 0 answers