If we are solving a linear program and the problem is unbounded, then is it possible to get a primal ray which leads to the unboundedness? I found this pyscipopt.lp.getPrimalRay. But I did not find any examples on how to create a pyscipopt.lp object. Can someone suggest how to get a primal ray for a pyscipopt.scip.Model object.
An example of a model which leads to unboundedness -
from pyscipopt import *
model = Model("Example")
x = model.addVar("x")
y = model.addVar("y")
model.setObjective(-x -y)
model.addCons(2*x - y*y >= 0)
model.optimize()
sol = model.getBestSol()
print("x: {}".format(sol[x]))
print("y: {}".format(sol[y]))
There is a method in SCIP that gives you the values of the primal ray (if one exists) called SCIPgetPrimalRayVal
which will give you the value for a certain variable. However, that method is not yet wrapped inside PySCIPopt
.
You can easily do this yourself though (just do the same as all the methods in scip.pyx
) for both SCIPgetPrimalRayVal
and SCIPhasPrimalRay
. And then it would be great if you could create a pull request over on the PySCIPopt github to extend the interface for everyone.