Search code examples
linear-programmingmixed-integer-programmingscip

How to solve the linear relaxation of a PySCIPOpt Model


Given a pyscipopt.Model, how to solve its linear relaxation in the shortest code possible?

The documentation is hard to navigate. There was a similar question before, but the answer does not apply here.


Solution

  • You need to iterate through all variables and change their types to CONTINUOUS:

    for v in model.getVars():
        m.chgVarType(v, 'CONTINUOUS')
    

    Then you can solve the LP relaxation of the problem. Please note that your model should be a standard MIP and not contain any nonlinear or general constraints.