PySCIPOpt icon indicating copy to clipboard operation
PySCIPOpt copied to clipboard

How to set the initial solution in MIP problems?

Open primalhy opened this issue 3 years ago • 1 comments

How to set primal starting value?There is a method(Start) in gurobi to set the initial solution. Thanks

primalhy avatar Jul 14 '22 17:07 primalhy

You can do something like what is described here: https://github.com/scipopt/PySCIPOpt/issues/114

Essentially, you need to create a solution with model.createSol() and add the values to the variables with model.setSolVal(s, x, 1), assuming you named the solution s, and are trying to give the value of 1 to variable x. Just don't forget that you need to provide a value to all the variables, both integer and continuous. Afterwards, simply do model.addSol(s) to add the solution you've created.

In the issue I linked, there seems to be some problems regarding addSol() and trySol(). I have been able to work with model.addSol(), but I know that the solution I am providing is feasible.

Joao-Dionisio avatar Aug 03 '22 09:08 Joao-Dionisio