Search code examples
optimizationscip

Using soplex command line to output a solution


So taking a trivial problem, test.lp

Maximize
 obj: b1 + b2
Subject To
 c1: + 2 b1 + 2 b2  <= 3
Binary
 b1 b2
End

Has an immediately obvious answer that either b1 or b2 should be 1, and the other 0.

I am able to run SoPlex like:

soplex --lpfile test.lp -X -x

which outputs:

SoPlex status       : problem is solved [optimal]
Solving time (sec)  : 0.00
Iterations          : 1
Objective value     : 1.50000000e+00


Primal solution (name, value):
b1      5.0000000000000000e-01
b2      1.0000000000000000e+00

Which it's clear it's "normalized" the problem by dividing everything by 2 (as you can see the objective is 1.5, not 3 and it returns the solution is b1 is 0.5 instead 1).

So my question is, how to output the actual variable solution. Preferably in it's own file. It seems like this would be really obvious, but I can't find anything after hours of looking and experimenting!


Solution

  • The solution is perfectly correct. Your constraint limits either b1 or b2 to be 0.5 while the other variable can be 1. This makes the constraint tight and leads to an optimal solution value of 1.5.

    Please note that SoPlex is a pure LP solver, so specifying variables as binary is just going to be ignored by the solver. You should check out SCIP if you want to solve integer optimization problems.