Model API

Contents

Model API#

class pyscipopt.Model#
activateBenders(benders, nsubproblems)#

Activates the Benders’ decomposition plugin with the input name.

Parameters:
  • benders (Benders) – the Benders’ decomposition to which the subproblem belongs to

  • nsubproblems (int) – the number of subproblems in the Benders’ decomposition

addBendersSubproblem(benders, subproblem)#

Adds a subproblem to the Benders’ decomposition given by the input name.

Parameters:
  • benders (Benders) – the Benders’ decomposition to which the subproblem belongs to

  • subproblem (Model) – the subproblem to add to the decomposition

addCoefKnapsack(cons, var, weight)#

Adds coefficient to knapsack constraint (if it is not zero)

Parameters:
  • cons (Constraint) – knapsack constraint

  • var (Variable) – variable of constraint entry

  • weight (float) – coefficient of constraint entry

addCoefLinear(cons, var, value)#

Adds coefficient to linear constraint (if it is not zero)

Parameters:
  • cons (Constraint) – linear constraint

  • var (Variable) – variable of constraint entry

  • value (float) – coefficient of constraint entry

addCons(cons, name='', initial=True, separate=True, enforce=True, check=True, propagate=True, local=False, modifiable=False, dynamic=False, removable=False, stickingatnode=False)#

Add a linear or nonlinear constraint.

Parameters:
  • cons (ExprCons) – the constraint expression to add to the model (e.g., x + y <= 5)

  • name (str, optional) – the name of the constraint, generic name if empty (Default value = “”)

  • initial (bool, optional) – should the LP relaxation of constraint be in the initial LP? (Default value = True)

  • separate (bool, optional) – should the constraint be separated during LP processing? (Default value = True)

  • enforce (bool, optional) – should the constraint be enforced during node processing? (Default value = True)

  • check (bool, optional) – should the constraint be checked for feasibility? (Default value = True)

  • propagate (bool, optional) – should the constraint be propagated during node processing? (Default value = True)

  • local (bool, optional) – is the constraint only valid locally? (Default value = False)

  • modifiable (bool, optional) – is the constraint modifiable (subject to column generation)? (Default value = False)

  • dynamic (bool, optional) – is the constraint subject to aging? (Default value = False)

  • removable (bool, optional) – should the relaxation be removed from the LP due to aging or cleanup? (Default value = False)

  • stickingatnode (bool, optional) – should the constraints always be kept at the node where it was added, even if it may be moved to a more global node? (Default value = False)

Returns:

The created and added Constraint object.

Return type:

Constraint

addConsAnd(vars, resvar, name='', initial=True, separate=True, enforce=True, check=True, propagate=True, local=False, modifiable=False, dynamic=False, removable=False, stickingatnode=False)#

Add an AND-constraint.

Parameters:
  • vars (list of Variable) – list of BINARY variables to be included (operators)

  • resvar (Variable) – BINARY variable (resultant)

  • name (str, optional) – name of the constraint (Default value = “”)

  • initial (bool, optional) – should the LP relaxation of constraint be in the initial LP? (Default value = True)

  • separate (bool, optional) – should the constraint be separated during LP processing? (Default value = True)

  • enforce (bool, optional) – should the constraint be enforced during node processing? (Default value = True)

  • check (bool, optional) – should the constraint be checked for feasibility? (Default value = True)

  • propagate (bool, optional) – should the constraint be propagated during node processing? (Default value = True)

  • local (bool, optional) – is the constraint only valid locally? (Default value = False)

  • dynamic (bool, optional) – is the constraint subject to aging? (Default value = False)

  • removable (bool, optional) – should the relaxation be removed from the LP due to aging or cleanup? (Default value = False)

  • stickingatnode (bool, optional) – should the constraint always be kept at the node where it was added, even if it may be moved to a more global node? (Default value = False)

Returns:

The newly created AND constraint

Return type:

Constraint

addConsCardinality(consvars, cardval, indvars=None, weights=None, name='', initial=True, separate=True, enforce=True, check=True, propagate=True, local=False, dynamic=False, removable=False, stickingatnode=False)#

Add a cardinality constraint that allows at most ‘cardval’ many nonzero variables.

Parameters:
  • consvars (list of Variable) – list of variables to be included

  • cardval (int) – nonnegative integer

  • indvars (list of Variable or None, optional) – indicator variables indicating which variables may be treated as nonzero in cardinality constraint, or None if new indicator variables should be introduced automatically (Default value = None)

  • weights (list of float or None, optional) – weights determining the variable order, or None if variables should be ordered in the same way they were added to the constraint (Default value = None)

  • name (str, optional) – name of the constraint (Default value = “”)

  • initial (bool, optional) – should the LP relaxation of constraint be in the initial LP? (Default value = True)

  • separate (bool, optional) – should the constraint be separated during LP processing? (Default value = True)

  • enforce (bool, optional) – should the constraint be enforced during node processing? (Default value = True)

  • check (bool, optional) – should the constraint be checked for feasibility? (Default value = True)

  • propagate (bool, optional) – should the constraint be propagated during node processing? (Default value = True)

  • local (bool, optional) – is the constraint only valid locally? (Default value = False)

  • dynamic (bool, optional) – is the constraint subject to aging? (Default value = False)

  • removable (bool, optional) – should the relaxation be removed from the LP due to aging or cleanup? (Default value = False)

  • stickingatnode (bool, optional) – should the constraint always be kept at the node where it was added, even if it may be moved to a more global node? (Default value = False)

Returns:

The newly created Cardinality constraint

Return type:

Constraint

addConsCoeff(cons, var, coeff)#

Add coefficient to the constraint (if non-zero).

Parameters:
  • cons (Constraint) – Constraint to be changed

  • var (Variable) – variable to be added

  • coeff (float) – coefficient of new variable

addConsDisjunction(conss, name='', initial=True, relaxcons=None, enforce=True, check=True, local=False, modifiable=False, dynamic=False)#

Add a disjunction constraint.

Parameters:
  • conss (iterable of ExprCons) – An iterable of constraint objects to be included initially in the disjunction. Currently, these must be expressions.

  • name (str, optional) – the name of the disjunction constraint.

  • initial (bool, optional) – should the LP relaxation of disjunction constraint be in the initial LP? (Default value = True)

  • relaxcons (None, optional) – a conjunction constraint containing the linear relaxation of the disjunction constraint, or None. NOT YET SUPPORTED. (Default value = None)

  • enforce (bool, optional) – should the constraint be enforced during node processing? (Default value = True)

  • check (bool, optional) – should the constraint be checked for feasibility? (Default value = True)

  • local (bool, optional) – is the constraint only valid locally? (Default value = False)

  • modifiable (bool, optional) – is the constraint modifiable (subject to column generation)? (Default value = False)

  • dynamic (bool, optional) – is the constraint subject to aging? (Default value = False)

Returns:

The created disjunction constraint

Return type:

Constraint

addConsElemDisjunction(disj_cons, cons)#

Appends a constraint to a disjunction.

Parameters:
  • disj_cons (Constraint) – the disjunction constraint to append to.

  • cons (Constraint) – the constraint to append

Returns:

disj_cons – The disjunction constraint with cons appended.

Return type:

Constraint

addConsIndicator(cons, binvar=None, activeone=True, name='', initial=True, separate=True, enforce=True, check=True, propagate=True, local=False, dynamic=False, removable=False, stickingatnode=False)#

Add an indicator constraint for the linear inequality cons.

The binvar argument models the redundancy of the linear constraint. A solution for which binvar is 1 must satisfy the constraint.

Parameters:
  • cons (ExprCons) – a linear inequality

  • binvar (Variable, optional) – binary indicator variable, or None if it should be created (Default value = None)

  • activeone (bool, optional) – constraint should active if binvar is 1 (0 if activeone = False)

  • name (str, optional) – name of the constraint (Default value = “”)

  • initial (bool, optional) – should the LP relaxation of constraint be in the initial LP? (Default value = True)

  • separate (bool, optional) – should the constraint be separated during LP processing? (Default value = True)

  • enforce (bool, optional) – should the constraint be enforced during node processing? (Default value = True)

  • check (bool, optional) – should the constraint be checked for feasibility? (Default value = True)

  • propagate (bool, optional) – should the constraint be propagated during node processing? (Default value = True)

  • local (bool, optional) – is the constraint only valid locally? (Default value = False)

  • dynamic (bool, optional) – is the constraint subject to aging? (Default value = False)

  • removable (bool, optional) – should the relaxation be removed from the LP due to aging or cleanup? (Default value = False)

  • stickingatnode (bool, optional) – should the constraint always be kept at the node where it was added, even if it may be moved to a more global node? (Default value = False)

Returns:

The newly created Indicator constraint

Return type:

Constraint

addConsKnapsack(vars, weights, capacity, name='', initial=True, separate=True, enforce=True, check=True, modifiable=False, propagate=True, local=False, dynamic=False, removable=False, stickingatnode=False)#
Parameters:
  • vars (list of Variable) – list of variables to be included

  • weights (list of int) – list of weights

  • capacity (int) – capacity of the knapsack

  • name (str, optional) – name of the constraint (Default value = “”)

  • initial (bool, optional) – should the LP relaxation of constraint be in the initial LP? (Default value = True)

  • separate (bool, optional) – should the constraint be separated during LP processing? (Default value = True)

  • enforce (bool, optional) – should the constraint be enforced during node processing? (Default value = True)

  • check (bool, optional) – should the constraint be checked for feasibility? (Default value = True)

  • propagate (bool, optional) – should the constraint be propagated during node processing? (Default value = True)

  • local (bool, optional) – is the constraint only valid locally? (Default value = False)

  • dynamic (bool, optional) – is the constraint subject to aging? (Default value = False)

  • removable (bool, optional) – should the relaxation be removed from the LP due to aging or cleanup? (Default value = False)

  • stickingatnode (bool, optional) – should the constraint always be kept at the node where it was added, even if it may be moved to a more global node? (Default value = False)

Returns:

The newly created knapsack constraint

Return type:

Constraint

addConsLocal(cons, validnode=None, name='', initial=True, separate=True, enforce=True, check=True, propagate=True, local=True, dynamic=False, removable=True, stickingatnode=True)#

Add a constraint to the current node.

Parameters:
  • cons (ExprCons) – the constraint expression to add to the current node (e.g., x + y <= 5)

  • validnode (Node or None, optional) – more global node where cons is also valid. (Default=None)

  • name (str, optional) – name of the constraint (Default value = ‘’)

  • initial (bool, optional) – should the LP relaxation of constraint be in the initial LP? (Default value = True)

  • separate (bool, optional) – should the constraint be separated during LP processing? (Default value = True)

  • enforce (bool, optional) – should the constraint be enforced during node processing? (Default value = True)

  • check (bool, optional) – should the constraint be checked for feasibility? (Default value = True)

  • propagate (bool, optional) – should the constraint be propagated during node processing? (Default value = True)

  • local (bool, optional) – is the constraint only valid locally? (Default value = True)

  • dynamic (bool, optional) – is the constraint subject to aging? (Default value = False)

  • removable (bool, optional) – should the relaxation be removed from the LP due to aging or cleanup? (Default value = True)

  • stickingatnode (bool, optional) – should the constraint always be kept at the node where it was added? (Default value = True)

Returns:

The added Constraint object.

Return type:

Constraint

addConsNode(node, cons, validnode=None, name='', initial=True, separate=True, enforce=True, check=True, propagate=True, local=True, dynamic=False, removable=True, stickingatnode=True)#

Add a constraint to the given node.

Parameters:
  • node (Node) – node at which the constraint will be added

  • cons (ExprCons) – the constraint expression to add to the node (e.g., x + y <= 5)

  • validnode (Node or None, optional) – more global node where cons is also valid. (Default=None)

  • name (str, optional) – name of the constraint (Default value = ‘’)

  • initial (bool, optional) – should the LP relaxation of constraint be in the initial LP? (Default value = True)

  • separate (bool, optional) – should the constraint be separated during LP processing? (Default value = True)

  • enforce (bool, optional) – should the constraint be enforced during node processing? (Default value = True)

  • check (bool, optional) – should the constraint be checked for feasibility? (Default value = True)

  • propagate (bool, optional) – should the constraint be propagated during node processing? (Default value = True)

  • local (bool, optional) – is the constraint only valid locally? (Default value = True)

  • dynamic (bool, optional) – is the constraint subject to aging? (Default value = False)

  • removable (bool, optional) – should the relaxation be removed from the LP due to aging or cleanup? (Default value = True)

  • stickingatnode (bool, optional) – should the constraint always be kept at the node where it was added? (Default value = True)

Returns:

The added Constraint object.

Return type:

Constraint

addConsOr(vars, resvar, name='', initial=True, separate=True, enforce=True, check=True, propagate=True, local=False, modifiable=False, dynamic=False, removable=False, stickingatnode=False)#

Add an OR-constraint.

Parameters:
  • vars (list of Variable) – list of BINARY variables to be included (operators)

  • resvar (Variable) – BINARY variable (resultant)

  • name (str, optional) – name of the constraint (Default value = “”)

  • initial (bool, optional) – should the LP relaxation of constraint be in the initial LP? (Default value = True)

  • separate (bool, optional) – should the constraint be separated during LP processing? (Default value = True)

  • enforce (bool, optional) – should the constraint be enforced during node processing? (Default value = True)

  • check (bool, optional) – should the constraint be checked for feasibility? (Default value = True)

  • propagate (bool, optional) – should the constraint be propagated during node processing? (Default value = True)

  • local (bool, optional) – is the constraint only valid locally? (Default value = False)

  • dynamic (bool, optional) – is the constraint subject to aging? (Default value = False)

  • removable (bool, optional) – should the relaxation be removed from the LP due to aging or cleanup? (Default value = False)

  • stickingatnode (bool, optional) – should the constraint always be kept at the node where it was added, even if it may be moved to a more global node? (Default value = False)

Returns:

The newly created OR constraint

Return type:

Constraint

addConsSOS1(vars, weights=None, name='', initial=True, separate=True, enforce=True, check=True, propagate=True, local=False, dynamic=False, removable=False, stickingatnode=False)#

Add an SOS1 constraint.

Parameters:
  • vars (list of Variable) – list of variables to be included

  • weights (list of float or None, optional) – list of weights (Default value = None)

  • name (str, optional) – name of the constraint (Default value = “”)

  • initial (bool, optional) – should the LP relaxation of constraint be in the initial LP? (Default value = True)

  • separate (bool, optional) – should the constraint be separated during LP processing? (Default value = True)

  • enforce (bool, optional) – should the constraint be enforced during node processing? (Default value = True)

  • check (bool, optional) – should the constraint be checked for feasibility? (Default value = True)

  • propagate (bool, optional) – should the constraint be propagated during node processing? (Default value = True)

  • local (bool, optional) – is the constraint only valid locally? (Default value = False)

  • dynamic (bool, optional) – is the constraint subject to aging? (Default value = False)

  • removable (bool, optional) – should the relaxation be removed from the LP due to aging or cleanup? (Default value = False)

  • stickingatnode (bool, optional) – should the constraint always be kept at the node where it was added, even if it may be moved to a more global node? (Default value = False)

Returns:

The newly created SOS1 constraint

Return type:

Constraint

addConsSOS2(vars, weights=None, name='', initial=True, separate=True, enforce=True, check=True, propagate=True, local=False, dynamic=False, removable=False, stickingatnode=False)#

Add an SOS2 constraint.

Parameters:
  • vars (list of Variable) – list of variables to be included

  • weights (list of float or None, optional) – list of weights (Default value = None)

  • name (str, optional) – name of the constraint (Default value = “”)

  • initial (bool, optional) – should the LP relaxation of constraint be in the initial LP? (Default value = True)

  • separate (bool, optional) – should the constraint be separated during LP processing? (Default value = True)

  • enforce (bool, optional) – should the constraint be enforced during node processing? (Default value = True)

  • check (bool, optional) – should the constraint be checked for feasibility? (Default value = True)

  • propagate (bool, optional) – should the constraint be propagated during node processing? (Default value = True)

  • local (bool, optional) – is the constraint only valid locally? (Default value = False)

  • dynamic (bool, optional) – is the constraint subject to aging? (Default value = False)

  • removable (bool, optional) – should the relaxation be removed from the LP due to aging or cleanup? (Default value = False)

  • stickingatnode (bool, optional) – should the constraint always be kept at the node where it was added, even if it may be moved to a more global node? (Default value = False)

Returns:

The newly created SOS2 constraint

Return type:

Constraint

addConsXor(vars, rhsvar, name='', initial=True, separate=True, enforce=True, check=True, propagate=True, local=False, modifiable=False, dynamic=False, removable=False, stickingatnode=False)#

Add a XOR-constraint.

Parameters:
  • vars (list of Variable) – list of binary variables to be included (operators)

  • rhsvar (bool) – BOOLEAN value, explicit True, False or bool(obj) is needed (right-hand side)

  • name (str, optional) – name of the constraint (Default value = “”)

  • initial (bool, optional) – should the LP relaxation of constraint be in the initial LP? (Default value = True)

  • separate (bool, optional) – should the constraint be separated during LP processing? (Default value = True)

  • enforce (bool, optional) – should the constraint be enforced during node processing? (Default value = True)

  • check (bool, optional) – should the constraint be checked for feasibility? (Default value = True)

  • propagate (bool, optional) – should the constraint be propagated during node processing? (Default value = True)

  • local (bool, optional) – is the constraint only valid locally? (Default value = False)

  • dynamic (bool, optional) – is the constraint subject to aging? (Default value = False)

  • removable (bool, optional) – should the relaxation be removed from the LP due to aging or cleanup? (Default value = False)

  • stickingatnode (bool, optional) – should the constraint always be kept at the node where it was added, even if it may be moved to a more global node? (Default value = False)

Returns:

The newly created XOR constraint

Return type:

Constraint

addConss(conss, name='', initial=True, separate=True, enforce=True, check=True, propagate=True, local=False, modifiable=False, dynamic=False, removable=False, stickingatnode=False)#

Adds multiple constraints.

Each of the constraints is added to the model using Model.addCons().

For all parameters, except conss, this method behaves differently depending on the type of the passed argument: 1. If the value is iterable, it must be of the same length as conss. For each constraint, Model.addCons() will be called with the value at the corresponding index. 2. Else, the (default) value will be applied to all of the constraints.

Parameters:
  • conss (iterable of ExprCons) – An iterable of constraint objects. Any iterable will be converted into a list before further processing.

  • name (str or iterable of str, optional) – the name of the constraint, generic name if empty (Default value = ‘’)

  • initial (bool or iterable of bool, optional) – should the LP relaxation of constraint be in the initial LP? (Default value = True)

  • separate (bool or iterable of bool, optional) – should the constraint be separated during LP processing? (Default value = True)

  • enforce (bool or iterable of bool, optional) – should the constraint be enforced during node processing? (Default value = True)

  • check (bool or iterable of bool, optional) – should the constraint be checked for feasibility? (Default value = True)

  • propagate (bool or iterable of bool, optional) – should the constraint be propagated during node processing? (Default value = True)

  • local (bool or iterable of bool, optional) – is the constraint only valid locally? (Default value = False)

  • modifiable (bool or iterable of bool, optional) – is the constraint modifiable (subject to column generation)? (Default value = False)

  • dynamic (bool or iterable of bool, optional) – is the constraint subject to aging? (Default value = False)

  • removable (bool or iterable of bool, optional) – should the relaxation be removed from the LP due to aging or cleanup? (Default value = False)

  • stickingatnode (bool or iterable of bool, optional) – should the constraints always be kept at the node where it was added, even if it may be moved to a more global node? (Default value = False)

Returns:

The created and added Constraint objects.

Return type:

list of Constraint

addCut(cut, forcecut=False)#

Adds cut to separation storage and returns whether cut has been detected to be infeasible for local bounds.

Parameters:
  • cut (Row) – The cut that will be added

  • forcecut (bool, optional) – Whether the cut should be forced or not, i.e., selected no matter what

Returns:

infeasible – Whether the cut has been detected to be infeasible from local bounds

Return type:

bool

addExprNonlinear(cons, expr, coef)#

Add coef*expr to nonlinear constraint.

Parameters:
  • cons (Constraint)

  • expr (Expr or GenExpr)

  • coef (float)

addMatrixCons(cons: ExprCons | MatrixExprCons, name: str | ndarray = '', initial: bool | ndarray = True, separate: bool | ndarray = True, enforce: bool | ndarray = True, check: bool | ndarray = True, propagate: bool | ndarray = True, local: bool | ndarray = False, modifiable: bool | ndarray = False, dynamic: bool | ndarray = False, removable: bool | ndarray = False, stickingatnode: bool | ndarray = False)#

Add a linear or nonlinear matrix constraint.

Parameters:
  • cons (ExprCons or MatrixExprCons) – The matrix expression constraint or expression constraint, that are not yet an actual constraint

  • name (str or np.ndarray, optional) – the name of the matrix constraint, generic name if empty (Default value = “”)

  • initial (bool or np.ndarray, optional) – should the LP relaxation of constraint be in the initial LP? (Default value = True)

  • separate (bool or np.ndarray, optional) – should the matrix constraint be separated during LP processing? (Default value = True)

  • enforce (bool or np.ndarray, optional) – should the matrix constraint be enforced during node processing? (Default value = True)

  • check (bool or np.ndarray, optional) – should the matrix constraint be checked for feasibility? (Default value = True)

  • propagate (bool or np.ndarray, optional) – should the matrix constraint be propagated during node processing? (Default value = True)

  • local (bool or np.ndarray, optional) – is the matrix constraint only valid locally? (Default value = False)

  • modifiable (bool or np.ndarray, optional) – is the matrix constraint modifiable (subject to column generation)? (Default value = False)

  • dynamic (bool or np.ndarray, optional) – is the matrix constraint subject to aging? (Default value = False)

  • removable (bool or np.ndarray, optional) – should the relaxation be removed from the LP due to aging or cleanup? (Default value = False)

  • stickingatnode (bool or np.ndarray, optional) – should the matrix constraints always be kept at the node where it was added, even if it may be moved to a more global node? (Default value = False)

Returns:

The created and added Constraint or MatrixConstraint.

Return type:

Constraint or MatrixConstraint

addMatrixConsIndicator(cons: ExprCons | MatrixExprCons, binvar: Variable | MatrixVariable = None, activeone: bool | ndarray = True, name: str | ndarray = '', initial: bool | ndarray = True, separate: bool | ndarray = True, enforce: bool | ndarray = True, check: bool | ndarray = True, propagate: bool | ndarray = True, local: bool | ndarray = False, dynamic: bool | ndarray = False, removable: bool | ndarray = False, stickingatnode: bool | ndarray = False) MatrixConstraint#

Add an indicator matrix constraint for the linear inequality cons.

The binvar argument models the redundancy of the linear constraint. A solution for which binvar is 1 must satisfy the constraint.

Parameters:
  • cons (ExprCons or MatrixExprCons) – a linear inequality

  • binvar (Variable or MatrixVariable, optional) – binary indicator variable / matrix variable, or None if it should be created. (Default value = None)

  • activeone (bool or np.ndarray, optional) – the matrix constraint should be active if binvar is 1 (0 if activeone = False).

  • name (str or np.ndarray, optional) – name of the matrix constraint. (Default value = “”)

  • initial (bool or np.ndarray, optional) – should the LP relaxation of matrix constraint be in the initial LP? (Default value = True)

  • separate (bool or np.ndarray, optional) – should the matrix constraint be separated during LP processing? (Default value = True)

  • enforce (bool or np.ndarray, optional) – should the matrix constraint be enforced during node processing? (Default value = True)

  • check (bool or np.ndarray, optional) – should the matrix constraint be checked for feasibility? (Default value = True)

  • propagate (bool or np.ndarray, optional) – should the matrix constraint be propagated during node processing? (Default value = True)

  • local (bool or np.ndarray, optional) – is the matrix constraint only valid locally? (Default value = False)

  • dynamic (bool or np.ndarray, optional) – is the matrix constraint subject to aging? (Default value = False)

  • removable (bool or np.ndarray, optional) – should the relaxation be removed from the LP due to aging or cleanup? (Default value = False)

  • stickingatnode (bool or np.ndarray, optional) – should the matrix constraint always be kept at the node where it was added, even if it may be moved to a more global node? (Default value = False)

Returns:

The newly created Indicator MatrixConstraint object.

Return type:

MatrixConstraint

addMatrixVar(shape: int | Tuple, name: str | ndarray = '', vtype: str | ndarray = 'C', lb: int | float | ndarray | None = 0.0, ub: int | float | ndarray | None = None, obj: int | float | ndarray = 0.0, pricedVar: bool | ndarray = False, pricedVarScore: int | float | ndarray = 1.0) MatrixVariable#

Create a new matrix of variable. Default matrix variables are non-negative and continuous.

Parameters:
  • shape (int or tuple) – the shape of the resultant MatrixVariable

  • name (str or np.ndarray, optional) – name of the matrix variable, generic if empty (Default value = ‘’)

  • vtype (str or np.ndarray, optional) – type of the matrix variable: ‘C’ continuous, ‘I’ integer, ‘B’ binary, and ‘M’ implicit integer (Default value = ‘C’)

  • lb (float or np.ndarray or None, optional) – lower bound of the matrix variable, use None for -infinity (Default value = 0.0)

  • ub (float or np.ndarray or None, optional) – upper bound of the matrix variable, use None for +infinity (Default value = None)

  • obj (float or np.ndarray, optional) – objective value of matrix variable (Default value = 0.0)

  • pricedVar (bool or np.ndarray, optional) – is the matrix variable a pricing candidate? (Default value = False)

  • pricedVarScore (float or np.ndarray, optional) – score of matrix variable in case it is priced, the higher the better (Default value = 1.0)

Return type:

MatrixVariable

addObjoffset(offset, solutions=False)#

Add constant offset to objective.

Parameters:
  • offset (float) – offset to add

  • solutions (bool, optional) – add offset also to existing solutions (Default value = False)

addPoolCut(row)#

If not already existing, adds row to global cut pool.

Parameters:

row (Row)

addPyCons(cons)#

Adds a customly created cons.

Parameters:

cons (Constraint) – constraint to add

addRowDive(row)#

Adds a row to the LP in current dive.

Parameters:

row (Row)

addRowExact(rowexact)#

Adds an exact row to the LP.

Parameters:

rowexact (RowExact) – The exact row to add.

addSol(solution, free=True)#

Try to add a solution to the storage.

Parameters:
  • solution (Solution) – solution to store

  • free (bool, optional) – should solution be freed afterwards? (Default value = True)

Returns:

stored – stores whether given solution was good enough to keep

Return type:

bool

addVar(name='', vtype='C', lb=0.0, ub=None, obj=0.0, pricedVar=False, pricedVarScore=1.0, deletable=False)#

Create a new variable. Default variable is non-negative and continuous.

Parameters:
  • name (str, optional) – name of the variable, generic if empty (Default value = ‘’)

  • vtype (str, optional) – type of the variable: ‘C’ continuous, ‘I’ integer, ‘B’ binary, and ‘M’ implicit integer (Default value = ‘C’)

  • lb (float or None, optional) – lower bound of the variable, use None for -infinity (Default value = 0.0)

  • ub (float or None, optional) – upper bound of the variable, use None for +infinity (Default value = None)

  • obj (float, optional) – objective value of variable (Default value = 0.0)

  • pricedVar (bool, optional) – is the variable a pricing candidate? (Default value = False)

  • pricedVarScore (float, optional) – score of variable in case it is priced, the higher the better (Default value = 1.0)

Return type:

Variable

addVarLocks(var, nlocksdown, nlocksup)#

Adds given values to lock numbers of variable for rounding.

Parameters:
  • var (Variable) – variable to adjust the locks for

  • nlocksdown (int) – new number of down locks

  • nlocksup (int) – new number of up locks

addVarLocksType(var, locktype, nlocksdown, nlocksup)#

adds given values to lock numbers of type locktype of variable for rounding

Parameters:
  • var (Variable) – variable to adjust the locks for

  • locktype (SCIP_LOCKTYPE) – type of variable locks

  • nlocksdown (int) – modification in number of down locks

  • nlocksup (int) – modification in number of up locks

addVarSOS1(cons, var, weight)#

Add variable to SOS1 constraint.

Parameters:
  • cons (Constraint) – SOS1 constraint

  • var (Variable) – new variable

  • weight (weight) – weight of new variable

addVarSOS2(cons, var, weight)#

Add variable to SOS2 constraint.

Parameters:
  • cons (Constraint) – SOS2 constraint

  • var (Variable) – new variable

  • weight (weight) – weight of new variable

addVarToRow(row, var, value)#

Resolves variable to columns and adds them with the coefficient to the row.

Parameters:
  • row (Row) – Row in which the variable will be added

  • var (Variable) – Variable which will be added to the row

  • value (float) – Coefficient on the variable when placed in the row

adjustedVarLb(var, lb)#

Returns the adjusted (i.e. rounded, if the given variable is of integral type) lower bound value; does not change the bounds of the variable.

Parameters:
  • var (Variable) – variable for which the bound is adjusted

  • lb (float) – lower bound value to adjust

Returns:

adjusted lower bound

Return type:

float

adjustedVarUb(var, ub)#

Returns the adjusted (i.e. rounded, if the given variable is of integral type) upper bound value; does not change the bounds of the variable.

Parameters:
  • var (Variable) – variable for which the bound is adjusted

  • ub (float) – upper bound value to adjust

Returns:

adjusted upper bound

Return type:

float

aggregateVars(varx, vary, coefx=1.0, coefy=-1.0, rhs=0.0)#

Aggregate two variables by adding an aggregation constraint.

The aggregation is defined by the linear equation:

coefx * varx + coefy * vary = rhs

After aggregation, varx becomes a redundant variable and vary remains active. The aggregation effectively substitutes varx with: (rhs - coefy * vary) / coefx

This method can only be called during presolving.

Parameters:
  • varx (Variable) – variable to be aggregated (will become redundant)

  • vary (Variable) – variable to aggregate with (will remain active)

  • coefx (float, optional) – coefficient for varx in the aggregation equation (default: 1.0)

  • coefy (float, optional) – coefficient for vary in the aggregation equation (default: -1.0)

  • rhs (float, optional) – right-hand side of the aggregation equation (default: 0.0)

Returns:

  • infeasible (bool) – whether the aggregation is infeasible (e.g., bounds are incompatible)

  • redundant (bool) – whether the aggregation makes varx redundant

  • aggregated (bool) – whether the aggregation was actually performed

Examples

To express x = y (i.e., 1*x + (-1)*y = 0):

infeas, redun, aggr = model.aggregateVars(x, y, 1.0, -1.0, 0.0)

To express x = 5 - y (i.e., 1*x + 1*y = 5):

infeas, redun, aggr = model.aggregateVars(x, y, 1.0, 1.0, 5.0)

allColsInLP()#

Checks if all columns, i.e. every variable with non-empty column is present in the LP. This is not True when performing pricing for instance.

Return type:

bool

allowNegSlackExact()#

Returns whether negative slack is allowed in exact solving mode.

Return type:

bool

appendVarSOS1(cons, var)#

Append variable to SOS1 constraint.

Parameters:
appendVarSOS2(cons, var)#

Append variable to SOS2 constraint.

Parameters:
applyCutsProbing()#

Applies the cuts in the separation storage to the LP and clears the storage afterwards; this method can only be applied during probing; the user should resolve the probing LP afterwards in order to get a new solution. returns:

Returns:

cutoff – whether an empty domain was created

Return type:

bool

attachEventHandlerCallback(callback, events, name='eventhandler', description='')#

Attach an event handler to the model using a callback function.

Parameters:
  • callback (callable) – The callback function to be called when an event occurs. The callback function should have the following signature: callback(model, event)

  • events (list of SCIP_EVENTTYPE) – List of event types to attach the event handler to.

  • name (str, optional) – Name of the event handler. If not provided, a unique default name will be generated.

  • description (str, optional) – Description of the event handler. If not provided, an empty string will be used.

backtrackProbing(probingdepth)#

Undoes all changes to the problem applied in probing up to the given probing depth.

Parameters:

probingdepth (int) – probing depth of the node in the probing path that should be reactivated

branchLPExact()#

Performs exact LP branching.

Return type:

SCIP_RESULT

branchVar(variable)#

Branch on a non-continuous variable.

Parameters:

variable (Variable) – Variable to branch on

Returns:

  • Node – Node created for the down (left) branch

  • Node or None – Node created for the equal child (middle child). Only exists if branch variable is integer

  • Node – Node created for the up (right) branch

branchVarVal(variable, value)#

Branches on variable using a value which separates the domain of the variable.

Parameters:
  • variable (Variable) – Variable to branch on

  • value (float) – value to branch on

Returns:

  • Node – Node created for the down (left) branch

  • Node or None – Node created for the equal child (middle child). Only exists if the branch variable is integer

  • Node – Node created for the up (right) branch

cacheRowExtensions(row)#

Informs row that all subsequent additions of variables to the row should be cached and not directly applied; after all additions were applied, flushRowExtensions() must be called; while the caching of row extensions is activated, information methods of the row give invalid results; caching should be used, if a row is build with addVarToRow() calls variable by variable to increase the performance.

Parameters:

row (Row)

calcChildEstimate(variable, targetvalue)#

Calculates an estimate for the objective of the best feasible solution contained in the subtree after applying the given branching; this estimate can be given to the SCIPcreateChild() call.

Parameters:
  • variable (Variable) – Variable to compute the estimate for

  • targetvalue (float) – new value of the variable in the child node

Returns:

objective estimate of the best solution in the subtree after applying the given branching

Return type:

float

calcNodeselPriority(variable, branchdir, targetvalue)#

Calculates the node selection priority for moving the given variable’s LP value to the given target value; this node selection priority can be given to the SCIPcreateChild() call.

Parameters:
  • variable (Variable) – variable on which the branching is applied

  • branchdir (PY_SCIP_BRANCHDIR) – type of branching that was performed

  • targetvalue (float) – new value of the variable in the child node

Returns:

node selection priority for moving the given variable’s LP value to the given target value

Return type:

int

catchEvent(eventtype, eventhdlr)#

Catches a global (not variable or row dependent) event.

Parameters:
  • eventtype (PY_SCIP_EVENTTYPE)

  • eventhdlr (Eventhdlr)

catchRowEvent(row, eventtype, eventhdlr)#

Catches a row coefficient, constant, or side change event on the given row.

Parameters:
  • row (Row)

  • eventtype (PY_SCIP_EVENTTYPE)

  • eventhdlr (Eventhdlr)

catchVarEvent(var, eventtype, eventhdlr)#

Catches an objective value or domain change event on the given transformed variable.

Parameters:
  • var (Variable)

  • eventtype (PY_SCIP_EVENTTYPE)

  • eventhdlr (Eventhdlr)

checkBendersSubproblemOptimality(solution, probnumber, benders=None)#

Returns whether the subproblem is optimal w.r.t the master problem auxiliary variables.

Parameters:
  • solution (Solution) – the master problem solution that is being checked for optimamlity

  • probnumber (int) – the problem number for which optimality is being checked

  • benders (Benders or None, optional) – the Benders’ decomposition to which the subproblem belongs to

Returns:

optimal – flag to indicate whether the current subproblem is optimal for the master

Return type:

bool

checkQuadraticNonlinear(cons)#

Returns if the given constraint is quadratic.

Parameters:

cons (Constraint)

Return type:

bool

checkSol(solution, printreason=True, completely=False, checkbounds=True, checkintegrality=True, checklprows=True, original=False)#

Check given primal solution for feasibility without adding it to the storage.

Parameters:
  • solution (Solution) – solution to store

  • printreason (bool, optional) – should all reasons of violations be printed? (Default value = True)

  • completely (bool, optional) – should all violation be checked? (Default value = False)

  • checkbounds (bool, optional) – should the bounds of the variables be checked? (Default value = True)

  • checkintegrality (bool, optional) – has integrality to be checked? (Default value = True)

  • checklprows (bool, optional) – have current LP rows (both local and global) to be checked? (Default value = True)

  • original (bool, optional) – must the solution be checked against the original problem (Default value = False)

Returns:

feasible – whether the given solution was feasible or not

Return type:

bool

chgCapacityKnapsack(cons, capacity)#

Change capacity of a knapsack constraint.

Parameters:
  • cons (Constraint) – knapsack constraint to change the capacity from

  • capacity (float or None) – new capacity (set to None for +infinity)

chgCoefLinear(cons, var, value)#

Changes coefficient of variable in linear constraint; deletes the variable if coefficient is zero; adds variable if not yet contained in the constraint This method may only be called during problem creation stage for an original constraint and variable. This method requires linear time to search for occurences of the variable in the constraint data.

Parameters:
  • cons (Constraint) – linear constraint

  • var (Variable) – variable of constraint entry

  • value (float) – new coefficient of constraint entry

chgLhs(cons, lhs)#

Change left-hand side value of a constraint.

Parameters:
  • cons (Constraint) – constraint to change the left-hand side from

  • lhs (float or None) – new left-hand side (set to None for -infinity)

chgReoptObjective(coeffs, sense='minimize')#

Change the objective function for reoptimization.

Parameters:
  • coeffs (Expr) – the coefficients as a linear expression

  • sense (str) – the objective sense (Default value = ‘minimize’)

chgRhs(cons, rhs)#

Change right-hand side value of a constraint.

Parameters:
  • cons (Constraint) – constraint to change the right-hand side from

  • rhs (float or None) – new right-hand side (set to None for +infinity)

chgRowLhsDive(row, newlhs)#

Changes row lhs in current dive, change will be undone after diving ends, for permanent changes use SCIPchgRowLhs().

Parameters:
  • row (Row)

  • newlhs (float)

chgRowRhsDive(row, newrhs)#

Changes row rhs in current dive, change will be undone after diving ends. For permanent changes use SCIPchgRowRhs().

Parameters:
  • row (Row)

  • newrhs (float)

chgVarBranchPriority(var, priority)#

Sets the branch priority of the variable. Variables with higher branch priority are always preferred to variables with lower priority in selection of branching variable.

Parameters:
  • var (Variable) – variable to change priority of

  • priority (int) – the new priority of the variable (the default branching priority is 0)

chgVarLb(var, lb)#

Changes the lower bound of the specified variable.

Parameters:
  • var (Variable) – variable to change bound of

  • lb (float or None) – new lower bound (set to None for -infinity)

chgVarLbDive(var, newbound)#

Changes variable’s current lb in current dive.

Parameters:
chgVarLbGlobal(var, lb)#

Changes the global lower bound of the specified variable.

Parameters:
  • var (Variable) – variable to change bound of

  • lb (float or None) – new lower bound (set to None for -infinity)

chgVarLbNode(node, var, lb)#

Changes the lower bound of the specified variable at the given node.

Parameters:
  • node (Node) – Node at which the variable bound will be changed

  • var (Variable) – variable to change bound of

  • lb (float or None) – new lower bound (set to None for -infinity)

chgVarLbProbing(var, lb)#

Changes the variable lower bound during probing mode.

Parameters:
  • var (Variable) – variable to change bound of

  • lb (float or None) – new lower bound (set to None for -infinity)

chgVarObjDive(var, newobj)#

Changes (column) variable’s objective value in current dive.

Parameters:
chgVarObjProbing(var, newobj)#

Changes (column) variable’s objective value during probing mode.

chgVarType(var, vtype)#

Changes the type of a variable.

Parameters:
  • var (Variable) – variable to change type of

  • vtype (str) – new variable type. ‘C’ or “CONTINUOUS”, ‘I’ or “INTEGER”, ‘B’ or “BINARY”, and ‘M’ “IMPLINT”.

chgVarUb(var, ub)#

Changes the upper bound of the specified variable.

Parameters:
  • var (Variable) – variable to change bound of

  • lb (float or None) – new upper bound (set to None for +infinity)

chgVarUbDive(var, newbound)#

Changes variable’s current ub in current dive.

Parameters:
chgVarUbGlobal(var, ub)#

Changes the global upper bound of the specified variable.

Parameters:
  • var (Variable) – variable to change bound of

  • lb (float or None) – new upper bound (set to None for +infinity)

chgVarUbNode(node, var, ub)#

Changes the upper bound of the specified variable at the given node.

Parameters:
  • node (Node) – Node at which the variable bound will be changed

  • var (Variable) – variable to change bound of

  • lb (float or None) – new upper bound (set to None for +infinity)

chgVarUbProbing(var, ub)#

Changes the variable upper bound during probing mode.

Parameters:
  • var (Variable) – variable to change bound of

  • ub (float or None) – new upper bound (set to None for +infinity)

computeBestSolSubproblems()#

Solves the subproblems with the best solution to the master problem. Afterwards, the best solution from each subproblem can be queried to get the solution to the original problem. If the user wants to resolve the subproblems, they must free them by calling freeBendersSubproblems()

constructLP()#

Makes sure that the LP of the current node is loaded and may be accessed through the LP information methods.

Returns:

cutoff – Can the node be cutoff?

Return type:

bool

copyLargeNeighborhoodSearch(to_fix, fix_vals) Model#

Creates a configured copy of the transformed problem and applies provided fixings intended for LNS heuristics.

Parameters:
  • to_fix (List[Variable]) – A list of variables to fix in the copy

  • fix_vals (List[Real]) – A list of the values to which to fix the variables in the copy (care their order)

Returns:

model – A model containing the created copy

Return type:

Model

count()#

Counts the number of feasible points of problem.

createChild(nodeselprio, estimate)#

Create a child node of the focus node.

Parameters:
  • nodeselprio (int) – node selection priority of new node

  • estimate (float) – estimate for (transformed) objective value of best feasible solution in subtree

Returns:

the child which was created

Return type:

Node

createCons(conshdlr, name, initial=True, separate=True, enforce=True, check=True, propagate=True, local=False, modifiable=False, dynamic=False, removable=False, stickingatnode=False)#

Create a constraint of a custom constraint handler.

Parameters:
  • conshdlr (Conshdlr) – constraint handler

  • name (str) – name of constraint handler

  • initial (bool, optional) – (Default value = True)

  • separate (bool, optional) – (Default value = True)

  • enforce (bool, optional) – (Default value = True)

  • check (bool, optional) – (Default value = True)

  • propagate (bool, optional) – (Default value = True)

  • local (bool, optional) – (Default value = False)

  • modifiable (bool, optional) – (Default value = False)

  • dynamic (bool, optional) – (Default value = False)

  • removable (bool, optional) – (Default value = False)

  • stickingatnode (bool, optional) – (Default value = False)

Return type:

Constraint

createConsFromExpr(cons, name='', initial=True, separate=True, enforce=True, check=True, propagate=True, local=False, modifiable=False, dynamic=False, removable=False, stickingatnode=False)#

Create a linear or nonlinear constraint without adding it to the SCIP problem. This is useful for creating disjunction constraints without also enforcing the individual constituents. Currently, this can only be used as an argument to .addConsElemDisjunction. To add an individual linear/nonlinear constraint, prefer .addCons().

Parameters:
  • cons (ExprCons) – The expression constraint that is not yet an actual constraint

  • name (str, optional) – the name of the constraint, generic name if empty (Default value = ‘’)

  • initial (bool, optional) – should the LP relaxation of constraint be in the initial LP? (Default value = True)

  • separate (bool, optional) – should the constraint be separated during LP processing? (Default value = True)

  • enforce (bool, optional) – should the constraint be enforced during node processing? (Default value = True)

  • check (bool, optional) – should the constraint be checked for feasibility? (Default value = True)

  • propagate (bool, optional) – should the constraint be propagated during node processing? (Default value = True)

  • local (bool, optional) – is the constraint only valid locally? (Default value = False)

  • modifiable (bool, optional) – is the constraint modifiable (subject to column generation)? (Default value = False)

  • dynamic (bool, optional) – is the constraint subject to aging? (Default value = False)

  • removable (bool, optional) – should the relaxation be removed from the LP due to aging or cleanup? (Default value = False)

  • stickingatnode (bool, optional) – should the constraint always be kept at the node where it was added, even if it may be moved to a more global node? (Default value = False)

Returns:

The created Constraint object.

Return type:

Constraint

createEmptyRowSepa(sepa, name='row', lhs=0.0, rhs=None, local=True, modifiable=False, removable=True)#

Creates and captures an LP row without any coefficients from a separator.

Parameters:
  • sepa (Sepa) – separator that creates the row

  • name (str, optional) – name of row (Default value = “row”)

  • lhs (float or None, optional) – left hand side of row (Default value = 0)

  • rhs (float or None, optional) – right hand side of row (Default value = None)

  • local (bool, optional) – is row only valid locally? (Default value = True)

  • modifiable (bool, optional) – is row modifiable during node processing (subject to column generation)? (Default value = False)

  • removable (bool, optional) – should the row be removed from the LP due to aging or cleanup? (Default value = True)

Return type:

Row

createEmptyRowUnspec(name='row', lhs=0.0, rhs=None, local=True, modifiable=False, removable=True)#

Creates and captures an LP row without any coefficients from an unspecified source.

Parameters:
  • name (str, optional) – name of row (Default value = “row”)

  • lhs (float or None, optional) – left hand side of row (Default value = 0)

  • rhs (float or None, optional) – right hand side of row (Default value = None)

  • local (bool, optional) – is row only valid locally? (Default value = True)

  • modifiable (bool, optional) – is row modifiable during node processing (subject to column generation)? (Default value = False)

  • removable (bool, optional) – should the row be removed from the LP due to aging or cleanup? (Default value = True)

Return type:

Row

createOrigSol(heur=None)#

Create a new primal solution in the original space.

Parameters:

heur (Heur or None, optional) – heuristic that found the solution (Default value = None)

Return type:

Solution

createPartialSol(heur=None)#

Create a partial primal solution, initialized to unknown values.

Parameters:

heur (Heur or None, optional) – heuristic that found the solution (Default value = None)

Return type:

Solution

createProbBasic(problemName='model')#

Create new problem instance with given name.

Parameters:

problemName (str, optional) – name of model or problem (Default value = ‘model’)

createSol(heur=None, initlp=False)#

Create a new primal solution in the transformed space.

Parameters:
  • heur (Heur or None, optional) – heuristic that found the solution (Default value = None)

  • initlp (bool, optional) – Should the created solution be initialised to the current LP solution instead of all zeros

Return type:

Solution

cutoffNode(node)#

marks node and whole subtree to be cut off from the branch and bound tree.

Parameters:

node (Node)

deactivatePricer(pricer)#

Deactivate the given pricer.

Parameters:

pricer (Pricer) – the pricer to deactivate

delCoefLinear(cons, var)#

Deletes variable from linear constraint This method may only be called during problem creation stage for an original constraint and variable. This method requires linear time to search for occurrences of the variable in the constraint data.

Parameters:
delCons(cons)#

Delete constraint from the model

Parameters:

cons (Constraint) – constraint to be deleted

delConsLocal(cons)#

Delete constraint from the current node and its children.

Parameters:

cons (Constraint) – constraint to be deleted

delVar(var)#

Delete a variable.

Parameters:

var (Variable) – the variable which shall be deleted

Returns:

deleted – Whether deleting was successfull

Return type:

bool

disableDebugSol()#

Disables the debug solution mechanism.

disablePropagation(onlyroot=False)#

Disables propagation in SCIP to avoid modifying the original problem during transformation.

Parameters:

onlyroot (bool, optional) – use propagation when root processing is finished (Default value = False)

dropEvent(eventtype, eventhdlr)#

Drops a global event (stops tracking the event).

Parameters:
  • eventtype (PY_SCIP_EVENTTYPE)

  • eventhdlr (Eventhdlr)

dropRowEvent(row, eventtype, eventhdlr)#

Drops a row coefficient, constant, or side change event (stops tracking the event) on the given row.

Parameters:
  • row (Row)

  • eventtype (PY_SCIP_EVENTTYPE)

  • eventhdlr (Eventhdlr)

dropVarEvent(var, eventtype, eventhdlr)#

Drops an objective value or domain change event (stops tracking the event) on the given transformed variable.

Parameters:
  • var (Variable)

  • eventtype (PY_SCIP_EVENTTYPE)

  • eventhdlr (Eventhdlr)

enableDebugSol()#

Enables the debug solution mechanism, which allows tracing back the invalidation of a debug solution during the solution process of SCIP. It must be explicitly enabled for the SCIP data structure.

enableExactSolving(enable)#

Enables or disables exact solving mode in SCIP.

Parameters:

enable (SCIP_Bool) – Whether to enable exact solving mode (True) or disable it (False).

enableReoptimization(enable=True)#

Include specific heuristics and branching rules for reoptimization.

Parameters:

enable (bool, optional) – True to enable and False to disable

endDive()#

Quits probing and resets bounds and constraints to the focus node’s environment.

endProbing()#

Quits probing and resets bounds and constraints to the focus node’s environment.

endStrongbranch()#

End strong branching. Needs to be called if startStrongBranching was called previously. Between these calls the user can access all strong branching functionality.

epsilon()#

Retrieve epsilon for e.g. equality checks.

Return type:

float

feasCeil(value)#

Rounds value - feasibility tolerance up to the next integer.

Parameters:

value (float)

Return type:

float

feasFloor(value)#

Rounds value + feasibility tolerance down to the next integer.

Parameters:

value (float)

Return type:

float

feasFrac(value)#

Returns fractional part of value, i.e. x - floor(x) in feasible tolerance: x - floor(x+feastol).

Parameters:

value (float)

Return type:

float

feasRound(value)#

Rounds value to the nearest integer in feasibility tolerance.

Parameters:

value (float)

Return type:

float

feastol()#

Retrieve feasibility tolerance.

Return type:

float

fixVar(var, val)#

Fixes the variable var to the value val if possible.

Parameters:
  • var (Variable) – variable to fix

  • val (float) – the fix value

Returns:

  • infeasible (bool) – Is the fixing infeasible?

  • fixed (bool) – Was the fixing performed?

fixVarProbing(var, fixedval)#

Fixes a variable at the current probing node.

Parameters:
flushRowExtensions(row)#

Flushes all cached row extensions after a call of cacheRowExtensions() and merges coefficients with equal columns into a single coefficient

Parameters:

row (Row)

frac(value)#

Returns fractional part of value, i.e. x - floor(x) in epsilon tolerance: x - floor(x+eps).

Parameters:

value (float)

Return type:

float

free()#

Explicitly free the SCIP instance and release plugin references.

Every included plugin holds a strong reference to its Model via self.model, and the Model holds strong references to every plugin via Model._plugins. This cycle is intentional: it keeps both sides alive during SCIP teardown so callbacks such as eventexit and consfree can safely reach self.model.

The cycle is broken in one of two ways:

  • Implicitly, via Model.__del__ when the last external reference to the Model is dropped. __del__ runs before the garbage collector (GC) clears attributes, so callbacks still see a live self.model. Timing is at the GC’s discretion.

  • Explicitly, by calling this method. SCIP is freed immediately, teardown callbacks fire before free returns, and the plugin list is cleared. Use this when deterministic cleanup is required. After free the Model must not be used further.

The solve itself is not affected by which path runs. free only controls when memory and resources are released, and when teardown callbacks execute.

freeBendersSubproblems()#

Deprecated: This method is no longer needed.

Benders subproblems are now automatically managed and freed by the master Model when it is deallocated. Calling this method explicitly has no effect.

Deprecated since version 5.7.0: This method is deprecated and will be removed in a future version. Subproblem memory management is now handled automatically.

freeProb()#

Frees problem and solution process data.

freeReoptSolve()#

Frees all solution process data and prepares for reoptimization.

freeSol(solution)#

Free given solution

Parameters:

solution (Solution) – solution to be freed

freeTransform()#

Frees all solution process data including presolving and transformed problem, only original problem is kept.

static from_ptr(capsule, take_ownership)#

Create a Model from a given pointer.

Parameters:
  • capsule – The PyCapsule containing the SCIP pointer under the name “scip”

  • take_ownership (bool) – Whether the newly created Model assumes ownership of the underlying Scip pointer (see _freescip)

Return type:

Model

generateIIS()#

Generates an Irreducible Infeasible Subsystem (IIS) from the current problem.

Return type:

IIS

getActivity(cons, sol=None)#

Retrieve activity of given constraint. Can only be called after solving is completed.

Parameters:
  • cons (Constraint) – linear constraint

  • sol (Solution or None, optional) – solution to compute activity of, None to use current node’s solution (Default value = None)

Return type:

float

getBendersAuxiliaryVar(probnumber, benders=None)#

Returns the auxiliary variable that is associated with the input problem number

Parameters:
  • probnumber (int) – the problem number for which the target variable belongs, -1 for master problem

  • benders (Benders or None, optional) – the Benders’ decomposition to which the subproblem variables belong to

Return type:

Variable

getBendersSubproblem(probnumber, benders=None)#

Returns a Model object that wraps around the SCIP instance of the subproblem. NOTE: This Model object is just a place holder and SCIP instance will not be freed when the object is destroyed.

Parameters:
  • probnumber (int) – the problem number for subproblem that is required

  • benders (Benders or None, optional) – the Benders’ decomposition object that the subproblem belongs to (Default = None)

Return type:

Model

getBendersVar(var, benders=None, probnumber=-1)#

Returns the variable for the subproblem or master problem depending on the input probnumber.

Parameters:
  • var (Variable) – the source variable for which the target variable is requested

  • benders (Benders or None, optional) – the Benders’ decomposition to which the subproblem variables belong to

  • probnumber (int, optional) – the problem number for which the target variable belongs, -1 for master problem

Return type:

Variable or None

getBestChild()#

Gets the best child of the focus node w.r.t. the node selection strategy.

Return type:

Node

getBestLeaf()#

Gets the best leaf from the node queue w.r.t. the node selection strategy.

Return type:

Node

getBestNode()#

Gets the best node from the tree (child, sibling, or leaf) w.r.t. the node selection strategy.

Return type:

Node

getBestSibling()#

Gets the best sibling of the focus node w.r.t. the node selection strategy.

Return type:

Node

getBestSol()#

Retrieve currently best known feasible primal solution.

Return type:

Solution or None

getBestboundNode()#

Gets the node with smallest lower bound from the tree (child, sibling, or leaf).

Return type:

Node

getBipartiteGraphRepresentation(prev_col_features=None, prev_edge_features=None, prev_row_features=None, static_only=False, suppress_warnings=False)#

This function generates the bipartite graph representation of an LP, which was first used in the following paper: @inproceedings{conf/nips/GasseCFCL19, title={Exact Combinatorial Optimization with Graph Convolutional Neural Networks}, author={Gasse, Maxime and Chételat, Didier and Ferroni, Nicola and Charlin, Laurent and Lodi, Andrea}, booktitle={Advances in Neural Information Processing Systems 32}, year={2019} } The exact features have been modified compared to the original implementation. This function is used mainly in the machine learning community for MIP. A user can only call it during the solving process, when there is an LP object. This means calling it from some user defined plugin on the Python side. An example plugin is a branching rule or an event handler, which is exclusively created to call this function. The user must then make certain to return the appropriate SCIP_RESULT (e.g. DIDNOTRUN)

Parameters:
  • prev_col_features (list of list or None, optional) – The list of column features previously returned by this function

  • prev_edge_features (list of list or None, optional) – The list of edge features previously returned by this function

  • prev_row_features (list of list or None, optional) – The list of row features previously returned by this function

  • static_only (bool, optional) – Whether exclusively static features should be generated

  • suppress_warnings (bool, optional) – Whether warnings should be suppressed

Returns:

  • col_features (list of list)

  • edge_features (list of list)

  • row_features (list of list)

  • dict – The feature mappings for the columns, edges, and rows

getBranchScoreMultiple(var, gains)#

Calculates the branching score out of the gain predictions for a branching with arbitrarily many children.

Parameters:
  • var (Variable) – variable to calculate the score for

  • gains (list of float) – list of gains for each child.

Return type:

float

getCapacityKnapsack(cons)#

Retrieve capacity of a knapsack constraint.

Parameters:

cons (Constraint) – knapsack constraint to get the capacity from

Return type:

float

getChildren()#

Gets the children of the focus node.

Return type:

list of Nodes

getColRedCost(col)#

Gets the reduced cost of the column in the current LP.

Parameters:

col (Column)

Return type:

float

getCondition(exact=False)#

Get the current LP’s condition number.

Parameters:

exact (bool, optional) – whether to get an estimate or the exact value (Default value = False)

Return type:

float

getConsNVars(constraint)#

Gets number of variables in a constraint.

Parameters:

constraint (Constraint) – Constraint to get the number of variables from.

Return type:

int

Raises:

TypeError – If the associated constraint handler does not have this functionality

getConsVals(constraint)#

Returns the value array of an arbitrary SCIP constraint that can be represented as a single linear constraint.

Parameters:

constraint (Constraint) – Constraint to get the values from.

Return type:

list of float

getConsVars(constraint)#

Gets variables in a constraint.

Parameters:

constraint (Constraint) – Constraint to get the variables from.

Return type:

list of Variable

getConss(transformed=True)#

Retrieve all constraints.

Parameters:

transformed (bool, optional) – get transformed variables instead of original (Default value = True)

Return type:

list of Constraint

getCurrentNode()#

Retrieve current node.

Return type:

Node

getCutEfficacy(cut, sol=None)#

Returns efficacy of the cut with respect to the given primal solution or the current LP solution: e = -feasibility/norm

Parameters:
  • cut (Row)

  • sol (Solution or None, optional)

Return type:

float

getCutLPSolCutoffDistance(cut, sol)#

Returns row’s cutoff distance in the direction of the given primal solution.

Parameters:
  • cut (Row)

  • sol (Solution)

Return type:

float

getCutoffbound()#

Gets the cutoff bound of the transformed problem.

Return type:

float

getDepth()#

Retrieve the depth of the current node.

Return type:

int

getDualMultiplier(cons)#

DEPRECATED: Retrieve the dual solution to a linear constraint.

Parameters:

cons (Constraint) – linear constraint

Return type:

float

getDualSolVal(cons, boundconstraint=False)#

Returns dual solution value of a constraint.

Parameters:
  • cons (Constraint) – constraint to get the dual solution value of

  • boundconstraint (bool, optional) – Decides whether to store a bool if the constraint is a bound constraint (default = False)

Return type:

float

getDualbound()#

Retrieve the best dual bound.

Return type:

float

getDualboundRoot()#

Retrieve the best root dual bound.

Return type:

float

getDualfarkasKnapsack(cons)#

Retrieve the dual farkas value to a knapsack constraint.

Parameters:

cons (Constraint) – knapsack constraint

Return type:

float

getDualfarkasLinear(cons)#

Retrieve the dual farkas value to a linear constraint.

Parameters:

cons (Constraint) – linear constraint

Return type:

float

getDualsolKnapsack(cons)#

Retrieve the dual solution to a knapsack constraint.

Parameters:

cons (Constraint) – knapsack constraint

Return type:

float

getDualsolLinear(cons)#

Retrieve the dual solution to a linear constraint.

Parameters:

cons (Constraint) – linear constraint

Return type:

float

getGap()#

Retrieve the gap, i.e. abs((primalbound - dualbound)/min(abs(primalbound),abs(dualbound)))

Return type:

float

getHeurTiming(heurname)#

Get the timing of a heuristic

Parameters:

heurname (string, name of the heuristic)

Returns:

positions in the node solving loop where heuristic should be executed

Return type:

PY_SCIP_HEURTIMING

getIIS()#

Get the IIS object. Note: Needs to be called after generateIIS, or after a single execution of the iisfinderExec.

Return type:

IIS

getLPBInvARow(row)#

Gets a row from B^-1 * A.

Parameters:

row (int) – The row index of the inverse basis matrix multiplied by the coefficient matrix

Return type:

list of float

getLPBInvRow(row)#

Gets a row from the inverse basis matrix B^-1

Parameters:

row (int) – The row index of the inverse basis matrix

Return type:

list of float

getLPBasisInd()#

Gets all indices of basic columns and rows: index i >= 0 corresponds to column i, index i < 0 to row -i-1

Return type:

list of int

getLPBranchCands()#

Gets branching candidates for LP solution branching (fractional variables) along with solution values, fractionalities, and number of branching candidates; The number of branching candidates does NOT account for fractional implicit integer variables which should not be used for branching decisions. Fractional implicit integer variables are stored at the positions nlpcands to nlpcands + nfracimplvars - 1 branching rules should always select the branching candidate among the first npriolpcands of the candidate list

Returns:

  • list of Variable – list of variables of LP branching candidates

  • list of float – list of LP candidate solution values

  • list of float – list of LP candidate fractionalities

  • int – number of LP branching candidates

  • int – number of candidates with maximal priority

  • int – number of fractional implicit integer variables

getLPColsData()#

Retrieve current LP columns.

Return type:

list of Column

getLPObjVal()#

Gets objective value of current LP (which is the sum of column and loose objective value).

Return type:

float

getLPRowsData()#

Retrieve current LP rows.

Return type:

list of Row

getLPSolstat()#

Gets solution status of current LP.

Return type:

SCIP_LPSOLSTAT

getLeaves()#

Gets the leaves of the tree along with number of leaves.

Return type:

list of Nodes

getLhs(cons)#

Retrieve left-hand side value of a constraint.

Parameters:

cons (Constraint) – linear or nonlinear constraint

Return type:

float

getLinearConsIndicator(cons)#

Get the linear constraint corresponding to the indicator constraint.

Parameters:

cons (Constraint) – The indicator constraint

Return type:

Constraint or None

getLocalEstimate(original=False)#

Gets estimate of best primal solution w.r.t. original or transformed problem contained in current subtree.

Parameters:

original (bool, optional) – get estimate of original or transformed problem (Default value = False)

Return type:

float

getLowerbound()#

Gets global lower (dual) bound of the transformed problem.

Return type:

float

getMajorVersion()#

Retrieve SCIP major version.

Return type:

int

getMaxDepth()#

Gets maximal depth of the branch-and-bound tree processed during solving (excluding probing nodes).

Return type:

int

getMemExternEstim()#

Gets the estimated number of bytes used by external software, e.g., the LP solver.

Return type:

int

getMemTotal()#

Gets the total number of bytes in block and buffer memory (i.e., total allocated, including unused).

Return type:

int

getMemUsed()#

Gets the total number of bytes used in block and buffer memory.

Return type:

int

getMinorVersion()#

Retrieve SCIP minor version.

Return type:

int

getNBestSolsFound()#

Gets number of feasible primal solutions found so far, that improved the primal bound at the time they were found.

Return type:

int

getNBinVars()#

Gets number of binary active problem variables.

Return type:

int

getNChildren()#

Gets number of children of focus node.

Return type:

int

getNConss(transformed=True)#

Retrieve number of all constraints.

Parameters:

transformed (bool, optional) – get number of transformed variables instead of original (Default value = True)

Return type:

int

getNContVars()#

Gets number of continuous active problem variables.

Return type:

int

getNCountedSols()#

Get number of feasible solution.

Return type:

int

getNCuts()#

Retrieve total number of cuts in storage.

Return type:

int

getNCutsApplied()#

Retrieve number of currently applied cuts.

Return type:

int

getNFeasibleLeaves()#

Retrieve number of leaf nodes processed with feasible relaxation solution.

Return type:

int

getNImplVars()#

Gets number of implicit integer active problem variables.

Return type:

int

getNInfeasibleLeaves()#

Gets number of infeasible leaf nodes processed.

Return type:

int

getNIntVars()#

Gets number of integer active problem variables.

Return type:

int

getNLPBranchCands()#

Gets number of branching candidates for LP solution branching (number of fractional variables)

Returns:

number of LP branching candidates

Return type:

int

getNLPCols()#

Retrieve the number of columns currently in the LP.

Return type:

int

getNLPIterations()#

Returns the total number of LP iterations so far.

Return type:

int

getNLPRows()#

Retrieve the number of rows currently in the LP.

Return type:

int

getNLPs()#

Gets total number of LPs solved so far.

Return type:

int

getNLeaves()#

Gets number of leaves in the tree.

Return type:

int

getNLimSolsFound()#

Gets number of feasible primal solutions respecting the objective limit found so far.

Return type:

int

getNNlRows()#

Gets current number of nonlinear rows in SCIP’s internal NLP.

Return type:

int

getNNodeLPIterations()#

Gets number of LP iterations used for solving node relaxations so far.

Return type:

int

getNNodes()#

Gets number of processed nodes in current run, including the focus node.

Return type:

int

getNReaders()#

Get number of currently available readers.

Return type:

int

getNSepaRounds()#

Retrieve the number of separation rounds that have been performed at the current node.

Return type:

int

getNSiblings()#

Gets number of siblings of focus node.

Return type:

int

getNSols()#

Gets number of feasible primal solutions stored in the solution storage in case the problem is transformed; in case the problem stage is SCIP_STAGE_PROBLEM, the number of solution in the original solution candidate storage is returned.

Return type:

int

getNSolsFound()#

Gets number of feasible primal solutions found so far.

Return type:

int

getNStrongbranchLPIterations()#

Gets number of LP iterations used for strong branching so far.

Return type:

int

getNTotalNodes()#

Gets number of processed nodes in all runs, including the focus node.

Return type:

int

getNVars(transformed=True)#

Retrieve number of variables in the problems.

Parameters:

transformed (bool, optional) – Get transformed variables instead of original (Default value = True)

Return type:

int

getNVarsAnd(and_cons)#

Gets number of variables in and constraint.

Parameters:

and_cons (Constraint) – AND constraint to get the number of variables from.

Return type:

int

getNlRowActivityBounds(nlrow)#

Gives the minimal and maximal activity of a nonlinear row w.r.t. the variable’s bounds.

Parameters:

nlrow (NLRow)

Return type:

tuple of float

getNlRowSolActivity(nlrow, sol=None)#

Gives the activity of a nonlinear row for a given primal solution.

Parameters:
  • nlrow (NLRow)

  • sol (Solution or None, optional) – a primal solution, if None, then the current LP solution is used

Return type:

float

getNlRowSolFeasibility(nlrow, sol=None)#

Gives the feasibility of a nonlinear row for a given primal solution

Parameters:
  • nlrow (NLRow)

  • sol (Solution or None, optional) – a primal solution, if None, then the current LP solution is used

Return type:

bool

getNlRows()#

Returns a list with the nonlinear rows in SCIP’s internal NLP.

Return type:

list of NLRow

getObjVal(original=True)#

Retrieve the objective value of the best solution.

Parameters:

original (bool, optional) – objective value in original space (Default value = True)

Return type:

float

getObjective()#

Retrieve objective function as Expr.

Return type:

Expr

getObjectiveSense()#

Retrieve objective sense.

Return type:

str

getObjlimit()#

Returns current limit on objective function.

Return type:

float

getObjoffset(original=True)#

Retrieve constant objective offset

Parameters:

original (bool, optional) – offset of original or transformed problem (Default value = True)

Return type:

float

getOpenNodes()#

Access to all data of open nodes (leaves, children, and siblings).

Returns:

  • leaves (list of Node) – list of all open leaf nodes

  • children (list of Node) – list of all open children nodes

  • siblings (list of Node) – list of all open sibling nodes

getParam(name)#

Get the value of a parameter of type int, bool, real, long, char or str.

Parameters:

name (str) – name of parameter

Return type:

object

getParams()#

Gets the values of all parameters as a dict mapping parameter names to their values.

Returns:

dict mapping parameter names to their values.

Return type:

dict of str to object

getPlungeDepth()#

Gets current plunging depth (successive selections of child/sibling nodes).

Return type:

int

getPresolvingTime()#

Returns the current presolving time in seconds.

Return type:

float

getPrimalDualIntegral()#

Recomputes and returns the primal dual gap stored in the stats

Return type:

float

getPrimalRay()#

Gets primal ray causing unboundedness of the LP relaxation.

Return type:

list of float

getPrimalRayVal(var)#

Gets value of given variable in primal ray causing unboundedness of the LP relaxation.

Parameters:

var (Variable)

Return type:

float

getPrimalbound()#

Retrieve the best primal bound.

Return type:

float

getPrioChild()#

Gets the best child of the focus node w.r.t. the node selection priority assigned by the branching rule.

Return type:

Node

getPrioSibling()#

Gets the best sibling of the focus node w.r.t. the node selection priority assigned by the branching rule.

Return type:

Node

getProbName()#

Retrieve problem name.

Return type:

str

getProbingDepth()#

Returns the current probing depth.

getPseudoBranchCands()#

Gets branching candidates for pseudo solution branching (non-fixed variables) along with the number of candidates.

Returns:

  • list of Variable – list of variables of pseudo branching candidates

  • int – number of pseudo branching candidates

  • int – number of candidates with maximal priority

getReadingTime()#

Retrieve the current reading time in seconds.

Return type:

float

getResultantAnd(and_cons)#

Gets the resultant variable in And constraint.

Parameters:

and_cons (Constraint) – Constraint to get the resultant variable from.

Return type:

Variable

getRhs(cons)#

Retrieve right-hand side value of a constraint.

Parameters:

cons (Constraint) – constraint to get the right-hand side from

Return type:

float

getRowActivity(row)#

Returns the activity of a row in the last LP or pseudo solution.

Parameters:

row (Row)

Return type:

float

getRowDualSol(row)#

Gets the dual LP solution of a row.

Parameters:

row (Row)

Return type:

float

getRowLPActivity(row)#

Returns the activity of a row in the last LP solution.

Parameters:

row (Row)

Return type:

float

getRowLinear(cons)#

Retrieve the linear relaxation of the given linear constraint as a row. May return NULL if no LP row was yet created; the user must not modify the row!

Parameters:

cons (Constraint) – linear constraint to get the coefficients of

Return type:

Row

getRowNumIntCols(row)#

Returns number of intergal columns in the row.

Parameters:

row (Row)

Return type:

int

getRowObjParallelism(row)#

Returns 1 if the row is parallel, and 0 if orthogonal.

Parameters:

row (Row)

Return type:

float

getRowParallelism(row1, row2, orthofunc=101)#

Returns the degree of parallelism between hyplerplanes. 1 if perfectly parallel, 0 if orthogonal. For two row vectors v, w the parallelism is calculated as: abs(v*w)/(abs(v)*abs(w)). 101 in this case is an ‘e’ (euclidean) in ASCII. The other acceptable input is 100 (d for discrete).

Parameters:
  • row1 (Row)

  • row2 (Row)

  • orthofunc (int, optional) – 101 (default) is an ‘e’ (euclidean) in ASCII. Alternate value is 100 (d for discrete)

Return type:

float

getSiblings()#

Gets the siblings of the focus node.

Return type:

list of Nodes

getSlack(cons, sol=None, side=None)#

Retrieve slack of given constraint. Can only be called after solving is completed.

Parameters:
  • cons (Constraint) – linear constraint

  • sol (Solution or None, optional) – solution to compute slack of, None to use current node’s solution (Default value = None)

  • side (str or None, optional) – whether to use ‘lhs’ or ‘rhs’ for ranged constraints, None to return minimum (Default value = None)

Return type:

float

getSlackVarIndicator(cons)#

Get slack variable of an indicator constraint.

Parameters:

cons (Constraint) – The indicator constraint

Return type:

Variable

getSolObjVal(sol, original=True)#

Retrieve the objective value of the solution.

Parameters:
  • sol (Solution)

  • original (bool, optional) – objective value in original space (Default value = True)

Return type:

float

getSolTime(sol)#

Get clock time when this solution was found.

Parameters:

sol (Solution)

Return type:

float

getSolVal(sol, expr: Expr | GenExpr | MatrixExpr) float | ndarray#

Retrieve value of given variable or expression in the given solution.

Parameters:
  • sol (Solution) – Solution to query the value from. If None, the current LP/pseudo solution is used.

  • expr (Expr, GenExpr, MatrixExpr) – Expression to query the value of.

Return type:

float or np.ndarray

Notes

A variable is also an expression.

getSols()#

Retrieve list of all feasible primal solutions stored in the solution storage.

Return type:

list of Solution

getSolvingTime()#

Retrieve the current solving time in seconds.

Return type:

float

getStage()#

Retrieve current SCIP stage.

Return type:

int

getStageName()#

Returns name of current stage as string.

Return type:

str

getStatus()#

Retrieve solution status.

Returns:

The status of SCIP.

Return type:

str

getTechVersion()#

Retrieve SCIP technical version.

Return type:

int

getTermsQuadratic(cons)#

Retrieve bilinear, quadratic, and linear terms of a quadratic constraint.

Parameters:

cons (Constraint)

Returns:

  • bilinterms (list of tuple) – Triples (var1, var2, coef) for terms of the form coef * var1 * var2 with var1 != var2.

  • quadterms (list of tuple) – Triples (var, sqrcoef, lincoef) for variables that appear in quadratic or bilinear terms. sqrcoef is the coefficient of var**2, and lincoef is the linear coefficient of var if it also appears linearly.

  • linterms (list of tuple) – Pairs (var, coef) for purely linear variables, i.e., variables that do not participate in any quadratic or bilinear term.

getTotalTime()#

Retrieve the current total SCIP time in seconds, i.e. the total time since the SCIP instance has been created.

Return type:

float

getTransformedCons(cons)#

Retrieve transformed constraint.

Parameters:

cons (Constraint)

Return type:

Constraint

getTransformedVar(var)#

Retrieve the transformed variable.

Parameters:

var (Variable) – original variable to get the transformed of

Return type:

Variable

getTreesizeEstimation()#

Get an estimate of the final tree size.

Return type:

float

getVal(expr: Expr | GenExpr | MatrixExpr) float | ndarray#

Retrieve the value of the given variable or expression in the best known solution. Can only be called after solving is completed.

Parameters:

expr (Expr, GenExpr or MatrixExpr) – Expression to query the value of.

Return type:

float or np.ndarray

Notes

A variable is also an expression.

getValsLinear(cons)#

Retrieve the coefficients of a linear constraint

Parameters:

cons (Constraint) – linear constraint to get the coefficients of

Return type:

dict of str to float

getVarDict(transformed=False)#

Gets dictionary with variables names as keys and current variable values as items.

Parameters:

transformed (bool, optional) – Get transformed variables instead of original (Default value = False)

Return type:

dict of str to float

getVarLbDive(var)#

Returns variable’s current lb in current dive.

Parameters:

var (Variable)

Return type:

float

getVarPseudocost(var, branchdir)#

gets the variable’s pseudo cost value for the given direction

Parameters:
  • variable (Variable) – problem variable

  • branchdir (PY_SCIP_BRANCHDIR) – branching direction (downwards, or upwards)

Return type:

float

getVarPseudocostScore(var, solVal)#

gets the variable’s pseudo cost score value for the given LP solution value

Parameters:
  • variable (Variable) – problem variable

  • solVal (float) – difference of variable’s new LP value - old LP value

Return type:

float

getVarRedcost(var)#

Retrieve the reduced cost of a variable.

Parameters:

var (Variable) – variable to get the reduced cost of

Return type:

float

getVarStrongbranch(var, itlim, idempotent=False, integral=False)#

Strong branches and gets information on column variable.

Parameters:
  • var (Variable) – Variable to get strong branching information on

  • itlim (int) – LP iteration limit for total strong branching calls

  • idempotent (bool, optional) – Should SCIP’s state remain the same after the call?

  • integral (bool, optional) – Boolean on whether the variable is currently integer.

Returns:

  • down (float) – The dual bound of the LP after branching down on the variable

  • up (float) – The dual bound of the LP after branchign up on the variable

  • downvalid (bool) – stores whether the returned down value is a valid dual bound, or NULL

  • upvalid (bool) – stores whether the returned up value is a valid dual bound, or NULL

  • downinf (bool) – store whether the downwards branch is infeasible

  • upinf (bool) – store whether the upwards branch is infeasible

  • downconflict (bool) – store whether a conflict constraint was created for an infeasible downwards branch

  • upconflict (bool) – store whether a conflict constraint was created for an infeasible upwards branch

  • lperror (bool) – whether an unresolved LP error occurred in the solving process

getVarStrongbranchLast(var)#

Get the results of the last strong branching call on this variable (potentially was called at another node).

Parameters:

var (Variable) – variable to get the previous strong branching information from

Returns:

  • down (float) – The dual bound of the LP after branching down on the variable

  • up (float) – The dual bound of the LP after branchign up on the variable

  • downvalid (bool) – stores whether the returned down value is a valid dual bound, or NULL

  • upvalid (bool) – stores whether the returned up value is a valid dual bound, or NULL

  • solval (float) – The solution value of the variable at the last strong branching call

  • lpobjval (float) – The LP objective value at the time of the last strong branching call

getVarStrongbranchNode(var)#

Get the node number from the last time strong branching was called on the variable.

Parameters:

var (Variable) – variable to get the previous strong branching node from

Return type:

int

getVarUbDive(var)#

Returns variable’s current ub in current dive.

Parameters:

var (Variable)

Return type:

float

getVars(transformed=False)#

Retrieve all variables.

Parameters:

transformed (bool, optional) – Get transformed variables instead of original (Default value = False)

Return type:

list of Variable

getVarsAnd(and_cons)#

Gets variables in AND constraint.

Parameters:

and_cons (Constraint) – AND Constraint to get the variables from.

Return type:

list of Variable

getWeightsKnapsack(cons)#

Retrieve the coefficients of a knapsack constraint

Parameters:

cons (Constraint) – knapsack constraint to get the coefficients of

Return type:

dict of str to float

hasPrimalRay()#

Returns whether a primal ray is stored that proves unboundedness of the LP relaxation.

Return type:

bool

hideOutput(quiet=True)#

Hide the output.

Parameters:

quiet (bool, optional) – hide output? (Default value = True)

inProbing()#

Returns whether we are in probing mode; probing mode is activated via startProbing() and stopped via endProbing().

Return type:

bool

inRepropagation()#

Returns if the current node is already solved and only propagated again.

Return type:

bool

includeBenders(benders, name, desc, priority=1, cutlp=True, cutpseudo=True, cutrelax=True, shareaux=False)#

Include a Benders’ decomposition.

Parameters:
  • benders (Benders) – the Benders decomposition

  • name (str) – the name

  • desc (str) – the description

  • priority (int, optional) – priority of the Benders’ decomposition

  • cutlp (bool, optional) – should Benders’ cuts be generated from LP solutions

  • cutpseudo (bool, optional) – should Benders’ cuts be generated from pseudo solutions

  • cutrelax (bool, optional) – should Benders’ cuts be generated from relaxation solutions

  • shareaux (bool, optional) – should the Benders’ decomposition share the auxiliary variables of the highest priority Benders’ decomposition

includeBendersDefaultCuts(benders)#

Includes the default Benders’ decomposition cuts to the custom Benders’ decomposition plugin.

Parameters:

benders (Benders) – the Benders’ decomposition that the default cuts will be applied to

includeBenderscut(benders, benderscut, name, desc, priority=1, islpcut=True)#

Include a Benders’ decomposition cutting method

Parameters:
  • benders (Benders) – the Benders’ decomposition that this cutting method is attached to

  • benderscut (Benderscut) – the Benders’ decomposition cutting method

  • name (str) – the name

  • desc (str) – the description

  • priority (int. optional) – priority of the Benders’ decomposition (Default = 1)

  • islpcut (bool, optional) – is this cutting method suitable for generating cuts for convex relaxations? (Default = True)

includeBranchrule(branchrule, name, desc, priority, maxdepth, maxbounddist)#

Include a branching rule.

Parameters:
  • branchrule (Branchrule) – branching rule

  • name (str) – name of branching rule

  • desc (str) – description of branching rule

  • priority (int) – priority of branching rule

  • maxdepth (int) – maximal depth level up to which this branching rule should be used (or -1)

  • maxbounddist (float) – maximal relative distance from current node’s dual bound to primal bound compared to best node’s dual bound for applying branching rule (0.0: only on current best node, 1.0: on all nodes)

includeConshdlr(conshdlr, name, desc, sepapriority=0, enfopriority=0, chckpriority=0, sepafreq=-1, propfreq=-1, eagerfreq=100, maxprerounds=-1, delaysepa=False, delayprop=False, needscons=True, proptiming=1, presoltiming=8)#

Include a constraint handler.

Parameters:
  • conshdlr (Conshdlr) – constraint handler

  • name (str) – name of constraint handler

  • desc (str) – description of constraint handler

  • sepapriority (int, optional) – priority for separation (Default value = 0)

  • enfopriority (int, optional) – priority for constraint enforcing (Default value = 0)

  • chckpriority (int, optional) – priority for checking feasibility (Default value = 0)

  • sepafreq (int, optional) – frequency for separating cuts; 0 = only at root node (Default value = -1)

  • propfreq (int, optional) – frequency for propagating domains; 0 = only preprocessing propagation (Default value = -1)

  • eagerfreq (int, optional) –

    frequency for using all instead of only the useful constraints in separation,

    propagation and enforcement; -1 = no eager evaluations, 0 = first only (Default value = 100)

  • maxprerounds (int, optional) – maximal number of presolving rounds the constraint handler participates in (Default value = -1)

  • delaysepa (bool, optional) – should separation method be delayed, if other separators found cuts? (Default value = False)

  • delayprop (bool, optional) – should propagation method be delayed, if other propagators found reductions? (Default value = False)

  • needscons (bool, optional) – should the constraint handler be skipped, if no constraints are available? (Default value = True)

  • proptiming (PY_SCIP_PROPTIMING) –

    positions in the node solving loop where propagation method of constraint handlers

    should be executed (Default value = SCIP_PROPTIMING.BEFORELP)

  • presoltiming (PY_SCIP_PRESOLTIMING) – timing mask of the constraint handler’s presolving method (Default value = SCIP_PRESOLTIMING.MEDIUM)

includeCutsel(cutsel, name, desc, priority)#

Include a cut selector.

Parameters:
  • cutsel (Cutsel) – cut selector

  • name (str) – name of cut selector

  • desc (str) – description of cut selector

  • priority (int) – priority of the cut selector

includeDefaultPlugins()#

Includes all default plug-ins into SCIP.

includeEventhdlr(eventhdlr, name, desc)#

Include an event handler.

Parameters:
  • eventhdlr (Eventhdlr) – event handler

  • name (str) – name of event handler

  • desc (str) – description of event handler

includeHeur(heur, name, desc, dispchar, priority=10000, freq=1, freqofs=0, maxdepth=-1, timingmask=1, usessubscip=False)#

Include a primal heuristic.

Parameters:
  • heur (Heur) – heuristic

  • name (str) – name of heuristic

  • desc (str) – description of heuristic

  • dispchar (str) – display character of heuristic. Please use a single length string.

  • priority (int. optional) – priority of the heuristic (Default value = 10000)

  • freq (int, optional) – frequency for calling heuristic (Default value = 1)

  • freqofs (int. optional) – frequency offset for calling heuristic (Default value = 0)

  • maxdepth (int, optional) – maximal depth level to call heuristic at (Default value = -1)

  • timingmask (PY_SCIP_HEURTIMING, optional) – positions in the node solvingreturn { ‘result’: SCIP_RESULT.SUCCESS, ‘lowerbound’: 10e4

  • executed (} loop where heuristic should be) – (Default value = SCIP_HEURTIMING_BEFORENODE)

  • usessubscip (bool, optional) – does the heuristic use a secondary SCIP instance? (Default value = False)

includeIISfinder(iisfinder, name, desc, priority=10000, freq=1)#

Include an IIS (Irreducible Infeasible Set) finder handler.

Parameters:
  • iisfinder (IISfinder) – IIS finder

  • name (str) – name of IIS finder

  • desc (str) – description of IIS finder

  • priority (int, optional) – priority of the IISfinder (#todo description)

  • freq (int, optional) – frequency for calling IIS finder

includeNodesel(nodesel, name, desc, stdpriority, memsavepriority)#

Include a node selector.

Parameters:
  • nodesel (Nodesel) – node selector

  • name (str) – name of node selector

  • desc (str) – description of node selector

  • stdpriority (int) – priority of the node selector in standard mode

  • memsavepriority (int) – priority of the node selector in memory saving mode

includePresol(presol, name, desc, priority, maxrounds, timing=4)#

Include a presolver.

Parameters:
  • presol (Presol) – presolver

  • name (str) – name of presolver

  • desc (str) – description of presolver

  • priority (int) – priority of the presolver (>= 0: before, < 0: after constraint handlers)

  • maxrounds (int) – maximal number of presolving rounds the presolver participates in (-1: no limit)

  • timing (PY_SCIP_PRESOLTIMING, optional) – timing mask of presolver (Default value = SCIP_PRESOLTIMING_FAST)

includePricer(pricer, name, desc, priority=1, delay=True)#

Include a pricer.

Parameters:
  • pricer (Pricer) – pricer

  • name (str) – name of pricer

  • desc (str) – description of pricer

  • priority (int, optional) – priority of pricer (Default value = 1)

  • delay (bool, optional) – should the pricer be delayed until no other pricers or already existing problem variables with negative reduced costs are found? (Default value = True)

includeProp(prop, name, desc, presolpriority, presolmaxrounds, proptiming, presoltiming=4, priority=1, freq=1, delay=True)#

Include a propagator.

Parameters:
  • prop (Prop) – propagator

  • name (str) – name of propagator

  • desc (str) – description of propagator

  • presolpriority (int) – presolving priority of the propgator (>= 0: before, < 0: after constraint handlers)

  • presolmaxrounds (int) – maximal number of presolving rounds the propagator participates in (-1: no limit)

  • proptiming (SCIP_PROPTIMING) – positions in the node solving loop where propagation method of constraint handlers should be executed

  • presoltiming (PY_SCIP_PRESOLTIMING, optional) – timing mask of the constraint handler’s presolving method (Default value = SCIP_PRESOLTIMING_FAST)

  • priority (int, optional) – priority of the propagator (Default value = 1)

  • freq (int, optional) – frequency for calling propagator (Default value = 1)

  • delay (bool, optional) – should propagator be delayed if other propagators have found reductions? (Default value = True)

includeReader(reader, name, desc, ext)#

Include a reader.

Parameters:
  • reader (Reader) – reader

  • name (str) – name of reader

  • desc (str) – description of reader

  • ext (str) – file extension of reader

includeRelax(relax, name, desc, priority=10000, freq=1)#

Include a relaxation handler.

Parameters:
  • relax (Relax) – relaxation handler

  • name (str) – name of relaxation handler

  • desc (str) – description of relaxation handler

  • priority (int, optional) – priority of the relaxation handler (negative: after LP, non-negative: before LP, Default value = 10000)

  • freq (int, optional) – frequency for calling relaxation handler

includeSepa(sepa, name, desc, priority=0, freq=10, maxbounddist=1.0, usessubscip=False, delay=False)#

Include a separator

Parameters:
  • sepa (Sepa) – separator

  • name (str) – name of separator

  • desc (str) – description of separator

  • priority (int, optional) – priority of separator (>= 0: before, < 0: after constraint handlers)

  • freq (int, optional) – frequency for calling separator

  • maxbounddist (float, optional) – maximal relative distance from current node’s dual bound to primal bound compared to best node’s dual bound for applying separation

  • usessubscip (bool, optional) – does the separator use a secondary SCIP instance? (Default value = False)

  • delay (bool, optional) – should separator be delayed, if other separators found cuts? (Default value = False)

  • sepa – separator

  • name – name of separator

  • desc – description of separator

  • priority – priority of separator (>= 0: before, < 0: after constraint handlers) (default=0)

  • freq – frequency for calling separator (default=10)

  • maxbounddist – maximal relative distance from current node’s dual bound to primal bound compared to best node’s dual bound for applying separation. (default = 1.0)

  • usessubscip – does the separator use a secondary SCIP instance? (Default value = False)

  • delay – should separator be delayed if other separators found cuts? (Default value = False)

infinity()#

Retrieve SCIP’s infinity value.

Return type:

int

initBendersDefault(subproblems)#

Initialises the default Benders’ decomposition with a dictionary of subproblems.

Parameters:

subproblems (Model or dict of object to Model) – a single Model instance or dictionary of Model instances

interruptSolve()#

Interrupt the solving process as soon as possible.

isAndConsSorted(and_cons)#

Returns if the variables of the AND-constraint are sorted with respect to their indices.

Parameters:

and_cons (Constraint) – Constraint to check.

Return type:

bool

isCutEfficacious(cut, sol=None)#

Returns whether the cut’s efficacy with respect to the given primal solution or the current LP solution is greater than the minimal cut efficacy.

Parameters:
  • cut (Row)

  • sol (Solution or None, optional)

Return type:

float

isEQ(val1, val2)#

Checks, if values are in range of epsilon.

Parameters:
  • val1 (float)

  • val2 (float)

Return type:

bool

isExact()#

Returns whether exact solving mode is enabled in SCIP.

Return type:

bool

isFeasEQ(val1, val2)#

Returns if relative difference between val1 and val2 is in range of feasibility tolerance.

Parameters:
  • val1 (float)

  • val2 (float)

Return type:

bool

isFeasGE(val1, val2)#

Returns whether relative difference of val1 and val2 is not lower than minus feasibility tolerance.

Parameters:
  • val1 (float)

  • val2 (float)

Return type:

bool

isFeasGT(val1, val2)#

Returns whether relative difference between val1 and val2 is greater than feasibility tolerance.

Parameters:
  • val1 (float)

  • val2 (float)

Return type:

bool

isFeasIntegral(value)#

Returns whether value is integral within the LP feasibility bounds.

Parameters:

value (float)

Return type:

bool

isFeasLE(val1, val2)#

Returns whether relative difference between val1 and val2 is not greater than feasibility tolerance.

Parameters:
  • val1 (float)

  • val2 (float)

Return type:

bool

isFeasLT(val1, val2)#

Returns whether relative difference between val1 and val2 is lower than minus feasibility tolerance.

Parameters:
  • val1 (float)

  • val2 (float)

Return type:

bool

isFeasNegative(value)#

Returns whether value < -feastol.

Parameters:

value (float)

Return type:

bool

isFeasPositive(value)#

Returns whether value > feastol.

Parameters:

value (float)

Return type:

bool

isFeasZero(value)#

Returns whether abs(value) < feastol.

Parameters:

value (float)

Return type:

bool

isGE(val1, val2)#

Returns whether val1 >= val2 - eps.

Parameters:
  • val1 (float)

  • val2 (float)

Return type:

bool

isGT(val1, val2)#

Returns whether val1 > val2 + eps.

Parameters:
  • val1 (float)

  • val2 (foat)

Return type:

bool

isHugeValue(val)#

Checks if value is huge and should be handled separately (e.g., in activity computation).

Parameters:

val (float)

Return type:

bool

isInfinity(value)#

Returns whether value is SCIP’s infinity.

Parameters:

value (float)

Return type:

bool

isIntegral(value)#

Returns whether value is integral within epsilon tolerance.

Parameters:

value (float) – value to check

Return type:

bool

isLE(val1, val2)#

Returns whether val1 <= val2 + eps.

Parameters:
  • val1 (float)

  • val2 (float)

Return type:

bool

isLPSolBasic()#

Returns whether the current LP solution is basic, i.e. is defined by a valid simplex basis.

Return type:

bool

isLT(val1, val2)#

Returns whether val1 < val2 - eps.

Parameters:
  • val1 (float)

  • val2 (float)

Return type:

bool

isNLPConstructed()#

Returns whether SCIP’s internal NLP has been constructed.

Return type:

bool

isNegative(val)#

Returns whether val < -eps.

Parameters:

val (float)

Return type:

bool

isObjChangedProbing()#

Returns whether the objective function has changed during probing mode.

Return type:

bool

isObjIntegral()#

Returns whether the objective function is integral.

Return type:

bool

isPositive(val)#

Returns whether val > eps.

Parameters:

val (float)

Return type:

bool

isReoptEnabled()#

Returns whether reoptimization is enabled.

Return type:

bool

isZero(value)#

Returns whether abs(value) < eps.

Parameters:

value (float)

Return type:

bool

lpiGetIterations()#

Get the iteration count of the last solved LP.

Return type:

int

markDoNotAggrVar(var)#

Marks a variable preventing it from being aggregated.

Parameters:

var (Variable) – variable to mark

markDoNotMultaggrVar(var)#

Marks a variable preventing it from being multi-aggregated.

Parameters:

var (Variable) – variable to mark

newProbingNode()#

Creates a new probing sub node, whose changes can be undone by backtracking to a higher node in the probing path with a call to backtrackProbing().

optimize()#

Optimize the problem.

optimizeNogil()#

Optimize the problem without GIL.

presolve()#

Presolve the problem.

printBestSol(write_zeros=False)#

Prints the best feasible primal solution.

Parameters:

write_zeros (bool, optional) – include variables that are set to zero (Default = False)

printCons(constraint)#

Print the constraint

Parameters:

constraint (Constraint)

printExternalCodeVersions()#

Print external code versions, e.g. symmetry, non-linear solver, lp solver.

printNlRow(nlrow)#

Prints nonlinear row.

Parameters:

nlrow (NLRow)

printProblem(ext='.cip', trans=False, genericnames=False)#

Write current model/problem to standard output.

Parameters:
  • ext (str, optional) – the extension to be used (Default value = ‘.cip’). Should have an extension corresponding to one of the readable file formats, described in https://www.scipopt.org/doc/html/group__FILEREADERS.php.

  • trans (bool, optional) – indicates whether the transformed problem is written to file (Default value = False)

  • genericnames (bool, optional) – indicates whether the problem should be written with generic variable and constraint names (Default value = False)

printRow(row)#

Prints row.

Parameters:

row (Row)

printSol(solution=None, write_zeros=False)#

Print the given primal solution.

Parameters:
  • solution (Solution or None, optional) – solution to print (default = None)

  • write_zeros (bool, optional) – include variables that are set to zero (Default=False)

printStatistics(filename=None)#

Print statistics.

Parameters:

filename (str, optional) – name of the output file (Default = None)

printStatisticsJson()#

Print statistics in JSON format.

printVersion()#

Print version, copyright information and compile mode.

propagateProbing(maxproprounds)#

Applies domain propagation on the probing sub problem, that was changed after SCIPstartProbing() was called; the propagated domains of the variables can be accessed with the usual bound accessing calls SCIPvarGetLbLocal() and SCIPvarGetUbLocal(); the propagation is only valid locally, i.e. the local bounds as well as the changed bounds due to SCIPchgVarLbProbing(), SCIPchgVarUbProbing(), and SCIPfixVarProbing() are used for propagation.

Parameters:

maxproprounds (int) – maximal number of propagation rounds (Default value = -1, that is, no limit)

Returns:

  • cutoff (bool) – whether the probing node can be cutoff

  • ndomredsfound (int) – number of domain reductions found

readParams(file)#

Read an external parameter file.

Parameters:

file (str) – file to read

readProblem(filename, extension=None)#

Read a problem instance from an external file.

Parameters:
  • filename (str) – problem file name

  • extension (str or None) – specify file extension/type (Default value = None)

readSol(filename)#

Reads a given solution file, problem has to be transformed in advance.

Parameters:

filename (str) – name of the input file

readSolFile(filename)#

Reads a given solution file.

Solution is created but not added to storage/the model. Use ‘addSol’ OR ‘trySol’ to add it.

Parameters:

filename (str) – name of the input file

Return type:

Solution

redirectOutput()#

Send output to python instead of terminal.

relax()#

Relaxes the integrality restrictions of the model.

releaseRow(row)#

Decreases usage counter of LP row, and frees memory if necessary.

Parameters:

row (Row)

repropagateNode(node)#

Marks the given node to be propagated again the next time a node of its subtree is processed.

resetParam(name)#

Reset parameter setting to its default value

Parameters:

name (str) – parameter to reset

resetParams()#

Reset parameter settings to their default values.

restartSolve()#

Restarts the solving process as soon as possible.

separateSol(sol=None, pretendroot=False, allowlocal=True, onlydelayed=False)#

Separates the given primal solution or the current LP solution by calling the separators and constraint handlers’ separation methods; the generated cuts are stored in the separation storage and can be accessed with the methods SCIPgetCuts() and SCIPgetNCuts(); after evaluating the cuts, you have to call SCIPclearCuts() in order to remove the cuts from the separation storage; it is possible to call SCIPseparateSol() multiple times with different solutions and evaluate the found cuts afterwards.

Parameters:
  • sol (Solution or None, optional) – solution to separate, None to use current lp solution (Default value = None)

  • pretendroot (bool, optional) – should the cut separators be called as if we are at the root node? (Default value = “False”)

  • allowlocal (bool, optional) – should the separator be asked to separate local cuts (Default value = True)

  • onlydelayed (bool, optional) – should only separators be called that were delayed in the previous round? (Default value = False)

Returns:

  • delayed (bool) – whether a separator was delayed

  • cutoff (bool) – whether the node can be cut off

setBendersSubproblemIsConvex(benders, probnumber, isconvex=True)#

Sets a flag indicating whether the subproblem is convex.

Parameters:
  • benders (Benders) – the Benders’ decomposition which contains the subproblem

  • probnumber (int) – the problem number of the subproblem that the convexity will be set for

  • isconvex (bool, optional) – flag to indicate whether the subproblem is convex (default=True)

setBoolParam(name, value)#

Set a boolean-valued parameter.

Parameters:
  • name (str) – name of parameter

  • value (bool) – value of parameter

setCharParam(name, value)#

Set a char-valued parameter.

Parameters:
  • name (str) – name of parameter

  • value (str) – value of parameter

setCheck(cons, newCheck)#

Set “check” flag of a constraint.

Parameters:
setEmphasis(paraemphasis, quiet=True)#

Set emphasis settings

Parameters:
  • paraemphasis (PY_SCIP_PARAMEMPHASIS) – emphasis to set

  • quiet (bool, optional) – hide output? (Default value = True)

setEnforced(cons, newEnf)#

Set “enforced” flag of a constraint.

Parameters:
setHeurTiming(heurname, heurtiming)#

Set the timing of a heuristic

Parameters:
  • heurname (string, name of the heuristic)

  • heurtiming (PY_SCIP_HEURTIMING) – positions in the node solving loop where heuristic should be executed

setHeuristics(setting)#

Set heuristics parameter settings.

Parameters:

setting (SCIP_PARAMSETTING) – the parameter settings, e.g. SCIP_PARAMSETTING.OFF

setInitial(cons, newInit)#

Set “initial” flag of a constraint.

Parameters:
setIntParam(name, value)#

Set an int-valued parameter.

Parameters:
  • name (str) – name of parameter

  • value (int) – value of parameter

setLogfile(path)#

Sets the log file name for the currently installed message handler.

Parameters:

path (str or None) – name of log file, or None (no log)

setLongintParam(name, value)#

Set a long-valued parameter.

Parameters:
  • name (str) – name of parameter

  • value (int) – value of parameter

setMaximize()#

Set the objective sense to maximization.

setMinimize()#

Set the objective sense to minimization.

setModifiable(cons, newMod)#

Set “modifiable” flag of a constraint.

Parameters:
setObjIntegral()#

Informs SCIP that the objective value is always integral in every feasible solution.

Notes

This function should be used to inform SCIP that the objective function is integral, helping to improve the performance. This is useful when using column generation. If no column generation (pricing) is used, SCIP automatically detects whether the objective function is integral or can be scaled to be integral. However, in any case, the user has to make sure that no variable is added during the solving process that destroys this property.

setObjective(expr, sense='minimize', clear='true')#

Establish the objective function as a linear expression.

Parameters:
  • expr (Expr or float) – the objective function SCIP Expr, or constant value

  • sense (str, optional) – the objective sense (“minimize” or “maximize”) (Default value = ‘minimize’)

  • clear (bool, optional) – set all other variables objective coefficient to zero (Default value = ‘true’)

setObjlimit(objlimit)#

Set a limit on the objective function. Only solutions with objective value better than this limit are accepted.

Parameters:

objlimit (float) – limit on the objective function

setParam(name, value)#

Set a parameter with value in int, bool, real, long, char or str.

Parameters:
  • name (str) – name of parameter

  • value (object) – value of parameter

setParams(params)#

Sets multiple parameters at once.

Parameters:

params (dict of str to object) – dict mapping parameter names to their values.

setParamsCountsols()#

Sets SCIP parameters such that a valid counting process is possible.

setPresolve(setting)#

Set presolving parameter settings.

Parameters:

setting (SCIP_PARAMSETTING) – the parameter settings, e.g. SCIP_PARAMSETTING.OFF

setProbName(name)#

Set problem name.

Parameters:

name (str)

setRealParam(name, value)#

Set a real-valued parameter.

Parameters:
  • name (str) – name of parameter

  • value (float) – value of parameter

setRelaxSolVal(var, val)#

Sets the value of the given variable in the global relaxation solution.

Parameters:
setRemovable(cons, newRem)#

Set “removable” flag of a constraint.

Parameters:
setSeparating(setting)#

Set separating parameter settings.

Parameters:

setting (SCIP_PARAMSETTING) – the parameter settings, e.g. SCIP_PARAMSETTING.OFF

setSolVal(solution, var, val)#

Set a variable in a solution.

Parameters:
  • solution (Solution) – solution to be modified

  • var (Variable) – variable in the solution

  • val (float) – value of the specified variable

setStringParam(name, value)#

Set a string-valued parameter.

Parameters:
  • name (str) – name of parameter

  • value (str) – value of parameter

setupBendersSubproblem(probnumber, benders=None, solution=None, checktype=1)#

Sets up the Benders’ subproblem given the master problem solution.

Parameters:
  • probnumber (int) – the index of the problem that is to be set up

  • benders (Benders or None, optional) – the Benders’ decomposition to which the subproblem belongs to

  • solution (Solution or None, optional) – the master problem solution that is used for the set up, if None, then the LP solution is used

  • checktype (PY_SCIP_BENDERSENFOTYPE) – the type of solution check that prompted the solving of the Benders’ subproblems, either PY_SCIP_BENDERSENFOTYPE: LP, RELAX, PSEUDO or CHECK. Default is LP.

solveBendersSubproblem(probnumber, solvecip, benders=None, solution=None)#

Solves the Benders’ decomposition subproblem. The convex relaxation will be solved unless the parameter solvecip is set to True.

Parameters:
  • probnumber (int) – the index of the problem that is to be set up

  • solvecip (bool) – whether the CIP of the subproblem should be solved. If False, then only the convex relaxation is solved.

  • benders (Benders or None, optional) – the Benders’ decomposition to which the subproblem belongs to

  • solution (Solution or None, optional) – the master problem solution that is used for the set up, if None, then the LP solution is used

Returns:

  • infeasible (bool) – returns whether the current subproblem is infeasible

  • objective (float or None) – the objective function value of the subproblem, can be None

solveConcurrent()#

Transforms, presolves, and solves problem using additional solvers which emphasize on finding solutions. WARNING: This feature is still experimental and prone to some errors.

solveDiveLP(itlim=-1)#

Solves the LP of the current dive. No separation or pricing is applied.

Parameters:

itlim (int, optional) – maximal number of LP iterations to perform (Default value = -1, that is, no limit)

Returns:

  • lperror (bool) – whether an unresolved lp error occured

  • cutoff (bool) – whether the LP was infeasible or the objective limit was reached

solveProbingLP(itlim=-1)#

Solves the LP at the current probing node (cannot be applied at preprocessing stage) no separation or pricing is applied.

Parameters:

itlim (int) – maximal number of LP iterations to perform (Default value = -1, that is, no limit)

Returns:

  • lperror (bool) – if an unresolved lp error occured

  • cutoff (bool) – whether the LP was infeasible or the objective limit was reached

solveProbingLPWithPricing(pretendroot=False, displayinfo=False, maxpricerounds=-1)#

Solves the LP at the current probing node (cannot be applied at preprocessing stage) and applies pricing until the LP is solved to optimality; no separation is applied.

Parameters:
  • pretendroot (bool) – should the pricers be called as if we are at the root node? (Default value = False)

  • displayinfo (bool) – should info lines be displayed after each pricing round? (Default value = False)

  • maxpricerounds (int) – maximal number of pricing rounds (-1: no limit); a finite limit means that the LP might not be solved to optimality! (Default value = -1)

Returns:

  • lperror (bool) – whether an unresolved LP error occurred

  • cutoff (bool) – whether the probing LP was infeasible or the objective limit was reached

sortAndCons(and_cons)#

Sorts the variables of the AND-constraint with respect to their indices.

Parameters:

and_cons (Constraint) – Constraint to sort.

startDive()#

Initiates LP diving. It allows the user to change the LP in several ways, solve, change again, etc, without affecting the actual LP. When endDive() is called, SCIP will undo all changes done and recover the LP it had before startDive.

startProbing()#

Initiates probing, making methods SCIPnewProbingNode(), SCIPbacktrackProbing(), SCIPchgVarLbProbing(), SCIPchgVarUbProbing(), SCIPfixVarProbing(), SCIPpropagateProbing(), SCIPsolveProbingLP(), etc available.

startStrongbranch()#

Start strong branching. Needs to be called before any strong branching. Must also later end strong branching. TODO: Propagation option has currently been disabled via Python. If propagation is enabled then strong branching is not done on the LP, but on additionally created nodes (has some overhead).

tightenVarLb(var, lb, force=False)#

Tighten the lower bound in preprocessing or current node, if the bound is tighter.

Parameters:
  • var (Variable) – SCIP variable

  • lb (float) – possible new lower bound

  • force (bool, optional) – force tightening even if below bound strengthening tolerance (default = False)

Returns:

  • infeasible (bool) – Whether new domain is empty

  • tightened (bool) – Whether the bound was tightened

tightenVarLbGlobal(var, lb, force=False)#

Tighten the global lower bound, if the bound is tighter.

Parameters:
  • var (Variable) – SCIP variable

  • lb (float) – possible new lower bound

  • force (bool, optional) – force tightening even if below bound strengthening tolerance

Returns:

  • infeasible (bool) – Whether new domain is empty

  • tightened (bool) – Whether the bound was tightened

tightenVarUb(var, ub, force=False)#

Tighten the upper bound in preprocessing or current node, if the bound is tighter.

Parameters:
  • var (Variable) – SCIP variable

  • ub (float) – possible new upper bound

  • force (bool, optional) – force tightening even if below bound strengthening tolerance

Returns:

  • infeasible (bool) – Whether new domain is empty

  • tightened (bool) – Whether the bound was tightened

tightenVarUbGlobal(var, ub, force=False)#

Tighten the global upper bound, if the bound is tighter.

Parameters:
  • var (Variable) – SCIP variable

  • ub (float) – possible new upper bound

  • force (bool, optional) – force tightening even if below bound strengthening tolerance

Returns:

  • infeasible (bool) – Whether new domain is empty

  • tightened (bool) – Whether the bound was tightened

to_ptr(give_ownership)#

Return the underlying Scip pointer to the current Model.

Parameters:

give_ownership (bool) – Whether the current Model gives away ownership of the underlying Scip pointer (see _freescip)

Returns:

The underlying pointer to the current Model, wrapped in a PyCapsule under the name “scip”.

Return type:

capsule

translateSubSol(sub_model, sol, heur) Solution#

Translates a solution of a model copy into a solution of the main model

Parameters:
  • sub_model (Model) – The python-wrapper of the subscip

  • sol (Solution) – The python-wrapper of the solution of the subscip

  • heur (Heur) – The python-wrapper of the heuristic that found the solution

Returns:

solution – The corresponding solution in the main model

Return type:

Solution

trySol(solution, printreason=True, completely=False, checkbounds=True, checkintegrality=True, checklprows=True, free=True)#

Check given primal solution for feasibility and try to add it to the storage.

Parameters:
  • solution (Solution) – solution to store

  • printreason (bool, optional) – should all reasons of violations be printed? (Default value = True)

  • completely (bool, optional) – should all violation be checked? (Default value = False)

  • checkbounds (bool, optional) – should the bounds of the variables be checked? (Default value = True)

  • checkintegrality (bool, optional) – does integrality have to be checked? (Default value = True)

  • checklprows (bool, optional) – do current LP rows (both local and global) have to be checked? (Default value = True)

  • free (bool, optional) – should solution be freed? (Default value = True)

Returns:

stored – whether given solution was feasible and good enough to keep

Return type:

bool

updateBendersLowerbounds(lowerbounds, benders=None)#

Updates the subproblem lower bounds for benders using the lowerbounds dict. If benders is None, then the default Benders’ decomposition is updated.

Parameters:
  • lowerbounds (dict of int to float)

  • benders (Benders or None, optional)

updateNodeLowerbound(node, lb)#

If given value is larger than the node’s lower bound (in transformed problem), sets the node’s lower bound to the new value.

Parameters:
  • node (Node) – the node to update

  • lb (float) – new bound (if greater) for the node

updateVarPseudocost(var, valdelta, objdelta, weight)#

Updates the pseudo costs of the given variable and the global pseudo costs after a change of valdelta in the variable’s solution value and resulting change of objdelta in the LP’s objective value. Update is ignored if objdelts is infinite. Weight is in range (0, 1], and affects how it updates the global weighted sum.

Parameters:
  • var (Variable) – Variable whos pseudo cost will be updated

  • valdelta (float) – The change in variable value (e.g. the fractional amount removed or added by branching)

  • objdelta (float) – The change in objective value of the LP after valdelta change of the variable

  • weight (float) – the weight in range (0,1] of how the update affects the stored weighted sum.

version()#

Retrieve SCIP version.

Return type:

float

writeBestSol(filename='origprob.sol', write_zeros=False)#

Write the best feasible primal solution to a file.

Parameters:
  • filename (str, optional) – name of the output file (Default=”origprob.sol”)

  • write_zeros (bool, optional) – include variables that are set to zero (Default=False)

writeBestTransSol(filename='transprob.sol', write_zeros=False)#

Write the best feasible primal solution for the transformed problem to a file.

Parameters:
  • filename (str, optional) – name of the output file (Default=”transprob.sol”)

  • write_zeros (bool, optional) – include variables that are set to zero (Default=False)

writeLP(filename='LP.lp')#

Writes current LP to a file.

Parameters:

filename (str, optional) – file name (Default value = “LP.lp”)

writeMIP(filename, genericnames=False, origobj=False, lazyconss=False)#

Writes MIP relaxation of the current branch-and-bound node to a file

Parameters:
  • filename (str) – name of the output file

  • genericnames (bool, optional) – should generic names like x_i and row_j be used in order to avoid troubles with reserved symbols? (Default value = False)

  • origobj (bool, optional) – should the original objective function be used (Default value = False)

  • lazyconss (bool, optional) – output removable rows as lazy constraints? (Default value = False)

writeName(var)#

Write the name of the variable to the std out.

Parameters:

var (Variable)

writeParams(filename='param.set', comments=True, onlychanged=True, verbose=True)#

Write parameter settings to an external file.

Parameters:
  • filename (str, optional) – file to be written (Default value = ‘param.set’)

  • comments (bool, optional) – write parameter descriptions as comments? (Default value = True)

  • onlychanged (bool, optional) – write only modified parameters (Default value = True)

  • verbose (bool, optional) – indicates whether a success message should be printed

writeProblem(filename='model.cip', trans=False, genericnames=False, verbose=True)#

Write current model/problem to a file.

Parameters:
  • filename (str, optional) – the name of the file to be used (Default value = ‘model.cip’). Should have an extension corresponding to one of the readable file formats, described in https://www.scipopt.org/doc/html/group__FILEREADERS.php.

  • trans (bool, optional) – indicates whether the transformed problem is written to file (Default value = False)

  • genericnames (bool, optional) – indicates whether the problem should be written with generic variable and constraint names (Default value = False)

  • verbose (bool, optional) – indicates whether a success message should be printed

writeSol(solution, filename='origprob.sol', write_zeros=False)#

Write the given primal solution to a file.

Parameters:
  • solution (Solution) – solution to write

  • filename (str, optional) – name of the output file (Default=”origprob.sol”)

  • write_zeros (bool, optional) – include variables that are set to zero (Default=False)

writeStatistics(filename='origprob.stats')#

Write statistics to a file.

Parameters:

filename (str, optional) – name of the output file (Default = “origprob.stats”)

writeStatisticsJson(filename='origprob.stats.json')#

Write statistics to a JSON file.

Parameters:

filename (str, optional) – name of the output file (Default = “origprob.stats.json”)

writeTransSol(solution, filename='transprob.sol', write_zeros=False)#

Write the given transformed primal solution to a file.

Parameters:
  • solution (Solution) – transformed solution to write

  • filename (str, optional) – name of the output file (Default=”transprob.sol”)

  • write_zeros (bool, optional) – include variables that are set to zero (Default=False)