Initializing help system before first use

problem.addgencons

problem.addgencons


Purpose
Adds one or more general constraints to the problem. Each general constraint y = f(x1, ..., xn, c1, ..., cn) consists of one or more (input) columns xi, zero or more constant values ci and a resultant (output column) y. General constraints can be defined using operators such as maximum and minimum (at least one input column of any type and arbitrary number of input values), and and or (at least one binary input column, no constant values, binary resultant) and absolute value (exactly one input column of arbitrary type, no constant values).
Synopsis
problem.addgencons (type, resultant, colstart, col, valstart, val)
Arguments
type 
list or array containing the types of the general constraints:
xpress.gencons_max (0) 
indicates a maximum constraint;
xpress.gencons_min (1) 
indicates a minimum constraint;
xpress.gencons_and (2) 
indicates an and constraint;
xpress.gencons_or (3) 
indicates an or constraint;
xpress.gencons_abs (4) 
indicates an absolute value constraint.
resultant 
Array/list containing the output variables (or indices thereof) of the general constraints.
colstart 
Array/list containing the start index of each general constraint in the col array.
col 
Array/list containing the input variables in all general constraints.
valstart 
Array/list containing the start index of each general constraint in the val array (may be None).
val 
Array/list containing the constant values in all general constraints (may be None).
Example
This adds two new general constraints x2 = max(x0, x1, 5) and x3 = |x1|:
type = [xpress.gencons_max, xpress.gencons_abs]
resultant = [2, 3]
colstart = [0, 2]
col = [0, 1, 1]
valstart = [0, 1]
val = [5.0]

prob.addgencons(type, resultant, colstart, col, valstart, val);
prob.solve()
Further information
General constraints must be set up before solving the problem. They are converted to additional binary variables, indicator and linear constraints with the exact formulation and number of added entities depending on the performed presolving. Note that using non-binary variables in and/ or constraints or adding constant values to them or absolute value constraints will give an error at solve time.
Related topics