4 from os.path
import abspath
5 from os.path
import splitext
9 from cpython cimport Py_INCREF, Py_DECREF
10 from libc.stdlib cimport malloc, free
11 from libc.stdio cimport fdopen
16 include
"branchrule.pxi" 17 include
"conshdlr.pxi" 19 include
"heuristic.pxi" 22 include
"propagator.pxi" 34 if sys.version_info >= (3, 0):
35 str_conversion =
lambda x:bytes(x,
'utf-8')
37 str_conversion =
lambda x:x
43 cdef
class PY_SCIP_RESULT:
44 DIDNOTRUN = SCIP_DIDNOTRUN
45 DELAYED = SCIP_DELAYED
46 DIDNOTFIND = SCIP_DIDNOTFIND
47 FEASIBLE = SCIP_FEASIBLE
48 INFEASIBLE = SCIP_INFEASIBLE
49 UNBOUNDED = SCIP_UNBOUNDED
51 SEPARATED = SCIP_SEPARATED
52 NEWROUND = SCIP_NEWROUND
53 REDUCEDDOM = SCIP_REDUCEDDOM
54 CONSADDED = SCIP_CONSADDED
55 CONSCHANGED = SCIP_CONSCHANGED
56 BRANCHED = SCIP_BRANCHED
57 SOLVELP = SCIP_SOLVELP
58 FOUNDSOL = SCIP_FOUNDSOL
59 SUSPENDED = SCIP_SUSPENDED
60 SUCCESS = SCIP_SUCCESS
62 cdef
class PY_SCIP_PARAMSETTING:
63 DEFAULT = SCIP_PARAMSETTING_DEFAULT
64 AGGRESSIVE = SCIP_PARAMSETTING_AGGRESSIVE
65 FAST = SCIP_PARAMSETTING_FAST
66 OFF = SCIP_PARAMSETTING_OFF
68 cdef
class PY_SCIP_PARAMEMPHASIS:
69 DEFAULT = SCIP_PARAMEMPHASIS_DEFAULT
70 CPSOLVER = SCIP_PARAMEMPHASIS_CPSOLVER
71 EASYCIP = SCIP_PARAMEMPHASIS_EASYCIP
72 FEASIBILITY = SCIP_PARAMEMPHASIS_FEASIBILITY
73 HARDLP = SCIP_PARAMEMPHASIS_HARDLP
74 OPTIMALITY = SCIP_PARAMEMPHASIS_OPTIMALITY
75 COUNTER = SCIP_PARAMEMPHASIS_COUNTER
76 PHASEFEAS = SCIP_PARAMEMPHASIS_PHASEFEAS
77 PHASEIMPROVE = SCIP_PARAMEMPHASIS_PHASEIMPROVE
78 PHASEPROOF = SCIP_PARAMEMPHASIS_PHASEPROOF
80 cdef
class PY_SCIP_STATUS:
81 UNKNOWN = SCIP_STATUS_UNKNOWN
82 USERINTERRUPT = SCIP_STATUS_USERINTERRUPT
83 NODELIMIT = SCIP_STATUS_NODELIMIT
84 TOTALNODELIMIT = SCIP_STATUS_TOTALNODELIMIT
85 STALLNODELIMIT = SCIP_STATUS_STALLNODELIMIT
86 TIMELIMIT = SCIP_STATUS_TIMELIMIT
87 MEMLIMIT = SCIP_STATUS_MEMLIMIT
88 GAPLIMIT = SCIP_STATUS_GAPLIMIT
89 SOLLIMIT = SCIP_STATUS_SOLLIMIT
90 BESTSOLLIMIT = SCIP_STATUS_BESTSOLLIMIT
91 RESTARTLIMIT = SCIP_STATUS_RESTARTLIMIT
92 OPTIMAL = SCIP_STATUS_OPTIMAL
93 INFEASIBLE = SCIP_STATUS_INFEASIBLE
94 UNBOUNDED = SCIP_STATUS_UNBOUNDED
95 INFORUNBD = SCIP_STATUS_INFORUNBD
97 cdef
class PY_SCIP_STAGE:
98 INIT = SCIP_STAGE_INIT
99 PROBLEM = SCIP_STAGE_PROBLEM
100 TRANSFORMING = SCIP_STAGE_TRANSFORMING
101 TRANSFORMED = SCIP_STAGE_TRANSFORMED
102 INITPRESOLVE = SCIP_STAGE_INITPRESOLVE
103 PRESOLVING = SCIP_STAGE_PRESOLVING
104 EXITPRESOLVE = SCIP_STAGE_EXITPRESOLVE
105 PRESOLVED = SCIP_STAGE_PRESOLVED
106 INITSOLVE = SCIP_STAGE_INITSOLVE
107 SOLVING = SCIP_STAGE_SOLVING
108 SOLVED = SCIP_STAGE_SOLVED
109 EXITSOLVE = SCIP_STAGE_EXITSOLVE
110 FREETRANS = SCIP_STAGE_FREETRANS
111 FREE = SCIP_STAGE_FREE
113 cdef
class PY_SCIP_NODETYPE:
114 FOCUSNODE = SCIP_NODETYPE_FOCUSNODE
115 PROBINGNODE = SCIP_NODETYPE_PROBINGNODE
116 SIBLING = SCIP_NODETYPE_SIBLING
117 CHILD = SCIP_NODETYPE_CHILD
118 LEAF = SCIP_NODETYPE_LEAF
119 DEADEND = SCIP_NODETYPE_DEADEND
120 JUNCTION = SCIP_NODETYPE_JUNCTION
121 PSEUDOFORK = SCIP_NODETYPE_PSEUDOFORK
122 FORK = SCIP_NODETYPE_FORK
123 SUBROOT = SCIP_NODETYPE_SUBROOT
124 REFOCUSNODE = SCIP_NODETYPE_REFOCUSNODE
127 cdef
class PY_SCIP_PROPTIMING:
128 BEFORELP = SCIP_PROPTIMING_BEFORELP
129 DURINGLPLOOP = SCIP_PROPTIMING_DURINGLPLOOP
130 AFTERLPLOOP = SCIP_PROPTIMING_AFTERLPLOOP
131 AFTERLPNODE = SCIP_PROPTIMING_AFTERLPNODE
133 cdef
class PY_SCIP_PRESOLTIMING:
134 NONE = SCIP_PRESOLTIMING_NONE
135 FAST = SCIP_PRESOLTIMING_FAST
136 MEDIUM = SCIP_PRESOLTIMING_MEDIUM
137 EXHAUSTIVE = SCIP_PRESOLTIMING_EXHAUSTIVE
139 cdef
class PY_SCIP_HEURTIMING:
140 BEFORENODE = SCIP_HEURTIMING_BEFORENODE
141 DURINGLPLOOP = SCIP_HEURTIMING_DURINGLPLOOP
142 AFTERLPLOOP = SCIP_HEURTIMING_AFTERLPLOOP
143 AFTERLPNODE = SCIP_HEURTIMING_AFTERLPNODE
144 AFTERPSEUDONODE = SCIP_HEURTIMING_AFTERPSEUDONODE
145 AFTERLPPLUNGE = SCIP_HEURTIMING_AFTERLPPLUNGE
146 AFTERPSEUDOPLUNGE = SCIP_HEURTIMING_AFTERPSEUDOPLUNGE
147 DURINGPRICINGLOOP = SCIP_HEURTIMING_DURINGPRICINGLOOP
148 BEFOREPRESOL = SCIP_HEURTIMING_BEFOREPRESOL
149 DURINGPRESOLLOOP = SCIP_HEURTIMING_DURINGPRESOLLOOP
150 AFTERPROPLOOP = SCIP_HEURTIMING_AFTERPROPLOOP
152 cdef
class PY_SCIP_EVENTTYPE:
153 DISABLED = SCIP_EVENTTYPE_DISABLED
154 VARADDED = SCIP_EVENTTYPE_VARADDED
155 VARDELETED = SCIP_EVENTTYPE_VARDELETED
156 VARFIXED = SCIP_EVENTTYPE_VARFIXED
157 VARUNLOCKED = SCIP_EVENTTYPE_VARUNLOCKED
158 OBJCHANGED = SCIP_EVENTTYPE_OBJCHANGED
159 GLBCHANGED = SCIP_EVENTTYPE_GLBCHANGED
160 GUBCHANGED = SCIP_EVENTTYPE_GUBCHANGED
161 LBTIGHTENED = SCIP_EVENTTYPE_LBTIGHTENED
162 LBRELAXED = SCIP_EVENTTYPE_LBRELAXED
163 UBTIGHTENED = SCIP_EVENTTYPE_UBTIGHTENED
164 UBRELAXED = SCIP_EVENTTYPE_UBRELAXED
165 GHOLEADDED = SCIP_EVENTTYPE_GHOLEADDED
166 GHOLEREMOVED = SCIP_EVENTTYPE_GHOLEREMOVED
167 LHOLEADDED = SCIP_EVENTTYPE_LHOLEADDED
168 LHOLEREMOVED = SCIP_EVENTTYPE_LHOLEREMOVED
169 IMPLADDED = SCIP_EVENTTYPE_IMPLADDED
170 PRESOLVEROUND = SCIP_EVENTTYPE_PRESOLVEROUND
171 NODEFOCUSED = SCIP_EVENTTYPE_NODEFOCUSED
172 NODEFEASIBLE = SCIP_EVENTTYPE_NODEFEASIBLE
173 NODEINFEASIBLE = SCIP_EVENTTYPE_NODEINFEASIBLE
174 NODEBRANCHED = SCIP_EVENTTYPE_NODEBRANCHED
175 FIRSTLPSOLVED = SCIP_EVENTTYPE_FIRSTLPSOLVED
176 LPSOLVED = SCIP_EVENTTYPE_LPSOLVED
177 LPEVENT = SCIP_EVENTTYPE_LPEVENT
178 POORSOLFOUND = SCIP_EVENTTYPE_POORSOLFOUND
179 BESTSOLFOUND = SCIP_EVENTTYPE_BESTSOLFOUND
180 ROWADDEDSEPA = SCIP_EVENTTYPE_ROWADDEDSEPA
181 ROWDELETEDSEPA = SCIP_EVENTTYPE_ROWDELETEDSEPA
182 ROWADDEDLP = SCIP_EVENTTYPE_ROWADDEDLP
183 ROWDELETEDLP = SCIP_EVENTTYPE_ROWDELETEDLP
184 ROWCOEFCHANGED = SCIP_EVENTTYPE_ROWCOEFCHANGED
185 ROWCONSTCHANGED = SCIP_EVENTTYPE_ROWCONSTCHANGED
186 ROWSIDECHANGED = SCIP_EVENTTYPE_ROWSIDECHANGED
187 SYNC = SCIP_EVENTTYPE_SYNC
189 cdef
class PY_SCIP_LPSOLSTAT:
190 NOTSOLVED = SCIP_LPSOLSTAT_NOTSOLVED
191 OPTIMAL = SCIP_LPSOLSTAT_OPTIMAL
192 INFEASIBLE = SCIP_LPSOLSTAT_INFEASIBLE
193 UNBOUNDEDRAY = SCIP_LPSOLSTAT_UNBOUNDEDRAY
194 OBJLIMIT = SCIP_LPSOLSTAT_OBJLIMIT
195 ITERLIMIT = SCIP_LPSOLSTAT_ITERLIMIT
196 TIMELIMIT = SCIP_LPSOLSTAT_TIMELIMIT
197 ERROR = SCIP_LPSOLSTAT_ERROR
199 cdef
class PY_SCIP_BRANCHDIR:
200 DOWNWARDS = SCIP_BRANCHDIR_DOWNWARDS
201 UPWARDS = SCIP_BRANCHDIR_UPWARDS
202 FIXED = SCIP_BRANCHDIR_FIXED
203 AUTO = SCIP_BRANCHDIR_AUTO
205 def PY_SCIP_CALL(SCIP_RETCODE rc):
208 elif rc == SCIP_ERROR:
209 raise Exception(
'SCIP: unspecified error!')
210 elif rc == SCIP_NOMEMORY:
211 raise MemoryError(
'SCIP: insufficient memory error!')
212 elif rc == SCIP_READERROR:
213 raise IOError(
'SCIP: read error!')
214 elif rc == SCIP_WRITEERROR:
215 raise IOError(
'SCIP: write error!')
216 elif rc == SCIP_NOFILE:
217 raise IOError(
'SCIP: file not found error!')
218 elif rc == SCIP_FILECREATEERROR:
219 raise IOError(
'SCIP: cannot create file!')
220 elif rc == SCIP_LPERROR:
221 raise Exception(
'SCIP: error in LP solver!')
222 elif rc == SCIP_NOPROBLEM:
223 raise Exception(
'SCIP: no problem exists!')
224 elif rc == SCIP_INVALIDCALL:
225 raise Exception(
'SCIP: method cannot be called at this time' 226 +
' in solution process!')
227 elif rc == SCIP_INVALIDDATA:
228 raise Exception(
'SCIP: error in input data!')
229 elif rc == SCIP_INVALIDRESULT:
230 raise Exception(
'SCIP: method returned an invalid result code!')
231 elif rc == SCIP_PLUGINNOTFOUND:
232 raise Exception(
'SCIP: a required plugin was not found !')
233 elif rc == SCIP_PARAMETERUNKNOWN:
234 raise KeyError(
'SCIP: the parameter with the given name was not found!')
235 elif rc == SCIP_PARAMETERWRONGTYPE:
236 raise LookupError(
'SCIP: the parameter is not of the expected type!')
237 elif rc == SCIP_PARAMETERWRONGVAL:
238 raise ValueError(
'SCIP: the value is invalid for the given parameter!')
239 elif rc == SCIP_KEYALREADYEXISTING:
240 raise KeyError(
'SCIP: the given key is already existing in table!')
241 elif rc == SCIP_MAXDEPTHLEVEL:
242 raise Exception(
'SCIP: maximal branching depth level exceeded!')
244 raise Exception(
'SCIP: unknown return code!')
247 cdef SCIP_EVENT* event
250 cdef create(SCIP_EVENT* scip_event):
252 event.event = scip_event
256 """gets type of event""" 263 """gets new bound for a bound change event""" 267 """gets old bound for a bound change event""" 271 """gets variable for a variable event (var added, var deleted, var fixed, objective value or domain change, domain hole added or removed)""" 273 return Variable.create(var)
276 """gets node for a node or LP event""" 278 return Node.create(node)
281 """Base class holding a pointer to corresponding SCIP_COL""" 285 cdef create(SCIP_COL* scip_col):
291 """gets position of column in current LP, or -1 if it is not in LP""" 295 """gets the basis status of a column in the LP solution, Note: returns basis status `zero` for columns not in the current SCIP LP""" 297 if stat == SCIP_BASESTAT_LOWER:
299 elif stat == SCIP_BASESTAT_BASIC:
301 elif stat == SCIP_BASESTAT_UPPER:
303 elif stat == SCIP_BASESTAT_ZERO:
306 raise Exception(
'SCIP returned unknown base status!')
309 """returns whether the associated variable is of integral type (binary, integer, implicit integer)""" 313 """gets variable this column represents""" 315 return Variable.create(var)
318 """gets the primal LP solution of a column""" 322 """gets lower bound of column""" 326 """gets upper bound of column""" 330 """Base class holding a pointer to corresponding SCIP_ROW""" 334 cdef create(SCIP_ROW* scip_row):
340 """returns the left hand side of row""" 344 """returns the right hand side of row""" 348 """gets constant shift of row""" 352 """gets position of row in current LP, or -1 if it is not in LP""" 356 """gets the basis status of a row in the LP solution, Note: returns basis status `basic` for rows not in the current SCIP LP""" 358 if stat == SCIP_BASESTAT_LOWER:
360 elif stat == SCIP_BASESTAT_BASIC:
362 elif stat == SCIP_BASESTAT_UPPER:
364 elif stat == SCIP_BASESTAT_ZERO:
366 raise Exception(
'SCIP returned base status zero for a row!')
368 raise Exception(
'SCIP returned unknown base status!')
371 """returns TRUE iff the activity of the row (without the row's constant) is always integral in a feasible solution """ 375 """returns TRUE iff row is modifiable during node processing (subject to column generation) """ 379 """get number of nonzero entries in row vector""" 383 """get number of nonzero entries in row vector that correspond to columns currently in the SCIP LP""" 387 """gets list with columns of nonzero entries""" 389 return [Column.create(cols[i])
for i
in range(self.
getNNonz())]
392 """gets list with coefficients of nonzero entries""" 394 return [vals[i]
for i
in range(self.
getNNonz())]
397 """Base class holding a pointer to corresponding SCIP_SOL""" 401 cdef create(SCIP_SOL* scip_sol):
407 """Base class holding a pointer to corresponding SCIP_NODE""" 411 cdef create(SCIP_NODE* scip_node):
413 node.node = scip_node
417 """Retrieve parent node.""" 421 """Retrieve number of node.""" 425 """Retrieve depth of node.""" 429 """Retrieve type of node.""" 433 """Retrieve lower bound of node.""" 437 """Retrieve the estimated value of the best feasible solution in subtree of the node""" 441 """Retrieve number of added constraints at this node""" 445 """Is the node in the path to the current node?""" 449 """Is the node marked to be propagated again?""" 454 """Is a linear expression and has SCIP_VAR*""" 458 cdef create(SCIP_VAR* scipvar):
461 Expr.__init__(var, {Term(var) : 1.0})
467 return cname.decode(
'utf-8')
471 return <size_t>(self.
var)
477 """Retrieve the variables type (BINARY, INTEGER or CONTINUOUS)""" 479 if vartype == SCIP_VARTYPE_BINARY:
481 elif vartype == SCIP_VARTYPE_INTEGER:
483 elif vartype == SCIP_VARTYPE_CONTINUOUS
or vartype == SCIP_VARTYPE_IMPLINT:
487 """Retrieve whether the variable belongs to the original problem""" 491 """Retrieve whether the variable is a COLUMN variable that is member of the current LP""" 495 """Retrieve column of COLUMN variable""" 496 cdef SCIP_COL* scip_col
498 return Column.create(scip_col)
501 """Retrieve original lower bound of variable""" 505 """Retrieve original upper bound of variable""" 509 """Retrieve global lower bound of variable""" 513 """Retrieve global upper bound of variable""" 517 """Retrieve current lower bound of variable""" 521 """Retrieve current upper bound of variable""" 525 """Retrieve current objective value of variable""" 529 """Retrieve the current LP solution value of variable""" 535 cdef public object data
538 cdef create(SCIP_CONS* scipcons):
540 raise Warning(
"cannot create Constraint with SCIP_CONS* == NULL")
548 return cname.decode(
'utf-8')
554 """Retrieve whether the constraint belongs to the original problem""" 558 """Retrieve True if the relaxation of the constraint should be in the initial LP""" 562 """Retrieve True if constraint should be separated during LP processing""" 566 """Retrieve True if constraint should be enforced during node processing""" 570 """Retrieve True if constraint should be checked for feasibility""" 574 """Retrieve True if constraint should be propagated during node processing""" 578 """Retrieve True if constraint is only locally valid or not added to any (sub)problem""" 582 """Retrieve True if constraint is modifiable (subject to column generation)""" 586 """Retrieve True if constraint is subject to aging""" 590 """Retrieve True if constraint's relaxation should be removed from the LP due to aging or cleanup""" 594 """Retrieve True if constraint is only locally valid or not added to any (sub)problem""" 598 """Retrieve True if constraint is linear""" 600 return constype ==
'linear' 603 """Retrieve True if constraint is quadratic""" 605 return constype ==
'quadratic' 608 cdef void relayMessage(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char *msg):
609 sys.stdout.write(msg.decode(
'UTF-8'))
611 cdef void relayErrorMessage(void *messagehdlr, FILE *file, const char *msg):
612 sys.stderr.write(msg.decode(
'UTF-8'))
623 cdef Solution _bestSol
625 cdef public object data
627 cdef object __weakref__
629 def __init__(self, problemName='model', defaultPlugins=True):
631 :param problemName: name of the problem (default 'model') 632 :param defaultPlugins: use default plugins? (default True) 635 raise Exception(
"linked SCIP is not compatible to this version of PySCIPOpt - use at least version", MAJOR)
636 if self.
version() < MAJOR + MINOR/10.0 + PATCH/100.0:
637 warnings.warn(
"linked SCIP {} is not recommended for this version of PySCIPOpt - use version {}.{}.{}".format(self.
version(), MAJOR, MINOR, PATCH))
644 def __dealloc__(self):
647 PY_SCIP_CALL(
SCIPfree(&self._scip) )
650 """Create a new SCIP instance""" 654 """Includes all default plug-ins into SCIP""" 655 PY_SCIP_CALL(SCIPincludeDefaultPlugins(self._scip))
658 """Create new problem instance with given name 660 :param problemName: name of model or problem (Default value = 'model') 663 n = str_conversion(problemName)
667 """Frees problem and solution process data""" 671 """Frees all solution process data including presolving and transformed problem, only original problem is kept""" 675 """Retrieve SCIP version""" 679 """Print version, copyright information and compile mode""" 683 """Retrieve problem name""" 687 """Retrieve the current total SCIP time in seconds, i.e. the total time since the SCIP instance has been created""" 691 """Retrieve the current solving time in seconds""" 695 """Retrieve the current reading time in seconds""" 699 """Retrieve the curernt presolving time in seconds""" 703 """Retrieve the total number of processed nodes.""" 707 """Retrieve current node.""" 711 """Retrieve the gap, i.e. |(primalbound - dualbound)/min(|primalbound|,|dualbound|)|.""" 715 """Retrieve the depth of the current node""" 719 """Retrieve SCIP's infinity value""" 723 """Retrieve epsilon for e.g. equality checks""" 727 """Retrieve feasibility tolerance""" 731 """returns fractional part of value, i.e. x - floor(x) in feasible tolerance: x - floor(x+feastol)""" 735 """returns fractional part of value, i.e. x - floor(x) in epsilon tolerance: x - floor(x+eps)""" 739 """returns whether abs(value) < eps""" 743 """returns whether abs(value) < feastol""" 747 """returns whether value is SCIP's infinity""" 751 """returns whether value < -feastol""" 755 """returns whether val1 <= val2 + eps""" 756 return SCIPisLE(self._scip, val1, val2)
759 """returns whether val1 < val2 - eps""" 760 return SCIPisLT(self._scip, val1, val2)
763 """returns whether val1 >= val2 - eps""" 764 return SCIPisGE(self._scip, val1, val2)
767 """returns whether val1 > val2 + eps""" 768 return SCIPisGT(self._scip, val1, val2)
771 """Get the current LP's condition number 773 :param exact: whether to get an estimate or the exact value (Default value = False) 778 cdef SCIP_Real quality = 0
789 """Set the objective sense to minimization.""" 793 """Set the objective sense to maximization.""" 797 """Set a limit on the objective function. 798 Only solutions with objective value better than this limit are accepted. 800 :param objlimit: limit on the objective function 806 """returns current limit on objective function.""" 810 """Establish the objective function as a linear expression. 812 :param coeffs: the coefficients 813 :param sense: the objective sense (Default value = 'minimize') 814 :param clear: set all other variables objective coefficient to zero (Default value = 'true') 817 cdef SCIP_VAR** _vars
821 if not isinstance(coeffs, Expr):
822 assert(_is_number(coeffs)),
"given coefficients are neither Expr or number but %s" % coeffs.__class__.__name__
823 coeffs = Expr() + coeffs
825 if coeffs.degree() > 1:
826 raise ValueError(
"Nonlinear objective functions are not supported!")
827 if coeffs[CONST] != 0.0:
834 for i
in range(_nvars):
837 for term, coef
in coeffs.terms.items():
840 assert len(term) == 1
841 var = <Variable>term[0]
844 if sense ==
"minimize":
846 elif sense ==
"maximize":
849 raise Warning(
"unrecognized optimization sense: %s" % sense)
852 """Retrieve objective function as Expr""" 855 for var
in variables:
858 objective += coeff * var
859 objective.normalize()
863 """Add constant offset to objective 865 :param offset: offset to add 866 :param solutions: add offset also to existing solutions (Default value = False) 875 """Retrieve constant objective offset 877 :param original: offset of original or transformed problem (Default value = True) 887 """Set presolving parameter settings. 889 :param setting: the parameter settings (SCIP_PARAMSETTING) 895 """Set problem name""" 896 n = str_conversion(name)
900 """Set separating parameter settings. 902 :param setting: the parameter settings (SCIP_PARAMSETTING) 908 """Set heuristics parameter settings. 910 :param setting: the parameter setting (SCIP_PARAMSETTING) 916 """Disables propagation in SCIP to avoid modifying the original problem during transformation. 918 :param onlyroot: use propagation when root processing is finished (Default value = False) 926 """Write current model/problem to a file. 928 :param filename: the name of the file to be used (Default value = 'model.cip') 929 :param trans: indicates whether the transformed problem is written to file (Default value = False) 932 fn = str_conversion(filename)
933 fn, ext = splitext(fn)
935 ext = str_conversion(
'.cip')
942 print(
'wrote problem to file ' + str(fn))
946 def addVar(self, name='', vtype='C', lb=0.0, ub=None, obj=0.0, pricedVar = False):
947 """Create a new variable. Default variable is non-negative and continuous. 949 :param name: name of the variable, generic if empty (Default value = '') 950 :param vtype: type of the variable (Default value = 'C') 951 :param lb: lower bound of the variable, use None for -infinity (Default value = 0.0) 952 :param ub: upper bound of the variable, use None for +infinity (Default value = None) 953 :param obj: objective value of variable (Default value = 0.0) 954 :param pricedVar: is the variable a pricing candidate? (Default value = False) 962 cname = str_conversion(name)
967 cdef SCIP_VAR* scip_var
968 vtype = vtype.upper()
969 if vtype
in [
'C',
'CONTINUOUS']:
970 PY_SCIP_CALL(
SCIPcreateVarBasic(self._scip, &scip_var, cname, lb, ub, obj, SCIP_VARTYPE_CONTINUOUS))
971 elif vtype
in [
'B',
'BINARY']:
974 PY_SCIP_CALL(
SCIPcreateVarBasic(self._scip, &scip_var, cname, lb, ub, obj, SCIP_VARTYPE_BINARY))
975 elif vtype
in [
'I',
'INTEGER']:
976 PY_SCIP_CALL(
SCIPcreateVarBasic(self._scip, &scip_var, cname, lb, ub, obj, SCIP_VARTYPE_INTEGER))
978 raise Warning(
"unrecognized variable type")
983 PY_SCIP_CALL(
SCIPaddVar(self._scip, scip_var))
985 pyVar = Variable.create(scip_var)
993 """Release the variable. 995 :param Variable var: variable to be released 1001 """Retrieve the transformed variable. 1003 :param Variable var: original variable to get the transformed of 1006 cdef SCIP_VAR* _tvar
1008 return Variable.create(_tvar)
1011 """adds given values to lock numbers of variable for rounding 1013 :param Variable var: variable to adjust the locks for 1014 :param nlocksdown: new number of down locks 1015 :param nlocksup: new number of up locks 1018 PY_SCIP_CALL(
SCIPaddVarLocks(self._scip, var.var, nlocksdown, nlocksup))
1021 """Fixes the variable var to the value val if possible. 1023 :param Variable var: variable to fix 1024 :param val: float, the fix value 1025 :return: tuple (infeasible, fixed) of booleans 1028 cdef SCIP_Bool infeasible
1029 cdef SCIP_Bool fixed
1030 PY_SCIP_CALL(
SCIPfixVar(self._scip, var.var, val, &infeasible, &fixed))
1031 return infeasible, fixed
1034 """Delete a variable. 1036 :param var: the variable which shall be deleted 1037 :return: bool, was deleting succesful 1040 cdef SCIP_Bool deleted
1041 PY_SCIP_CALL(
SCIPdelVar(self._scip, var.var, &deleted))
1045 """Tighten the lower bound in preprocessing or current node, if the bound is tighter. 1047 :param var: SCIP variable 1048 :param lb: possible new lower bound 1049 :param force: force tightening even if below bound strengthening tolerance 1050 :return: tuple of bools, (infeasible, tightened) 1051 infeasible: whether new domain is empty 1052 tightened: whether the bound was tightened 1055 cdef SCIP_Bool infeasible
1056 cdef SCIP_Bool tightened
1057 PY_SCIP_CALL(
SCIPtightenVarLb(self._scip, var.var, lb, force, &infeasible, &tightened))
1058 return infeasible, tightened
1062 """Tighten the upper bound in preprocessing or current node, if the bound is tighter. 1064 :param var: SCIP variable 1065 :param ub: possible new upper bound 1066 :param force: force tightening even if below bound strengthening tolerance 1067 :return: tuple of bools, (infeasible, tightened) 1068 infeasible: whether new domain is empty 1069 tightened: whether the bound was tightened 1072 cdef SCIP_Bool infeasible
1073 cdef SCIP_Bool tightened
1074 PY_SCIP_CALL(
SCIPtightenVarUb(self._scip, var.var, ub, force, &infeasible, &tightened))
1075 return infeasible, tightened
1079 """Tighten the global upper bound, if the bound is tighter. 1081 :param var: SCIP variable 1082 :param ub: possible new upper bound 1083 :param force: force tightening even if below bound strengthening tolerance 1084 :return: tuple of bools, (infeasible, tightened) 1085 infeasible: whether new domain is empty 1086 tightened: whether the bound was tightened 1089 cdef SCIP_Bool infeasible
1090 cdef SCIP_Bool tightened
1092 return infeasible, tightened
1095 """Tighten the global upper bound, if the bound is tighter. 1097 :param var: SCIP variable 1098 :param lb: possible new upper bound 1099 :param force: force tightening even if below bound strengthening tolerance 1100 :return: tuple of bools, (infeasible, tightened) 1101 infeasible: whether new domain is empty 1102 tightened: whether the bound was tightened 1105 cdef SCIP_Bool infeasible
1106 cdef SCIP_Bool tightened
1108 return infeasible, tightened
1111 """Changes the lower bound of the specified variable. 1113 :param Variable var: variable to change bound of 1114 :param lb: new lower bound (set to None for -infinity) 1122 """Changes the upper bound of the specified variable. 1124 :param Variable var: variable to change bound of 1125 :param ub: new upper bound (set to None for +infinity) 1134 """Changes the global lower bound of the specified variable. 1136 :param Variable var: variable to change bound of 1137 :param lb: new lower bound (set to None for -infinity) 1145 """Changes the global upper bound of the specified variable. 1147 :param Variable var: variable to change bound of 1148 :param ub: new upper bound (set to None for +infinity) 1156 """Changes the lower bound of the specified variable at the given node. 1158 :param Variable var: variable to change bound of 1159 :param lb: new lower bound (set to None for -infinity) 1167 """Changes the upper bound of the specified variable at the given node. 1169 :param Variable var: variable to change bound of 1170 :param ub: new upper bound (set to None for +infinity) 1178 """Changes the type of a variable 1180 :param Variable var: variable to change type of 1181 :param vtype: new variable type 1184 cdef SCIP_Bool infeasible
1185 if vtype
in [
'C',
'CONTINUOUS']:
1186 PY_SCIP_CALL(
SCIPchgVarType(self._scip, var.var, SCIP_VARTYPE_CONTINUOUS, &infeasible))
1187 elif vtype
in [
'B',
'BINARY']:
1188 PY_SCIP_CALL(
SCIPchgVarType(self._scip, var.var, SCIP_VARTYPE_BINARY, &infeasible))
1189 elif vtype
in [
'I',
'INTEGER']:
1190 PY_SCIP_CALL(
SCIPchgVarType(self._scip, var.var, SCIP_VARTYPE_INTEGER, &infeasible))
1192 raise Warning(
"unrecognized variable type")
1194 print(
'could not change variable type of variable %s' % var)
1197 """Retrieve all variables. 1199 :param transformed: get transformed variables instead of original (Default value = False) 1202 cdef SCIP_VAR** _vars
1214 return [Variable.create(_vars[i])
for i
in range(_nvars)]
1217 """Retrieve number of variables in the problems""" 1221 """Retrieve the number of constraints.""" 1225 """if given value is larger than the node's lower bound (in transformed problem), 1226 sets the node's lower bound to the new value 1228 :param node: Node, the node to update 1229 :param newbound: float, new bound (if greater) for the node 1236 """Gets solution status of current LP""" 1241 """makes sure that the LP of the current node is loaded and 1242 may be accessed through the LP information methods 1244 :return: bool cutoff, i.e. can the node be cut off? 1247 cdef SCIP_Bool cutoff
1252 """gets objective value of current LP (which is the sum of column and loose objective value)""" 1257 """Retrieve current LP columns""" 1258 cdef SCIP_COL** cols
1262 return [Column.create(cols[i])
for i
in range(ncols)]
1265 """Retrieve current LP rows""" 1266 cdef SCIP_ROW** rows
1270 return [Row.create(rows[i])
for i
in range(nrows)]
1273 """Retrieve the number of rows currently in the LP""" 1277 """Retrieve the number of cols currently in the LP""" 1281 """Gets all indices of basic columns and rows: index i >= 0 corresponds to column i, index i < 0 to row -i-1""" 1283 cdef int* inds = <int *> malloc(nrows * sizeof(int))
1286 result = [inds[i]
for i
in range(nrows)]
1291 """gets a row from the inverse basis matrix B^-1""" 1294 cdef SCIP_Real* coefs = <SCIP_Real*> malloc(nrows * sizeof(SCIP_Real))
1297 result = [coefs[i]
for i
in range(nrows)]
1302 """gets a row from B^-1 * A""" 1305 cdef SCIP_Real* coefs = <SCIP_Real*> malloc(ncols * sizeof(SCIP_Real))
1308 result = [coefs[i]
for i
in range(ncols)]
1313 """returns whether the current LP solution is basic, i.e. is defined by a valid simplex basis""" 1318 def createEmptyRowSepa(self, Sepa sepa, name="row", lhs = 0.0, rhs = None, local = True, modifiable = False, removable = True):
1319 """creates and captures an LP row without any coefficients from a separator 1321 :param sepa: separator that creates the row 1322 :param name: name of row (Default value = "row") 1323 :param lhs: left hand side of row (Default value = 0) 1324 :param rhs: right hand side of row (Default value = None) 1325 :param local: is row only valid locally? (Default value = True) 1326 :param modifiable: is row modifiable during node processing (subject to column generation)? (Default value = False) 1327 :param removable: should the row be removed from the LP due to aging or cleanup? (Default value = True) 1330 lhs = -
SCIPinfinity(self._scip)
if lhs
is None else lhs
1332 scip_sepa =
SCIPfindSepa(self._scip, str_conversion(sepa.name))
1333 PY_SCIP_CALL(
SCIPcreateEmptyRowSepa(self._scip, &row, scip_sepa, str_conversion(name), lhs, rhs, local, modifiable, removable))
1334 PyRow = Row.create(row)
1337 def createEmptyRowUnspec(self, name="row", lhs = 0.0, rhs = None, local = True, modifiable = False, removable = True):
1338 """creates and captures an LP row without any coefficients from an unspecified source 1340 :param name: name of row (Default value = "row") 1341 :param lhs: left hand side of row (Default value = 0) 1342 :param rhs: right hand side of row (Default value = None) 1343 :param local: is row only valid locally? (Default value = True) 1344 :param modifiable: is row modifiable during node processing (subject to column generation)? (Default value = False) 1345 :param removable: should the row be removed from the LP due to aging or cleanup? (Default value = True) 1348 lhs = -
SCIPinfinity(self._scip)
if lhs
is None else lhs
1350 PY_SCIP_CALL(
SCIPcreateEmptyRowUnspec(self._scip, &row, str_conversion(name), lhs, rhs, local, modifiable, removable))
1351 PyRow = Row.create(row)
1355 """returns the activity of a row in the last LP or pseudo solution""" 1359 """returns the activity of a row in the last LP solution""" 1364 """decreases usage counter of LP row, and frees memory if necessary""" 1368 """informs row, that all subsequent additions of variables to the row should be cached and not directly applied; 1369 after all additions were applied, flushRowExtensions() must be called; 1370 while the caching of row extensions is activated, information methods of the row give invalid results; 1371 caching should be used, if a row is build with addVarToRow() calls variable by variable to increase the performance""" 1375 """flushes all cached row extensions after a call of cacheRowExtensions() and merges coefficients with equal columns into a single coefficient""" 1378 def addVarToRow(self, Row row not None, Variable var not None, value):
1379 """resolves variable to columns and adds them with the coefficient to the row""" 1388 """if not already existing, adds row to global cut pool""" 1392 """returns efficacy of the cut with respect to the given primal solution or the current LP solution: e = -feasibility/norm""" 1396 """ 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""" 1399 def addCut(self, Row cut not None, forcecut = False):
1400 """adds cut to separation storage and returns whether cut has been detected to be infeasible for local bounds""" 1401 cdef SCIP_Bool infeasible
1402 PY_SCIP_CALL(
SCIPaddRow(self._scip, cut.row, forcecut, &infeasible))
1406 """Retrieve total number of cuts in storage""" 1410 """Retrieve number of currently applied cuts""" 1414 def addCons(self, cons, name='', initial=True, separate=True,
1415 enforce=
True, check=
True, propagate=
True, local=
False,
1416 modifiable=
False, dynamic=
False, removable=
False,
1417 stickingatnode=
False):
1418 """Add a linear or quadratic constraint. 1420 :param cons: list of coefficients 1421 :param name: the name of the constraint, generic name if empty (Default value = '') 1422 :param initial: should the LP relaxation of constraint be in the initial LP? (Default value = True) 1423 :param separate: should the constraint be separated during LP processing? (Default value = True) 1424 :param enforce: should the constraint be enforced during node processing? (Default value = True) 1425 :param check: should the constraint be checked during for feasibility? (Default value = True) 1426 :param propagate: should the constraint be propagated during node processing? (Default value = True) 1427 :param local: is the constraint only valid locally? (Default value = False) 1428 :param modifiable: is the constraint modifiable (subject to column generation)? (Default value = False) 1429 :param dynamic: is the constraint subject to aging? (Default value = False) 1430 :param removable: should the relaxation be removed from the LP due to aging or cleanup? (Default value = False) 1431 :param stickingatnode: 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) 1434 assert isinstance(cons, ExprCons),
"given constraint is not ExprCons but %s" % cons.__class__.__name__
1440 kwargs = dict(name=name, initial=initial, separate=separate,
1441 enforce=enforce, check=check,
1442 propagate=propagate, local=local,
1443 modifiable=modifiable, dynamic=dynamic,
1444 removable=removable,
1445 stickingatnode=stickingatnode)
1446 kwargs[
'lhs'] = -
SCIPinfinity(self._scip)
if cons.lhs
is None else cons.lhs
1447 kwargs[
'rhs'] =
SCIPinfinity(self._scip)
if cons.rhs
is None else cons.rhs
1449 deg = cons.expr.degree()
1454 elif deg == float(
'inf'):
1459 def _addLinCons(self, ExprCons lincons, **kwargs):
1460 assert isinstance(lincons, ExprCons),
"given constraint is not ExprCons but %s" % lincons.__class__.__name__
1462 assert lincons.expr.degree() <= 1,
"given constraint is not linear, degree == %d" % lincons.expr.degree()
1463 terms = lincons.expr.terms
1465 cdef SCIP_CONS* scip_cons
1467 self._scip, &scip_cons, str_conversion(kwargs[
'name']), 0, NULL, NULL,
1468 kwargs[
'lhs'], kwargs[
'rhs'], kwargs[
'initial'],
1469 kwargs[
'separate'], kwargs[
'enforce'], kwargs[
'check'],
1470 kwargs[
'propagate'], kwargs[
'local'], kwargs[
'modifiable'],
1471 kwargs[
'dynamic'], kwargs[
'removable'], kwargs[
'stickingatnode']))
1473 for key, coeff
in terms.items():
1474 var = <Variable>key[0]
1475 PY_SCIP_CALL(
SCIPaddCoefLinear(self._scip, scip_cons, var.var, <SCIP_Real>coeff))
1478 PyCons = Constraint.create(scip_cons)
1483 def _addQuadCons(self, ExprCons quadcons, **kwargs):
1484 terms = quadcons.expr.terms
1485 assert quadcons.expr.degree() <= 2,
"given constraint is not quadratic, degree == %d" % quadcons.expr.degree()
1487 cdef SCIP_CONS* scip_cons
1489 self._scip, &scip_cons, str_conversion(kwargs[
'name']),
1491 0, NULL, NULL, NULL,
1492 kwargs[
'lhs'], kwargs[
'rhs'],
1493 kwargs[
'initial'], kwargs[
'separate'], kwargs[
'enforce'],
1494 kwargs[
'check'], kwargs[
'propagate'], kwargs[
'local'],
1495 kwargs[
'modifiable'], kwargs[
'dynamic'], kwargs[
'removable']))
1497 for v, c
in terms.items():
1499 var = <Variable>v[0]
1502 assert len(v) == 2,
'term length must be 1 or 2 but it is %s' % len(v)
1503 var1, var2 = <Variable>v[0], <Variable>v[1]
1507 PyCons = Constraint.create(scip_cons)
1511 def _addNonlinearCons(self, ExprCons cons, **kwargs):
1512 cdef SCIP_EXPR* expr
1513 cdef SCIP_EXPR** varexprs
1514 cdef SCIP_EXPRDATA_MONOMIAL** monomials
1516 cdef SCIP_EXPRTREE* exprtree
1517 cdef SCIP_VAR** vars
1518 cdef SCIP_CONS* scip_cons
1520 terms = cons.expr.terms
1523 variables = {var.ptr():var
for term
in terms
for var
in term}
1524 variables = list(variables.values())
1525 varindex = {var.ptr():idx
for (idx,var)
in enumerate(variables)}
1528 varexprs = <SCIP_EXPR**> malloc(len(varindex) * sizeof(SCIP_EXPR*))
1529 for idx
in varindex.values():
1530 PY_SCIP_CALL( SCIPexprCreate(
SCIPblkmem(self._scip), &expr, SCIP_EXPR_VARIDX, <int>idx) )
1531 varexprs[idx] = expr
1534 monomials = <SCIP_EXPRDATA_MONOMIAL**> malloc(len(terms) * sizeof(SCIP_EXPRDATA_MONOMIAL*))
1535 for i, (term, coef)
in enumerate(terms.items()):
1536 idxs = <int*> malloc(len(term) * sizeof(int))
1537 for j, var
in enumerate(term):
1538 idxs[j] = varindex[var.ptr()]
1539 PY_SCIP_CALL( SCIPexprCreateMonomial(
SCIPblkmem(self._scip), &monomials[i], <SCIP_Real>coef, <int>len(term), idxs, NULL) )
1543 PY_SCIP_CALL( SCIPexprCreatePolynomial(
SCIPblkmem(self._scip), &expr,
1544 <int>len(varindex), varexprs,
1545 <int>len(terms), monomials, 0.0, <SCIP_Bool>
True) )
1548 PY_SCIP_CALL( SCIPexprtreeCreate(
SCIPblkmem(self._scip), &exprtree, expr, <int>len(variables), 0, NULL) )
1549 vars = <SCIP_VAR**> malloc(len(variables) * sizeof(SCIP_VAR*))
1550 for idx, var
in enumerate(variables):
1551 vars[idx] = (<Variable>var).var
1556 self._scip, &scip_cons, str_conversion(kwargs[
'name']),
1559 kwargs[
'lhs'], kwargs[
'rhs'],
1560 kwargs[
'initial'], kwargs[
'separate'], kwargs[
'enforce'],
1561 kwargs[
'check'], kwargs[
'propagate'], kwargs[
'local'],
1562 kwargs[
'modifiable'], kwargs[
'dynamic'], kwargs[
'removable'],
1563 kwargs[
'stickingatnode']) )
1565 PyCons = Constraint.create(scip_cons)
1567 PY_SCIP_CALL( SCIPexprtreeFree(&exprtree) )
1573 def _addGenNonlinearCons(self, ExprCons cons, **kwargs):
1574 cdef SCIP_EXPR** childrenexpr
1575 cdef SCIP_EXPR** scipexprs
1576 cdef SCIP_EXPRTREE* exprtree
1577 cdef SCIP_CONS* scip_cons
1582 nodes = expr_to_nodes(expr)
1583 op2idx = Operator.operatorIndexDic
1595 if op2idx[node[0]] == SCIP_EXPR_VARIDX:
1597 vars = <SCIP_VAR**> malloc(nvars * sizeof(SCIP_VAR*))
1600 scipexprs = <SCIP_EXPR**> malloc(len(nodes) * sizeof(SCIP_EXPR*))
1601 for i,node
in enumerate(nodes):
1604 if opidx == SCIP_EXPR_VARIDX:
1605 assert len(node[1]) == 1
1607 PY_SCIP_CALL( SCIPexprCreate(
SCIPblkmem(self._scip), &scipexprs[i], opidx, <int>varpos) )
1608 vars[varpos] = (<Variable>pyvar).var
1611 if opidx == SCIP_EXPR_CONST:
1612 assert len(node[1]) == 1
1614 PY_SCIP_CALL( SCIPexprCreate(
SCIPblkmem(self._scip), &scipexprs[i], opidx, <SCIP_Real>value) )
1616 if opidx == SCIP_EXPR_SUM
or opidx == SCIP_EXPR_PRODUCT:
1617 nchildren = len(node[1])
1618 childrenexpr = <SCIP_EXPR**> malloc(nchildren * sizeof(SCIP_EXPR*))
1619 for c, pos
in enumerate(node[1]):
1620 childrenexpr[c] = scipexprs[pos]
1621 PY_SCIP_CALL( SCIPexprCreate(
SCIPblkmem(self._scip), &scipexprs[i], opidx, nchildren, childrenexpr) )
1625 if opidx == SCIP_EXPR_REALPOWER:
1627 valuenode = nodes[node[1][1]]
1628 assert op2idx[valuenode[0]] == SCIP_EXPR_CONST
1629 exponent = valuenode[1][0]
1630 if float(exponent).is_integer():
1631 PY_SCIP_CALL( SCIPexprCreate(
SCIPblkmem(self._scip), &scipexprs[i], SCIP_EXPR_INTPOWER, scipexprs[node[1][0]], <int>exponent) )
1633 PY_SCIP_CALL( SCIPexprCreate(
SCIPblkmem(self._scip), &scipexprs[i], opidx, scipexprs[node[1][0]], <SCIP_Real>exponent) )
1635 if opidx == SCIP_EXPR_EXP
or opidx == SCIP_EXPR_LOG
or opidx == SCIP_EXPR_SQRT
or opidx == SCIP_EXPR_ABS:
1636 assert len(node[1]) == 1
1637 PY_SCIP_CALL( SCIPexprCreate(
SCIPblkmem(self._scip), &scipexprs[i], opidx, scipexprs[node[1][0]]) )
1640 raise NotImplementedError
1641 assert varpos == nvars
1644 PY_SCIP_CALL( SCIPexprtreeCreate(
SCIPblkmem(self._scip), &exprtree, scipexprs[len(nodes) - 1], nvars, 0, NULL) );
1649 self._scip, &scip_cons, str_conversion(kwargs[
'name']),
1652 kwargs[
'lhs'], kwargs[
'rhs'],
1653 kwargs[
'initial'], kwargs[
'separate'], kwargs[
'enforce'],
1654 kwargs[
'check'], kwargs[
'propagate'], kwargs[
'local'],
1655 kwargs[
'modifiable'], kwargs[
'dynamic'], kwargs[
'removable'],
1656 kwargs[
'stickingatnode']) )
1658 PyCons = Constraint.create(scip_cons)
1660 PY_SCIP_CALL( SCIPexprtreeFree(&exprtree) )
1669 """Add coefficient to the linear constraint (if non-zero). 1671 :param Constraint cons: constraint to be changed 1672 :param Variable var: variable to be added 1673 :param coeff: coefficient of new variable 1678 def addConsSOS1(self, vars, weights=None, name="SOS1cons",
1679 initial=
True, separate=
True, enforce=
True, check=
True,
1680 propagate=
True, local=
False, dynamic=
False,
1681 removable=
False, stickingatnode=
False):
1682 """Add an SOS1 constraint. 1684 :param vars: list of variables to be included 1685 :param weights: list of weights (Default value = None) 1686 :param name: name of the constraint (Default value = "SOS1cons") 1687 :param initial: should the LP relaxation of constraint be in the initial LP? (Default value = True) 1688 :param separate: should the constraint be separated during LP processing? (Default value = True) 1689 :param enforce: should the constraint be enforced during node processing? (Default value = True) 1690 :param check: should the constraint be checked for feasibility? (Default value = True) 1691 :param propagate: should the constraint be propagated during node processing? (Default value = True) 1692 :param local: is the constraint only valid locally? (Default value = False) 1693 :param dynamic: is the constraint subject to aging? (Default value = False) 1694 :param removable: should the relaxation be removed from the LP due to aging or cleanup? (Default value = False) 1695 :param stickingatnode: 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) 1698 cdef SCIP_CONS* scip_cons
1701 PY_SCIP_CALL(
SCIPcreateConsSOS1(self._scip, &scip_cons, str_conversion(name), 0, NULL, NULL,
1702 initial, separate, enforce, check, propagate, local, dynamic, removable, stickingatnode))
1710 for i
in range(nvars):
1711 var = <Variable>vars[i]
1712 PY_SCIP_CALL(
SCIPaddVarSOS1(self._scip, scip_cons, var.var, weights[i]))
1715 return Constraint.create(scip_cons)
1717 def addConsSOS2(self, vars, weights=None, name="SOS2cons",
1718 initial=
True, separate=
True, enforce=
True, check=
True,
1719 propagate=
True, local=
False, dynamic=
False,
1720 removable=
False, stickingatnode=
False):
1721 """Add an SOS2 constraint. 1723 :param vars: list of variables to be included 1724 :param weights: list of weights (Default value = None) 1725 :param name: name of the constraint (Default value = "SOS2cons") 1726 :param initial: should the LP relaxation of constraint be in the initial LP? (Default value = True) 1727 :param separate: should the constraint be separated during LP processing? (Default value = True) 1728 :param enforce: should the constraint be enforced during node processing? (Default value = True) 1729 :param check: should the constraint be checked for feasibility? (Default value = True) 1730 :param propagate: is the constraint only valid locally? (Default value = True) 1731 :param local: is the constraint only valid locally? (Default value = False) 1732 :param dynamic: is the constraint subject to aging? (Default value = False) 1733 :param removable: should the relaxation be removed from the LP due to aging or cleanup? (Default value = False) 1734 :param stickingatnode: 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) 1737 cdef SCIP_CONS* scip_cons
1740 PY_SCIP_CALL(
SCIPcreateConsSOS2(self._scip, &scip_cons, str_conversion(name), 0, NULL, NULL,
1741 initial, separate, enforce, check, propagate, local, dynamic, removable, stickingatnode))
1749 for i
in range(nvars):
1750 var = <Variable>vars[i]
1751 PY_SCIP_CALL(
SCIPaddVarSOS2(self._scip, scip_cons, var.var, weights[i]))
1754 return Constraint.create(scip_cons)
1756 def addConsAnd(self, vars, resvar, name="ANDcons",
1757 initial=
True, separate=
True, enforce=
True, check=
True,
1758 propagate=
True, local=
False, modifiable=
False, dynamic=
False,
1759 removable=
False, stickingatnode=
False):
1760 """Add an AND-constraint. 1761 :param vars: list of BINARY variables to be included (operators) 1762 :param resvar: BINARY variable (resultant) 1763 :param name: name of the constraint (Default value = "ANDcons") 1764 :param initial: should the LP relaxation of constraint be in the initial LP? (Default value = True) 1765 :param separate: should the constraint be separated during LP processing? (Default value = True) 1766 :param enforce: should the constraint be enforced during node processing? (Default value = True) 1767 :param check: should the constraint be checked for feasibility? (Default value = True) 1768 :param propagate: should the constraint be propagated during node processing? (Default value = True) 1769 :param local: is the constraint only valid locally? (Default value = False) 1770 :param modifiable: is the constraint modifiable (subject to column generation)? (Default value = False) 1771 :param dynamic: is the constraint subject to aging? (Default value = False) 1772 :param removable: should the relaxation be removed from the LP due to aging or cleanup? (Default value = False) 1773 :param stickingatnode: 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) 1775 cdef SCIP_CONS* scip_cons
1779 _vars = <SCIP_VAR**> malloc(len(vars) * sizeof(SCIP_VAR*))
1780 for idx, var
in enumerate(vars):
1781 _vars[idx] = (<Variable>var).var
1782 _resVar = (<Variable>resvar).var
1784 PY_SCIP_CALL(
SCIPcreateConsAnd(self._scip, &scip_cons, str_conversion(name), _resVar, nvars, _vars,
1785 initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode))
1788 pyCons = Constraint.create(scip_cons)
1795 def addConsOr(self, vars, resvar, name="ORcons",
1796 initial=
True, separate=
True, enforce=
True, check=
True,
1797 propagate=
True, local=
False, modifiable=
False, dynamic=
False,
1798 removable=
False, stickingatnode=
False):
1799 """Add an OR-constraint. 1800 :param vars: list of BINARY variables to be included (operators) 1801 :param resvar: BINARY variable (resultant) 1802 :param name: name of the constraint (Default value = "ORcons") 1803 :param initial: should the LP relaxation of constraint be in the initial LP? (Default value = True) 1804 :param separate: should the constraint be separated during LP processing? (Default value = True) 1805 :param enforce: should the constraint be enforced during node processing? (Default value = True) 1806 :param check: should the constraint be checked for feasibility? (Default value = True) 1807 :param propagate: should the constraint be propagated during node processing? (Default value = True) 1808 :param local: is the constraint only valid locally? (Default value = False) 1809 :param modifiable: is the constraint modifiable (subject to column generation)? (Default value = False) 1810 :param dynamic: is the constraint subject to aging? (Default value = False) 1811 :param removable: should the relaxation be removed from the LP due to aging or cleanup? (Default value = False) 1812 :param stickingatnode: 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) 1814 cdef SCIP_CONS* scip_cons
1818 _vars = <SCIP_VAR**> malloc(len(vars) * sizeof(SCIP_VAR*))
1819 for idx, var
in enumerate(vars):
1820 _vars[idx] = (<Variable>var).var
1821 _resVar = (<Variable>resvar).var
1823 PY_SCIP_CALL(
SCIPcreateConsOr(self._scip, &scip_cons, str_conversion(name), _resVar, nvars, _vars,
1824 initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode))
1827 pyCons = Constraint.create(scip_cons)
1834 def addConsXor(self, vars, rhsvar, name="XORcons",
1835 initial=
True, separate=
True, enforce=
True, check=
True,
1836 propagate=
True, local=
False, modifiable=
False, dynamic=
False,
1837 removable=
False, stickingatnode=
False):
1838 """Add a XOR-constraint. 1839 :param vars: list of BINARY variables to be included (operators) 1840 :param rhsvar: BOOLEAN value, explicit True, False or bool(obj) is needed (right-hand side) 1841 :param name: name of the constraint (Default value = "XORcons") 1842 :param initial: should the LP relaxation of constraint be in the initial LP? (Default value = True) 1843 :param separate: should the constraint be separated during LP processing? (Default value = True) 1844 :param enforce: should the constraint be enforced during node processing? (Default value = True) 1845 :param check: should the constraint be checked for feasibility? (Default value = True) 1846 :param propagate: should the constraint be propagated during node processing? (Default value = True) 1847 :param local: is the constraint only valid locally? (Default value = False) 1848 :param modifiable: is the constraint modifiable (subject to column generation)? (Default value = False) 1849 :param dynamic: is the constraint subject to aging? (Default value = False) 1850 :param removable: should the relaxation be removed from the LP due to aging or cleanup? (Default value = False) 1851 :param stickingatnode: 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) 1853 cdef SCIP_CONS* scip_cons
1857 assert type(rhsvar)
is type(bool()),
"Provide BOOLEAN value as rhsvar, you gave %s." % type(rhsvar)
1858 _vars = <SCIP_VAR**> malloc(len(vars) * sizeof(SCIP_VAR*))
1859 for idx, var
in enumerate(vars):
1860 _vars[idx] = (<Variable>var).var
1862 PY_SCIP_CALL(
SCIPcreateConsXor(self._scip, &scip_cons, str_conversion(name), rhsvar, nvars, _vars,
1863 initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode))
1866 pyCons = Constraint.create(scip_cons)
1873 def addConsCardinality(self, consvars, cardval, indvars=None, weights=None, name="CardinalityCons",
1874 initial=
True, separate=
True, enforce=
True, check=
True,
1875 propagate=
True, local=
False, dynamic=
False,
1876 removable=
False, stickingatnode=
False):
1877 """Add a cardinality constraint that allows at most 'cardval' many nonzero variables. 1879 :param consvars: list of variables to be included 1880 :param cardval: nonnegative integer 1881 :param indvars: 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) 1882 :param weights: 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) 1883 :param name: name of the constraint (Default value = "CardinalityCons") 1884 :param initial: should the LP relaxation of constraint be in the initial LP? (Default value = True) 1885 :param separate: should the constraint be separated during LP processing? (Default value = True) 1886 :param enforce: should the constraint be enforced during node processing? (Default value = True) 1887 :param check: should the constraint be checked for feasibility? (Default value = True) 1888 :param propagate: should the constraint be propagated during node processing? (Default value = True) 1889 :param local: is the constraint only valid locally? (Default value = False) 1890 :param dynamic: is the constraint subject to aging? (Default value = False) 1891 :param removable: should the relaxation be removed from the LP due to aging or cleanup? (Default value = False) 1892 :param stickingatnode: 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) 1895 cdef SCIP_CONS* scip_cons
1896 cdef SCIP_VAR* indvar
1899 initial, separate, enforce, check, propagate, local, dynamic, removable, stickingatnode))
1903 weights = list(range(1, len(consvars) + 1))
1905 for i, v
in enumerate(consvars):
1908 indvar = (<Variable>indvars[i]).var
1917 pyCons = Constraint.create(scip_cons)
1925 initial=
True, separate=
True, enforce=
True, check=
True,
1926 propagate=
True, local=
False, dynamic=
False,
1927 removable=
False, stickingatnode=
False):
1928 """Add an indicator constraint for the linear inequality 'cons'. 1930 The 'binvar' argument models the redundancy of the linear constraint. A solution for which 1931 'binvar' is 1 must satisfy the constraint. 1933 :param cons: a linear inequality of the form "<=" 1934 :param binvar: binary indicator variable, or None if it should be created (Default value = None) 1935 :param name: name of the constraint (Default value = "IndicatorCons") 1936 :param initial: should the LP relaxation of constraint be in the initial LP? (Default value = True) 1937 :param separate: should the constraint be separated during LP processing? (Default value = True) 1938 :param enforce: should the constraint be enforced during node processing? (Default value = True) 1939 :param check: should the constraint be checked for feasibility? (Default value = True) 1940 :param propagate: should the constraint be propagated during node processing? (Default value = True) 1941 :param local: is the constraint only valid locally? (Default value = False) 1942 :param dynamic: is the constraint subject to aging? (Default value = False) 1943 :param removable: should the relaxation be removed from the LP due to aging or cleanup? (Default value = False) 1944 :param stickingatnode: 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) 1947 assert isinstance(cons, ExprCons),
"given constraint is not ExprCons but %s" % cons.__class__.__name__
1948 cdef SCIP_CONS* scip_cons
1949 cdef SCIP_VAR* _binVar
1950 if cons.lhs
is not None and cons.rhs
is not None:
1951 raise ValueError(
"expected inequality that has either only a left or right hand side")
1953 if cons.expr.degree() > 1:
1954 raise ValueError(
"expected linear inequality, expression has degree %d" % cons.expr.degree())
1957 if cons.rhs
is not None:
1964 _binVar = (<Variable>binvar).var
if binvar
is not None else NULL
1966 PY_SCIP_CALL(
SCIPcreateConsIndicator(self._scip, &scip_cons, str_conversion(name), _binVar, 0, NULL, NULL, rhs,
1967 initial, separate, enforce, check, propagate, local, dynamic, removable, stickingatnode))
1968 terms = cons.expr.terms
1970 for key, coeff
in terms.items():
1971 var = <Variable>key[0]
1977 pyCons = Constraint.create(scip_cons)
1984 """Adds a customly created cons. 1986 :param Constraint cons: constraint to add 1993 """Add variable to SOS1 constraint. 1995 :param Constraint cons: SOS1 constraint 1996 :param Variable var: new variable 1997 :param weight: weight of new variable 2000 PY_SCIP_CALL(
SCIPaddVarSOS1(self._scip, cons.cons, var.var, weight))
2003 """Append variable to SOS1 constraint. 2005 :param Constraint cons: SOS1 constraint 2006 :param Variable var: variable to append 2012 """Add variable to SOS2 constraint. 2014 :param Constraint cons: SOS2 constraint 2015 :param Variable var: new variable 2016 :param weight: weight of new variable 2019 PY_SCIP_CALL(
SCIPaddVarSOS2(self._scip, cons.cons, var.var, weight))
2022 """Append variable to SOS2 constraint. 2024 :param Constraint cons: SOS2 constraint 2025 :param Variable var: variable to append 2031 """Set "initial" flag of a constraint. 2035 newInit -- new initial value 2040 """Set "removable" flag of a constraint. 2044 newRem -- new removable value 2049 """Set "enforced" flag of a constraint. 2053 newEnf -- new enforced value 2058 """Set "check" flag of a constraint. 2062 newCheck -- new check value 2067 """Change right hand side value of a constraint. 2069 :param Constraint cons: linear or quadratic constraint 2070 :param rhs: new ride hand side (set to None for +infinity) 2078 if constype ==
'linear':
2080 elif constype ==
'quadratic':
2083 raise Warning(
"method cannot be called for constraints of type " + constype)
2086 """Change left hand side value of a constraint. 2088 :param Constraint cons: linear or quadratic constraint 2089 :param lhs: new left hand side (set to None for -infinity) 2097 if constype ==
'linear':
2099 elif constype ==
'quadratic':
2102 raise Warning(
"method cannot be called for constraints of type " + constype)
2105 """Retrieve right hand side value of a constraint. 2107 :param Constraint cons: linear or quadratic constraint 2111 if constype ==
'linear':
2113 elif constype ==
'quadratic':
2116 raise Warning(
"method cannot be called for constraints of type " + constype)
2119 """Retrieve left hand side value of a constraint. 2121 :param Constraint cons: linear or quadratic constraint 2125 if constype ==
'linear':
2127 elif constype ==
'quadratic':
2130 raise Warning(
"method cannot be called for constraints of type " + constype)
2133 """Retrieve activity of given constraint. 2134 Can only be called after solving is completed. 2136 :param Constraint cons: linear or quadratic constraint 2137 :param Solution sol: solution to compute activity of, None to use current node's solution (Default value = None) 2140 cdef SCIP_Real activity
2141 cdef SCIP_SOL* scip_sol
2143 if not self.
getStage() >= SCIP_STAGE_SOLVING:
2144 raise Warning(
"method cannot be called before problem is solved")
2146 if isinstance(sol, Solution):
2152 if constype ==
'linear':
2154 elif constype ==
'quadratic':
2157 raise Warning(
"method cannot be called for constraints of type " + constype)
2162 def getSlack(self, Constraint cons, Solution sol = None, side = None):
2163 """Retrieve slack of given constraint. 2164 Can only be called after solving is completed. 2167 :param Constraint cons: linear or quadratic constraint 2168 :param Solution sol: solution to compute slack of, None to use current node's solution (Default value = None) 2169 :param side: whether to use 'lhs' or 'rhs' for ranged constraints, None to return minimum (Default value = None) 2172 cdef SCIP_Real activity
2173 cdef SCIP_SOL* scip_sol
2176 if not self.
getStage() >= SCIP_STAGE_SOLVING:
2177 raise Warning(
"method cannot be called before problem is solved")
2179 if isinstance(sol, Solution):
2185 if constype ==
'linear':
2189 elif constype ==
'quadratic':
2194 raise Warning(
"method cannot be called for constraints of type " + constype)
2196 lhsslack = activity - lhs
2197 rhsslack = rhs - activity
2204 return min(lhsslack, rhsslack)
2207 """Retrieve transformed constraint. 2209 :param Constraint cons: constraint 2212 cdef SCIP_CONS* transcons
2214 return Constraint.create(transcons)
2217 """Retrieve bilinear, quadratic, and linear terms of a quadratic constraint. 2219 :param Constraint cons: constraint 2222 cdef SCIP_QUADVARTERM* _quadterms
2223 cdef SCIP_BILINTERM* _bilinterms
2224 cdef SCIP_VAR** _linvars
2225 cdef SCIP_Real* _lincoefs
2226 cdef int _nbilinterms
2227 cdef int _nquadterms
2230 assert cons.isQuadratic(),
"constraint is not quadratic" 2240 for i
in range(_nbilinterms):
2241 var1 = Variable.create(_bilinterms[i].var1)
2242 var2 = Variable.create(_bilinterms[i].var2)
2243 bilinterms.append((var1,var2,_bilinterms[i].coef))
2249 for i
in range(_nquadterms):
2250 var = Variable.create(_quadterms[i].var)
2251 quadterms.append((var,_quadterms[i].sqrcoef,_quadterms[i].lincoef))
2258 for i
in range(_nlinvars):
2259 var = Variable.create(_linvars[i])
2260 linterms.append((var,_lincoefs[i]))
2262 return (bilinterms, quadterms, linterms)
2265 """sets the value of the given variable in the global relaxation solution""" 2269 """Retrieve all constraints.""" 2270 cdef SCIP_CONS** _conss
2276 return [Constraint.create(_conss[i])
for i
in range(_nconss)]
2279 """Retrieve number of all constraints""" 2283 """Delete constraint from the model 2285 :param Constraint cons: constraint to be deleted 2291 """Delete constraint from the current node and it's children 2293 :param Constraint cons: constraint to be deleted 2299 """Retrieve the coefficients of a linear constraint 2301 :param Constraint cons: linear constraint to get the coefficients of 2304 cdef SCIP_Real* _vals
2305 cdef SCIP_VAR** _vars
2308 if not constype ==
'linear':
2309 raise Warning(
"coefficients not available for constraints of type ", constype)
2316 valsdict[bytes(
SCIPvarGetName(_vars[i])).decode(
'utf-8')] = _vals[i]
2320 """Retrieve the dual multiplier to a linear constraint. 2322 :param Constraint cons: linear constraint 2326 if not constype ==
'linear':
2327 raise Warning(
"dual solution values not available for constraints of type ", constype)
2328 if cons.isOriginal():
2335 """Retrieve the dual solution to a linear constraint. 2337 :param Constraint cons: linear constraint 2340 cdef SCIP_Real dualsolval
2341 cdef SCIP_Bool boundconstraint
2343 cdef SCIP_VAR** _vars
2344 cdef SCIP_Real* _vals
2345 cdef SCIP_Bool _success
2348 PY_SCIP_CALL(
SCIPgetDualSolVal(self._scip, cons.cons, &dualsolval, &boundconstraint) )
2354 if not constype ==
'linear':
2355 raise Warning(
"dual solution values not available for constraints of type ", constype)
2359 if cons.isOriginal():
2364 if dual == 0.0
and _nvars == 1:
2370 if (activity == rhs)
or (activity == lhs):
2376 raise Warning(
"no dual solution available for constraint " + cons.name)
2380 """Retrieve the dual farkas value to a linear constraint. 2382 :param Constraint cons: linear constraint 2386 if cons.isOriginal():
2393 """Retrieve the reduced cost of a variable. 2395 :param Variable var: variable to get the reduced cost of 2404 raise Warning(
"no reduced cost available for variable " + var.name)
2408 """Optimize the problem.""" 2413 """Presolve the problem.""" 2418 """initialises the default Benders' decomposition with a dictionary of subproblems 2421 subproblems -- a single Model instance or dictionary of Model instances 2423 cdef SCIP** subprobs
2424 cdef SCIP_BENDERS* benders
2427 if isinstance(subproblems, dict):
2429 nsubproblems = len(subproblems)
2435 subprobs = <SCIP**> malloc(nsubproblems * sizeof(SCIP*))
2439 for idx, subprob
in enumerate(subproblems.values()):
2440 subprobs[idx] = (<Model>subprob)._scip
2442 subprobs[0] = (<Model>subproblems)._scip
2449 self.
setBoolParam(
"constraints/benderslp/active",
True)
2454 """Solves the subproblems with the best solution to the master problem. 2455 Afterwards, the best solution from each subproblem can be queried to get 2456 the solution to the original problem. 2458 If the user wants to resolve the subproblems, they must free them by 2459 calling freeBendersSubproblems() 2461 cdef SCIP_BENDERS** _benders
2462 cdef SCIP_Bool _infeasible
2464 cdef int nsubproblems
2472 for i
in range(nbenders):
2474 for j
in range(nsubproblems):
2476 _benders[i], self._bestSol.sol, j))
2478 _benders[i], self._bestSol.sol, j, &_infeasible,
2479 SCIP_BENDERSENFOTYPE_CHECK, solvecip, NULL))
2482 """Calls the free subproblem function for the Benders' decomposition. 2483 This will free all subproblems for all decompositions. 2485 cdef SCIP_BENDERS** _benders
2487 cdef int nsubproblems
2493 for i
in range(nbenders):
2495 for j
in range(nsubproblems):
2500 """"updates the subproblem lower bounds for benders using 2501 the lowerbounds dict. If benders is None, then the default 2502 Benders' decomposition is updated 2504 cdef SCIP_BENDERS* _benders
2506 assert type(lowerbounds)
is dict
2511 n = str_conversion(benders.name)
2514 for d
in lowerbounds.keys():
2518 """Activates the Benders' decomposition plugin with the input name 2521 name -- the name of the Benders' decomposition plugin 2522 nsubproblems -- the number of subproblems in the Benders' decomposition 2524 n = str_conversion(name)
2525 cdef SCIP_BENDERS* benders
2530 """adds a subproblem to the Benders' decomposition given by the input 2534 name -- the Benders' decomposition that the subproblem is added to 2535 subproblem -- the subproblem to add to the decomposition 2537 cdef SCIP_BENDERS* benders
2538 n = str_conversion(name)
2543 """Returns the variable for the subproblem or master problem 2544 depending on the input probnumber 2547 var -- the source variable for which the target variable is requested 2548 benders -- the Benders' decomposition to which the subproblem variables belong to 2549 probnumber -- the problem number for which the target variable belongs, -1 for master problem 2551 cdef SCIP_BENDERS* _benders
2552 cdef SCIP_VAR* _mappedvar
2557 n = str_conversion(benders.name)
2560 if probnumber == -1:
2565 if _mappedvar == NULL:
2568 mappedvar = Variable.create(_mappedvar)
2574 """Include an event handler. 2577 eventhdlr -- event handler 2578 name -- name of event handler 2579 desc -- description of event handler 2581 n = str_conversion(name)
2582 d = str_conversion(desc)
2592 <SCIP_EVENTHDLRDATA*>eventhdlr))
2593 eventhdlr.model = <Model>weakref.proxy(self)
2594 eventhdlr.name = name
2595 Py_INCREF(eventhdlr)
2598 """Include a pricer. 2600 :param Pricer pricer: pricer 2601 :param name: name of pricer 2602 :param desc: description of pricer 2603 :param priority: priority of pricer (Default value = 1) 2604 :param delay: should the pricer be delayed until no other pricers or already existing problem variables with negative reduced costs are found? (Default value = True) 2607 n = str_conversion(name)
2608 d = str_conversion(desc)
2611 PyPricerCopy, PyPricerFree, PyPricerInit, PyPricerExit, PyPricerInitsol, PyPricerExitsol, PyPricerRedcost, PyPricerFarkas,
2612 <SCIP_PRICERDATA*>pricer))
2613 cdef SCIP_PRICER* scip_pricer
2616 pricer.model = <Model>weakref.proxy(self)
2619 def includeConshdlr(self, Conshdlr conshdlr, name, desc, sepapriority=0,
2620 enfopriority=0, chckpriority=0, sepafreq=-1, propfreq=-1,
2621 eagerfreq=100, maxprerounds=-1, delaysepa=
False,
2622 delayprop=
False, needscons=
True,
2623 proptiming=PY_SCIP_PROPTIMING.BEFORELP,
2624 presoltiming=PY_SCIP_PRESOLTIMING.MEDIUM):
2625 """Include a constraint handler 2627 :param Conshdlr conshdlr: constraint handler 2628 :param name: name of constraint handler 2629 :param desc: description of constraint handler 2630 :param sepapriority: priority for separation (Default value = 0) 2631 :param enfopriority: priority for constraint enforcing (Default value = 0) 2632 :param chckpriority: priority for checking feasibility (Default value = 0) 2633 :param sepafreq: frequency for separating cuts; 0 = only at root node (Default value = -1) 2634 :param propfreq: frequency for propagating domains; 0 = only preprocessing propagation (Default value = -1) 2635 :param eagerfreq: 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) 2636 :param maxprerounds: maximal number of presolving rounds the constraint handler participates in (Default value = -1) 2637 :param delaysepa: should separation method be delayed, if other separators found cuts? (Default value = False) 2638 :param delayprop: should propagation method be delayed, if other propagators found reductions? (Default value = False) 2639 :param needscons: should the constraint handler be skipped, if no constraints are available? (Default value = True) 2640 :param proptiming: positions in the node solving loop where propagation method of constraint handlers should be executed (Default value = SCIP_PROPTIMING.BEFORELP) 2641 :param presoltiming: timing mask of the constraint handler's presolving method (Default value = SCIP_PRESOLTIMING.MEDIUM) 2644 n = str_conversion(name)
2645 d = str_conversion(desc)
2646 PY_SCIP_CALL(
SCIPincludeConshdlr(self._scip, n, d, sepapriority, enfopriority, chckpriority, sepafreq, propfreq, eagerfreq,
2647 maxprerounds, delaysepa, delayprop, needscons, proptiming, presoltiming,
2648 PyConshdlrCopy, PyConsFree, PyConsInit, PyConsExit, PyConsInitpre, PyConsExitpre,
2649 PyConsInitsol, PyConsExitsol, PyConsDelete, PyConsTrans, PyConsInitlp, PyConsSepalp, PyConsSepasol,
2650 PyConsEnfolp, PyConsEnforelax, PyConsEnfops, PyConsCheck, PyConsProp, PyConsPresol, PyConsResprop, PyConsLock,
2651 PyConsActive, PyConsDeactive, PyConsEnable, PyConsDisable, PyConsDelvars, PyConsPrint, PyConsCopy,
2652 PyConsParse, PyConsGetvars, PyConsGetnvars, PyConsGetdivebdchgs,
2653 <SCIP_CONSHDLRDATA*>conshdlr))
2654 conshdlr.model = <Model>weakref.proxy(self)
2655 conshdlr.name = name
2658 def createCons(self, Conshdlr conshdlr, name, initial=True, separate=True, enforce=True, check=True, propagate=True,
2659 local=
False, modifiable=
False, dynamic=
False, removable=
False, stickingatnode=
False):
2660 """Create a constraint of a custom constraint handler 2662 :param Conshdlr conshdlr: constraint handler 2663 :param name: name of constraint 2664 :param initial: (Default value = True) 2665 :param separate: (Default value = True) 2666 :param enforce: (Default value = True) 2667 :param check: (Default value = True) 2668 :param propagate: (Default value = True) 2669 :param local: (Default value = False) 2670 :param modifiable: (Default value = False) 2671 :param dynamic: (Default value = False) 2672 :param removable: (Default value = False) 2673 :param stickingatnode: (Default value = False) 2677 n = str_conversion(name)
2678 cdef SCIP_CONSHDLR* scip_conshdlr
2679 scip_conshdlr =
SCIPfindConshdlr(self._scip, str_conversion(conshdlr.name))
2681 PY_SCIP_CALL(
SCIPcreateCons(self._scip, &(constraint.cons), n, scip_conshdlr, <SCIP_CONSDATA*>constraint,
2682 initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode))
2685 def includePresol(self, Presol presol, name, desc, priority, maxrounds, timing=SCIP_PRESOLTIMING_FAST):
2686 """Include a presolver 2688 :param Presol presol: presolver 2689 :param name: name of presolver 2690 :param desc: description of presolver 2691 :param priority: priority of the presolver (>= 0: before, < 0: after constraint handlers) 2692 :param maxrounds: maximal number of presolving rounds the presolver participates in (-1: no limit) 2693 :param timing: timing mask of presolver (Default value = SCIP_PRESOLTIMING_FAST) 2696 n = str_conversion(name)
2697 d = str_conversion(desc)
2698 PY_SCIP_CALL(
SCIPincludePresol(self._scip, n, d, priority, maxrounds, timing, PyPresolCopy, PyPresolFree, PyPresolInit,
2699 PyPresolExit, PyPresolInitpre, PyPresolExitpre, PyPresolExec, <SCIP_PRESOLDATA*>presol))
2700 presol.model = <Model>weakref.proxy(self)
2703 def includeSepa(self, Sepa sepa, name, desc, priority=0, freq=10, maxbounddist=1.0, usessubscip=False, delay=False):
2704 """Include a separator 2706 :param Sepa sepa: separator 2707 :param name: name of separator 2708 :param desc: description of separator 2709 :param priority: priority of separator (>= 0: before, < 0: after constraint handlers) 2710 :param freq: frequency for calling separator 2711 :param maxbounddist: maximal relative distance from current node's dual bound to primal bound compared to best node's dual bound for applying separation 2712 :param usessubscip: does the separator use a secondary SCIP instance? (Default value = False) 2713 :param delay: should separator be delayed, if other separators found cuts? (Default value = False) 2716 n = str_conversion(name)
2717 d = str_conversion(desc)
2718 PY_SCIP_CALL(
SCIPincludeSepa(self._scip, n, d, priority, freq, maxbounddist, usessubscip, delay, PySepaCopy, PySepaFree,
2719 PySepaInit, PySepaExit, PySepaInitsol, PySepaExitsol, PySepaExeclp, PySepaExecsol, <SCIP_SEPADATA*>sepa))
2720 sepa.model = <Model>weakref.proxy(self)
2724 def includeProp(self, Prop prop, name, desc, presolpriority, presolmaxrounds,
2725 proptiming, presoltiming=SCIP_PRESOLTIMING_FAST, priority=1, freq=1, delay=
True):
2726 """Include a propagator. 2728 :param Prop prop: propagator 2729 :param name: name of propagator 2730 :param desc: description of propagator 2731 :param presolpriority: presolving priority of the propgator (>= 0: before, < 0: after constraint handlers) 2732 :param presolmaxrounds: maximal number of presolving rounds the propagator participates in (-1: no limit) 2733 :param proptiming: positions in the node solving loop where propagation method of constraint handlers should be executed 2734 :param presoltiming: timing mask of the constraint handler's presolving method (Default value = SCIP_PRESOLTIMING_FAST) 2735 :param priority: priority of the propagator (Default value = 1) 2736 :param freq: frequency for calling propagator (Default value = 1) 2737 :param delay: should propagator be delayed if other propagators have found reductions? (Default value = True) 2740 n = str_conversion(name)
2741 d = str_conversion(desc)
2743 priority, freq, delay,
2744 proptiming, presolpriority, presolmaxrounds,
2745 presoltiming, PyPropCopy, PyPropFree, PyPropInit, PyPropExit,
2746 PyPropInitpre, PyPropExitpre, PyPropInitsol, PyPropExitsol,
2747 PyPropPresol, PyPropExec, PyPropResProp,
2748 <SCIP_PROPDATA*> prop))
2749 prop.model = <Model>weakref.proxy(self)
2752 def includeHeur(self, Heur heur, name, desc, dispchar, priority=10000, freq=1, freqofs=0,
2753 maxdepth=-1, timingmask=SCIP_HEURTIMING_BEFORENODE, usessubscip=
False):
2754 """Include a primal heuristic. 2756 :param Heur heur: heuristic 2757 :param name: name of heuristic 2758 :param desc: description of heuristic 2759 :param dispchar: display character of heuristic 2760 :param priority: priority of the heuristic (Default value = 10000) 2761 :param freq: frequency for calling heuristic (Default value = 1) 2762 :param freqofs: frequency offset for calling heuristic (Default value = 0) 2763 :param maxdepth: maximal depth level to call heuristic at (Default value = -1) 2764 :param timingmask: positions in the node solving loop where heuristic should be executed (Default value = SCIP_HEURTIMING_BEFORENODE) 2765 :param usessubscip: does the heuristic use a secondary SCIP instance? (Default value = False) 2768 nam = str_conversion(name)
2769 des = str_conversion(desc)
2770 dis = ord(str_conversion(dispchar))
2772 priority, freq, freqofs,
2773 maxdepth, timingmask, usessubscip,
2774 PyHeurCopy, PyHeurFree, PyHeurInit, PyHeurExit,
2775 PyHeurInitsol, PyHeurExitsol, PyHeurExec,
2776 <SCIP_HEURDATA*> heur))
2777 heur.model = <Model>weakref.proxy(self)
2782 """Include a relaxation handler. 2784 :param Relax relax: relaxation handler 2785 :param name: name of relaxation handler 2786 :param desc: description of relaxation handler 2787 :param priority: priority of the relaxation handler (negative: after LP, non-negative: before LP, Default value = 10000) 2788 :param freq: frequency for calling relaxation handler 2791 nam = str_conversion(name)
2792 des = str_conversion(desc)
2793 PY_SCIP_CALL(
SCIPincludeRelax(self._scip, nam, des, priority, freq, PyRelaxCopy, PyRelaxFree, PyRelaxInit, PyRelaxExit,
2794 PyRelaxInitsol, PyRelaxExitsol, PyRelaxExec, <SCIP_RELAXDATA*> relax))
2795 relax.model = <Model>weakref.proxy(self)
2801 """Include a branching rule. 2803 :param Branchrule branchrule: branching rule 2804 :param name: name of branching rule 2805 :param desc: description of branching rule 2806 :param priority: priority of branching rule 2807 :param maxdepth: maximal depth level up to which this branching rule should be used (or -1) 2808 :param maxbounddist: 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) 2811 nam = str_conversion(name)
2812 des = str_conversion(desc)
2814 priority, maxdepth, maxbounddist,
2815 PyBranchruleCopy, PyBranchruleFree, PyBranchruleInit, PyBranchruleExit,
2816 PyBranchruleInitsol, PyBranchruleExitsol, PyBranchruleExeclp, PyBranchruleExecext,
2817 PyBranchruleExecps, <SCIP_BRANCHRULEDATA*> branchrule))
2818 branchrule.model = <Model>weakref.proxy(self)
2819 Py_INCREF(branchrule)
2821 def includeBenders(self, Benders benders, name, desc, priority=1, cutlp=True, cutpseudo=True, cutrelax=True,
2823 """Include a Benders' decomposition. 2826 benders -- the Benders decomposition 2828 desc -- the description 2829 priority -- priority of the Benders' decomposition 2830 cutlp -- should Benders' cuts be generated from LP solutions 2831 cutpseudo -- should Benders' cuts be generated from pseudo solutions 2832 cutrelax -- should Benders' cuts be generated from relaxation solutions 2833 shareaux -- should the Benders' decomposition share the auxiliary variables of the highest priority Benders' decomposition 2835 n = str_conversion(name)
2836 d = str_conversion(desc)
2838 priority, cutlp, cutrelax, cutpseudo, shareaux,
2839 PyBendersCopy, PyBendersFree, PyBendersInit, PyBendersExit, PyBendersInitpre,
2840 PyBendersExitpre, PyBendersInitsol, PyBendersExitsol, PyBendersGetvar,
2841 PyBendersCreatesub, PyBendersPresubsolve, PyBendersSolvesubconvex,
2842 PyBendersSolvesub, PyBendersPostsolve, PyBendersFreesub,
2843 <SCIP_BENDERSDATA*>benders))
2844 cdef SCIP_BENDERS* scip_benders
2846 benders.model = <Model>weakref.proxy(self)
2852 """gets branching candidates for LP solution branching (fractional variables) along with solution values, 2853 fractionalities, and number of branching candidates; The number of branching candidates does NOT account 2854 for fractional implicit integer variables which should not be used for branching decisions. Fractional 2855 implicit integer variables are stored at the positions *nlpcands to *nlpcands + *nfracimplvars - 1 2856 branching rules should always select the branching candidate among the first npriolpcands of the candidate list 2858 :return tuple (lpcands, lpcandssol, lpcadsfrac, nlpcands, npriolpcands, nfracimplvars) where 2860 lpcands: list of variables of LP branching candidates 2861 lpcandssol: list of LP candidate solution values 2862 lpcandsfrac list of LP candidate fractionalities 2863 nlpcands: number of LP branching candidates 2864 npriolpcands: number of candidates with maximal priority 2865 nfracimplvars: number of fractional implicit integer variables 2870 cdef int npriolpcands
2871 cdef int nfracimplvars
2874 cdef SCIP_VAR** lpcands = <SCIP_VAR**> malloc(ncands * sizeof(SCIP_VAR*))
2875 cdef SCIP_Real* lpcandssol = <SCIP_Real*> malloc(ncands * sizeof(SCIP_Real))
2876 cdef SCIP_Real* lpcandsfrac = <SCIP_Real*> malloc(ncands * sizeof(SCIP_Real))
2879 &nlpcands, &npriolpcands, &nfracimplvars))
2881 return ([Variable.create(lpcands[i])
for i
in range(ncands)], [lpcandssol[i]
for i
in range(ncands)],
2882 [lpcandsfrac[i]
for i
in range(ncands)], nlpcands, npriolpcands, nfracimplvars)
2886 """Branch on a non-continuous variable. 2888 :param variable: Variable to branch on 2889 :return: tuple(downchild, eqchild, upchild) of Nodes of the left, middle and right child. 2892 cdef SCIP_NODE* downchild = <SCIP_NODE*> malloc(sizeof(SCIP_NODE))
2893 cdef SCIP_NODE* eqchild = <SCIP_NODE*> malloc(sizeof(SCIP_NODE))
2894 cdef SCIP_NODE* upchild = <SCIP_NODE*> malloc(sizeof(SCIP_NODE))
2896 PY_SCIP_CALL(
SCIPbranchVar(self._scip, (<Variable>variable).var, &downchild, &eqchild, &upchild))
2897 return Node.create(downchild), Node.create(eqchild), Node.create(upchild)
2901 """Branches on variable using a value which separates the domain of the variable. 2903 :param variable: Variable to branch on 2904 :param value: float, value to branch on 2905 :return: tuple(downchild, eqchild, upchild) of Nodes of the left, middle and right child. Middle child only exists 2906 if branch variable is integer 2909 cdef SCIP_NODE* downchild = <SCIP_NODE*> malloc(sizeof(SCIP_NODE))
2910 cdef SCIP_NODE* eqchild = <SCIP_NODE*> malloc(sizeof(SCIP_NODE))
2911 cdef SCIP_NODE* upchild = <SCIP_NODE*> malloc(sizeof(SCIP_NODE))
2913 PY_SCIP_CALL(
SCIPbranchVarVal(self._scip, (<Variable>variable).var, value, &downchild, &eqchild, &upchild))
2915 return Node.create(downchild), Node.create(eqchild), Node.create(upchild)
2918 """calculates the node selection priority for moving the given variable's LP value 2919 to the given target value; 2920 this node selection priority can be given to the SCIPcreateChild() call 2922 :param variable: variable on which the branching is applied 2923 :param branchdir: type of branching that was performed 2924 :param targetvalue: new value of the variable in the child node 2925 :return: node selection priority for moving the given variable's LP value to the given target value 2931 """Calculates an estimate for the objective of the best feasible solution 2932 contained in the subtree after applying the given branching; 2933 this estimate can be given to the SCIPcreateChild() call 2935 :param variable: Variable to compute the estimate for 2936 :param targetvalue: new value of the variable in the child node 2937 :return: objective estimate of the best solution in the subtree after applying the given branching 2943 """Create a child node of the focus node. 2945 :param nodeselprio: float, node selection priority of new node 2946 :param estimate: float, estimate for(transformed) objective value of best feasible solution in subtree 2947 :return: Node, the child which was created 2950 cdef SCIP_NODE* child = <SCIP_NODE*> malloc(sizeof(SCIP_NODE))
2951 PY_SCIP_CALL(
SCIPcreateChild(self._scip, &child, nodeselprio, estimate))
2952 return Node.create(child)
2956 """Initiates LP diving 2957 It allows the user to change the LP in several ways, solve, change again, etc, without affecting the actual LP that has. When endDive() is called, 2958 SCIP will undo all changes done and recover the LP it had before startDive 2963 """Quits probing and resets bounds and constraints to the focus node's environment""" 2967 """changes (column) variable's objective value in current dive""" 2971 """changes variable's current lb in current dive""" 2975 """changes variable's current ub in current dive""" 2979 """returns variable's current lb in current dive""" 2983 """returns variable's current ub in current dive""" 2987 """changes row lhs in current dive, change will be undone after diving 2988 ends, for permanent changes use SCIPchgRowLhs() 2993 """changes row rhs in current dive, change will be undone after diving 2994 ends, for permanent changes use SCIPchgRowLhs() 2999 """adds a row to the LP in current dive""" 3003 """solves the LP of the current dive no separation or pricing is applied 3004 no separation or pricing is applied 3005 :param itlim: maximal number of LP iterations to perform (Default value = -1, that is, no limit) 3006 returns two booleans: 3007 lperror -- if an unresolved lp error occured 3008 cutoff -- whether the LP was infeasible or the objective limit was reached 3010 cdef SCIP_Bool lperror
3011 cdef SCIP_Bool cutoff
3014 return lperror, cutoff
3017 """returns if the current node is already solved and only propagated again.""" 3022 """Initiates probing, making methods SCIPnewProbingNode(), SCIPbacktrackProbing(), SCIPchgVarLbProbing(), 3023 SCIPchgVarUbProbing(), SCIPfixVarProbing(), SCIPpropagateProbing(), SCIPsolveProbingLP(), etc available 3028 """Quits probing and resets bounds and constraints to the focus node's environment""" 3032 """changes (column) variable's objective value during probing mode""" 3036 """Fixes a variable at the current probing node.""" 3040 """returns whether the objective function has changed during probing mode""" 3044 """returns whether we are in probing mode; probing mode is activated via startProbing() and stopped via endProbing()""" 3048 """solves the LP at the current probing node (cannot be applied at preprocessing stage) 3049 no separation or pricing is applied 3050 :param itlim: maximal number of LP iterations to perform (Default value = -1, that is, no limit) 3051 returns two booleans: 3052 lperror -- if an unresolved lp error occured 3053 cutoff -- whether the LP was infeasible or the objective limit was reached 3055 cdef SCIP_Bool lperror
3056 cdef SCIP_Bool cutoff
3059 return lperror, cutoff
3062 """Interrupt the solving process as soon as possible.""" 3068 """Create a new primal solution. 3070 :param Heur heur: heuristic that found the solution (Default value = None) 3073 cdef SCIP_HEUR* _heur
3075 if isinstance(heur, Heur):
3076 n = str_conversion(heur.name)
3081 PY_SCIP_CALL(
SCIPcreateSol(self._scip, &solution.sol, _heur))
3085 """Prints the best feasible primal solution.""" 3088 def printSol(self, Solution solution, write_zeros=False):
3089 """Print the given primal solution. 3092 solution -- solution to print 3093 write_zeros -- include variables that are set to zero 3095 PY_SCIP_CALL(
SCIPprintSol(self._scip, solution.sol, NULL, write_zeros))
3098 """Write the best feasible primal solution to a file. 3101 filename -- name of the output file 3102 write_zeros -- include variables that are set to zero 3106 with open(filename,
"w")
as f:
3107 cfile = fdopen(f.fileno(),
"w")
3110 def writeSol(self, Solution solution, filename="origprob.sol", write_zeros=False):
3111 """Write the given primal solution to a file. 3114 solution -- solution to write 3115 filename -- name of the output file 3116 write_zeros -- include variables that are set to zero 3120 with open(filename,
"w")
as f:
3121 cfile = fdopen(f.fileno(),
"w")
3122 PY_SCIP_CALL(
SCIPprintSol(self._scip, solution.sol, cfile, write_zeros))
3127 """Reads a given solution file, problem has to be transformed in advance. 3130 filename -- name of the input file 3132 fn = str_conversion(filename)
3136 """Reads a given solution file. 3138 Solution is created but not added to storage/the model. 3139 Use 'addSol' OR 'trySol' to add it. 3142 filename -- name of the input file 3144 cdef SCIP_Bool partial
3145 cdef SCIP_Bool error
3146 cdef SCIP_Bool stored
3147 cdef Solution solution
3149 fn = str_conversion(filename)
3151 PY_SCIP_CALL(
SCIPreadSolFile(self._scip, fn, solution.sol,
False, &partial, &error))
3153 raise Exception(
"SCIP: reading solution from file failed!")
3158 """Set a variable in a solution. 3160 :param Solution solution: solution to be modified 3161 :param Variable var: variable in the solution 3162 :param val: value of the specified variable 3166 _sol = <SCIP_SOL*>solution.sol
3169 def trySol(self, Solution solution, printreason=True, completely=False, checkbounds=True, checkintegrality=True, checklprows=True, free=True):
3170 """Check given primal solution for feasibility and try to add it to the storage. 3172 :param Solution solution: solution to store 3173 :param printreason: should all reasons of violations be printed? (Default value = True) 3174 :param completely: should all violation be checked? (Default value = False) 3175 :param checkbounds: should the bounds of the variables be checked? (Default value = True) 3176 :param checkintegrality: has integrality to be checked? (Default value = True) 3177 :param checklprows: have current LP rows (both local and global) to be checked? (Default value = True) 3178 :param free: should solution be freed? (Default value = True) 3181 cdef SCIP_Bool stored
3183 PY_SCIP_CALL(
SCIPtrySolFree(self._scip, &solution.sol, printreason, completely, checkbounds, checkintegrality, checklprows, &stored))
3185 PY_SCIP_CALL(
SCIPtrySol(self._scip, solution.sol, printreason, completely, checkbounds, checkintegrality, checklprows, &stored))
3188 def checkSol(self, Solution solution, printreason=True, completely=False, checkbounds=True, checkintegrality=True, checklprows=True, original=False):
3189 """Check given primal solution for feasibility without adding it to the storage. 3191 :param Solution solution: solution to store 3192 :param printreason: should all reasons of violations be printed? (Default value = True) 3193 :param completely: should all violation be checked? (Default value = False) 3194 :param checkbounds: should the bounds of the variables be checked? (Default value = True) 3195 :param checkintegrality: has integrality to be checked? (Default value = True) 3196 :param checklprows: have current LP rows (both local and global) to be checked? (Default value = True) 3197 :param original: must the solution be checked against the original problem (Default value = False) 3200 cdef SCIP_Bool feasible
3202 PY_SCIP_CALL(
SCIPcheckSolOrig(self._scip, solution.sol, &feasible, printreason, completely))
3204 PY_SCIP_CALL(
SCIPcheckSol(self._scip, solution.sol, printreason, completely, checkbounds, checkintegrality, checklprows, &feasible))
3207 def addSol(self, Solution solution, free=True):
3208 """Try to add a solution to the storage. 3210 :param Solution solution: solution to store 3211 :param free: should solution be freed afterwards? (Default value = True) 3214 cdef SCIP_Bool stored
3218 PY_SCIP_CALL(
SCIPaddSol(self._scip, solution.sol, &stored))
3222 """Free given solution 3224 :param Solution solution: solution to be freed 3227 PY_SCIP_CALL(
SCIPfreeSol(self._scip, &solution.sol))
3230 """Retrieve list of all feasible primal solutions stored in the solution storage.""" 3231 cdef SCIP_SOL** _sols
3237 for i
in range(nsols):
3238 sols.append(Solution.create(_sols[i]))
3243 """Retrieve currently best known feasible primal solution.""" 3248 """Retrieve the objective value of the solution. 3250 :param Solution sol: solution 3251 :param original: objective value in original space (Default value = True) 3255 sol = Solution.create(NULL)
3263 """Retrieve the objective value of value of best solution. 3264 Can only be called after solving is completed. 3266 :param original: objective value in original space (Default value = True) 3269 if not self.
getStage() >= SCIP_STAGE_SOLVING:
3270 raise Warning(
"method cannot be called before problem is solved")
3274 """Retrieve value of given variable in the given solution or in 3275 the LP/pseudo solution if sol == None 3277 :param Solution sol: solution 3278 :param Variable var: variable to query the value of 3282 sol = Solution.create(NULL)
3286 """Retrieve the value of the best known solution. 3287 Can only be called after solving is completed. 3289 :param Variable var: variable to query the value of 3292 if not self.
getStage() >= SCIP_STAGE_SOLVING:
3293 raise Warning(
"method cannot be called before problem is solved")
3297 """Retrieve the best primal bound.""" 3301 """Retrieve the best dual bound.""" 3305 """Retrieve the best root dual bound.""" 3309 """Write the name of the variable to the std out. 3311 :param Variable var: variable 3317 """Retrieve current SCIP stage""" 3321 """Retrieve solution status.""" 3323 if stat == SCIP_STATUS_OPTIMAL:
3325 elif stat == SCIP_STATUS_TIMELIMIT:
3327 elif stat == SCIP_STATUS_INFEASIBLE:
3329 elif stat == SCIP_STATUS_UNBOUNDED:
3335 """Retrieve objective sense.""" 3337 if sense == SCIP_OBJSENSE_MAXIMIZE:
3339 elif sense == SCIP_OBJSENSE_MINIMIZE:
3345 """catches a global (not variable or row dependent) event""" 3346 cdef SCIP_EVENTHDLR* _eventhdlr
3347 if isinstance(eventhdlr, Eventhdlr):
3348 n = str_conversion(eventhdlr.name)
3351 raise Warning(
"event handler not found")
3352 PY_SCIP_CALL(
SCIPcatchEvent(self._scip, eventtype, _eventhdlr, NULL, NULL))
3355 """drops a global event (stops to track event)""" 3356 cdef SCIP_EVENTHDLR* _eventhdlr
3357 if isinstance(eventhdlr, Eventhdlr):
3358 n = str_conversion(eventhdlr.name)
3361 raise Warning(
"event handler not found")
3362 PY_SCIP_CALL(
SCIPdropEvent(self._scip, eventtype, _eventhdlr, NULL, -1))
3365 """catches an objective value or domain change event on the given transformed variable""" 3366 cdef SCIP_EVENTHDLR* _eventhdlr
3367 if isinstance(eventhdlr, Eventhdlr):
3368 n = str_conversion(eventhdlr.name)
3371 raise Warning(
"event handler not found")
3372 PY_SCIP_CALL(
SCIPcatchVarEvent(self._scip, var.var, eventtype, _eventhdlr, NULL, NULL))
3375 """drops an objective value or domain change event (stops to track event) on the given transformed variable""" 3376 cdef SCIP_EVENTHDLR* _eventhdlr
3377 if isinstance(eventhdlr, Eventhdlr):
3378 n = str_conversion(eventhdlr.name)
3381 raise Warning(
"event handler not found")
3382 PY_SCIP_CALL(
SCIPdropVarEvent(self._scip, var.var, eventtype, _eventhdlr, NULL, -1))
3385 """catches a row coefficient, constant, or side change event on the given row""" 3386 cdef SCIP_EVENTHDLR* _eventhdlr
3387 if isinstance(eventhdlr, Eventhdlr):
3388 n = str_conversion(eventhdlr.name)
3391 raise Warning(
"event handler not found")
3392 PY_SCIP_CALL(
SCIPcatchRowEvent(self._scip, row.row, eventtype, _eventhdlr, NULL, NULL))
3395 """drops a row coefficient, constant, or side change event (stops to track event) on the given row""" 3396 cdef SCIP_EVENTHDLR* _eventhdlr
3397 if isinstance(eventhdlr, Eventhdlr):
3398 n = str_conversion(eventhdlr.name)
3401 raise Warning(
"event handler not found")
3402 PY_SCIP_CALL(
SCIPdropRowEvent(self._scip, row.row, eventtype, _eventhdlr, NULL, -1))
3407 """Print statistics.""" 3411 """Write statistics to a file. 3414 filename -- name of the output file 3418 with open(filename,
"w")
as f:
3419 cfile = fdopen(f.fileno(),
"w")
3423 """gets total number of LPs solved so far""" 3431 :param quiet: hide output? (Default value = True) 3439 """Send output to python instead of terminal.""" 3441 cdef SCIP_MESSAGEHDLR *myMessageHandler
3443 PY_SCIP_CALL(SCIPmessagehdlrCreate(&myMessageHandler,
False, NULL,
False, relayMessage, relayMessage, relayMessage, NULL, NULL))
3445 SCIPmessageSetErrorPrinting(relayErrorMessage, NULL)
3450 """Set a boolean-valued parameter. 3452 :param name: name of parameter 3453 :param value: value of parameter 3456 n = str_conversion(name)
3460 """Set an int-valued parameter. 3462 :param name: name of parameter 3463 :param value: value of parameter 3466 n = str_conversion(name)
3470 """Set a long-valued parameter. 3472 :param name: name of parameter 3473 :param value: value of parameter 3476 n = str_conversion(name)
3480 """Set a real-valued parameter. 3482 :param name: name of parameter 3483 :param value: value of parameter 3486 n = str_conversion(name)
3490 """Set a char-valued parameter. 3492 :param name: name of parameter 3493 :param value: value of parameter 3496 n = str_conversion(name)
3500 """Set a string-valued parameter. 3502 :param name: name of parameter 3503 :param value: value of parameter 3506 n = str_conversion(name)
3507 v = str_conversion(value)
3511 """Set a parameter with value in int, bool, real, long, char or str. 3513 :param name: name of parameter 3514 :param value: value of parameter 3516 cdef SCIP_PARAM* param
3518 n = str_conversion(name)
3522 raise KeyError(
"Not a valid parameter name")
3524 paramtype = SCIPparamGetType(param)
3526 if paramtype == SCIP_PARAMTYPE_BOOL:
3528 elif paramtype == SCIP_PARAMTYPE_INT:
3530 elif paramtype == SCIP_PARAMTYPE_LONGINT:
3532 elif paramtype == SCIP_PARAMTYPE_REAL:
3534 elif paramtype == SCIP_PARAMTYPE_CHAR:
3536 elif paramtype == SCIP_PARAMTYPE_STRING:
3541 """Get the value of a parameter of type 3542 int, bool, real, long, char or str. 3544 :param name: name of parameter 3546 cdef SCIP_PARAM* param
3548 n = str_conversion(name)
3552 raise KeyError(
"Not a valid parameter name")
3554 paramtype = SCIPparamGetType(param)
3556 if paramtype == SCIP_PARAMTYPE_BOOL:
3557 return SCIPparamGetBool(param)
3558 elif paramtype == SCIP_PARAMTYPE_INT:
3559 return SCIPparamGetInt(param)
3560 elif paramtype == SCIP_PARAMTYPE_LONGINT:
3561 return SCIPparamGetLongint(param)
3562 elif paramtype == SCIP_PARAMTYPE_REAL:
3563 return SCIPparamGetReal(param)
3564 elif paramtype == SCIP_PARAMTYPE_CHAR:
3565 return chr(SCIPparamGetChar(param))
3566 elif paramtype == SCIP_PARAMTYPE_STRING:
3567 return SCIPparamGetString(param)
3571 """Read an external parameter file. 3573 :param file: file to be read 3576 absfile = str_conversion(abspath(file))
3579 def writeParams(self, filename='param.set', comments = True, onlychanged = True):
3580 """Write parameter settings to an external file. 3582 :param filename: file to be written (Default value = 'param.set') 3583 :param comments: write parameter descriptions as comments? (Default value = True) 3584 :param onlychanged: write only modified parameters (Default value = True) 3587 fn = str_conversion(filename)
3589 print(
'wrote parameter settings to file ' + filename)
3592 """Reset parameter setting to its default value 3594 :param name: parameter to reset 3597 n = str_conversion(name)
3601 """Reset parameter settings to their default values""" 3605 """Set emphasis settings 3607 :param paraemphasis: emphasis to set 3608 :param quiet: hide output? (Default value = True) 3614 """Read a problem instance from an external file. 3616 :param file: file to be read 3617 :param extension: specify file extension/type (Default value = None) 3620 absfile = str_conversion(abspath(file))
3621 if extension
is None:
3624 extension = str_conversion(extension)
3625 PY_SCIP_CALL(
SCIPreadProb(self._scip, absfile, extension))
3630 """Counts the number of feasible points of problem.""" 3634 """Get number of feasible solution.""" 3635 cdef SCIP_Bool valid
3636 cdef SCIP_Longint nsols
3640 print(
'total number of solutions found is not valid!')
3644 """Sets SCIP parameters such that a valid counting process is possible.""" 3648 """Frees all solution process data and prepares for reoptimization""" 3652 """Establish the objective function as a linear expression. 3654 :param coeffs: the coefficients 3655 :param sense: the objective sense (Default value = 'minimize') 3659 cdef SCIP_OBJSENSE objsense
3661 if sense ==
"minimize":
3662 objsense = SCIP_OBJSENSE_MINIMIZE
3663 elif sense ==
"maximize":
3664 objsense = SCIP_OBJSENSE_MAXIMIZE
3666 raise Warning(
"unrecognized optimization sense: %s" % sense)
3668 assert isinstance(coeffs, Expr),
"given coefficients are not Expr but %s" % coeffs.__class__.__name__
3670 if coeffs.degree() > 1:
3671 raise ValueError(
"Nonlinear objective functions are not supported!")
3672 if coeffs[CONST] != 0.0:
3673 raise ValueError(
"Constant offsets in objective are not supported!")
3675 cdef SCIP_VAR** _vars
3679 _coeffs = <SCIP_Real*> malloc(_nvars * sizeof(SCIP_Real))
3681 for i
in range(_nvars):
3684 for term, coef
in coeffs.terms.items():
3687 assert len(term) == 1
3688 var = <Variable>term[0]
3689 for i
in range(_nvars):
3690 if _vars[i] == var.var:
3698 def is_memory_freed():
3699 return BMSgetMemoryUsed() == 0
3701 def print_memory_in_use():
3702 BMScheckEmptyMemory()
SCIP_RETCODE SCIPfreeProb(SCIP *scip)
int SCIPgetNConss(SCIP *scip)
def trySol(self, Solution, solution, printreason=True, completely=False, checkbounds=True, checkintegrality=True, checklprows=True, free=True)
def dropVarEvent(self, Variable, var, eventtype, Eventhdlr, eventhdlr)
SCIP_RETCODE SCIPcreateConsAnd(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_VAR *resvar, int nvars, SCIP_VAR **vars, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
def setHeuristics(self, setting)
def getVarRedcost(self, Variable, var)
SCIP_RETCODE SCIPtightenVarLb(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound, SCIP_Bool force, SCIP_Bool *infeasible, SCIP_Bool *tightened)
def printBestSol(self, write_zeros=False)
SCIP_RETCODE SCIPsetStringParam(SCIP *scip, const char *name, const char *value)
SCIP_RETCODE SCIPsetObjsense(SCIP *scip, SCIP_OBJSENSE objsense)
SCIP_RETCODE SCIPincludeEventhdlr(SCIP *scip, const char *name, const char *desc, SCIP_DECL_EVENTCOPY((*eventcopy)), SCIP_DECL_EVENTFREE((*eventfree)), SCIP_DECL_EVENTINIT((*eventinit)), SCIP_DECL_EVENTEXIT((*eventexit)), SCIP_DECL_EVENTINITSOL((*eventinitsol)), SCIP_DECL_EVENTEXITSOL((*eventexitsol)), SCIP_DECL_EVENTDELETE((*eventdelete)), SCIP_DECL_EVENTEXEC((*eventexec)), SCIP_EVENTHDLRDATA *eventhdlrdata)
def appendVarSOS2(self, Constraint, cons, Variable, var)
def getNCutsApplied(self)
SCIP_RETCODE SCIPaddSolFree(SCIP *scip, SCIP_SOL **sol, SCIP_Bool *stored)
SCIP_Real SCIPgetGap(SCIP *scip)
SCIP_RETCODE SCIPcreateConsQuadratic(SCIP *scip, SCIP_CONS **cons, const char *name, int nlinvars, SCIP_VAR **linvars, SCIP_Real *lincoefs, int nquadterms, SCIP_VAR **quadvars1, SCIP_VAR **quadvars2, SCIP_Real *quadcoeffs, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable)
SCIP_RETCODE SCIPchgVarObjDive(SCIP *scip, SCIP_VAR *var, SCIP_Real newobj)
SCIP_Bool SCIPnodeIsPropagatedAgain(SCIP_NODE *node)
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
SCIP_Real * SCIPgetValsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPaddPricedVar(SCIP *scip, SCIP_VAR *var, SCIP_Real score)
SCIP_RETCODE SCIPsetLongintParam(SCIP *scip, const char *name, SCIP_Longint value)
int SCIPgetDepth(SCIP *scip)
SCIP_RETCODE SCIPprintStatistics(SCIP *scip, FILE *file)
def includeHeur(self, Heur, heur, name, desc, dispchar, priority=10000, freq=1, freqofs=0, maxdepth=-1, timingmask=SCIP_HEURTIMING_BEFORENODE, usessubscip=False)
def getDualboundRoot(self)
SCIP_RETCODE SCIPgetActivityQuadratic(SCIP *scip, SCIP_CONS *cons, SCIP_SOL *sol, SCIP_Real *activity)
def chgVarLb(self, Variable, var, lb)
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
def addConsOr(self, vars, resvar, name="ORcons", initial=True, separate=True, enforce=True, check=True, propagate=True, local=False, modifiable=False, dynamic=False, removable=False, stickingatnode=False)
void SCIPprintVersion(SCIP *scip, FILE *file)
SCIP_RETCODE SCIPgetDualSolVal(SCIP *scip, SCIP_CONS *cons, SCIP_Real *dualsolval, SCIP_Bool *boundconstraint)
def setRemovable(self, Constraint, cons, newRem)
SCIP_Real SCIPgetRhsQuadratic(SCIP *scip, SCIP_CONS *cons)
def getLhs(self, Constraint, cons)
def chgVarObjProbing(self, Variable, var, newobj)
SCIP_CONSHDLR * SCIPconsGetHdlr(SCIP_CONS *cons)
def chgVarUbDive(self, Variable, var, newbound)
SCIP_BASESTAT SCIPcolGetBasisStatus(SCIP_COL *col)
SCIP_CONSHDLR * SCIPfindConshdlr(SCIP *scip, const char *name)
SCIP_RETCODE SCIPtightenVarUbGlobal(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound, SCIP_Bool force, SCIP_Bool *infeasible, SCIP_Bool *tightened)
def isFeasZero(self, value)
SCIP_SOL * SCIPgetBestSol(SCIP *scip)
int SCIPgetNVars(SCIP *scip)
def tightenVarUb(self, Variable, var, ub, force=False)
def addRowDive(self, Row, row)
SCIP_Real SCIPfeasFrac(SCIP *scip, SCIP_Real val)
int SCIPnodeGetNAddedConss(SCIP_NODE *node)
SCIP_Bool SCIPconsIsStickingAtNode(SCIP_CONS *cons)
void SCIPsetMessagehdlrQuiet(SCIP *scip, SCIP_Bool quiet)
def checkSol(self, Solution, solution, printreason=True, completely=False, checkbounds=True, checkintegrality=True, checklprows=True, original=False)
def addConsCardinality(self, consvars, cardval, indvars=None, weights=None, name="CardinalityCons", initial=True, separate=True, enforce=True, check=True, propagate=True, local=False, dynamic=False, removable=False, stickingatnode=False)
SCIP_RETCODE SCIPsolveDiveLP(SCIP *scip, int itlim, SCIP_Bool *lperror, SCIP_Bool *cutoff)
SCIP_Real SCIPfeastol(SCIP *scip)
SCIP_Real SCIPgetDualboundRoot(SCIP *scip)
def setProbName(self, name)
SCIP_Real SCIPnodeGetEstimate(SCIP_NODE *node)
def dropEvent(self, eventtype, Eventhdlr, eventhdlr)
SCIP_Bool SCIPisLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
def catchEvent(self, eventtype, Eventhdlr, eventhdlr)
SCIP_RETCODE SCIPincludeBenders(SCIP *scip, const char *name, const char *desc, int priority, SCIP_Bool cutlp, SCIP_Bool cutpseudo, SCIP_Bool cutrelax, SCIP_Bool shareauxvars, SCIP_DECL_BENDERSCOPY((*benderscopy)), SCIP_DECL_BENDERSFREE((*bendersfree)), SCIP_DECL_BENDERSINIT((*bendersinit)), SCIP_DECL_BENDERSEXIT((*bendersexit)), SCIP_DECL_BENDERSINITPRE((*bendersinitpre)), SCIP_DECL_BENDERSEXITPRE((*bendersexitpre)), SCIP_DECL_BENDERSINITSOL((*bendersinitsol)), SCIP_DECL_BENDERSEXITSOL((*bendersexitsol)), SCIP_DECL_BENDERSGETVAR((*bendersgetvar)), SCIP_DECL_BENDERSCREATESUB((*benderscreatesub)), SCIP_DECL_BENDERSPRESUBSOLVE((*benderspresubsolve)), SCIP_DECL_BENDERSSOLVESUBCONVEX((*benderssolvesubconvex)), SCIP_DECL_BENDERSSOLVESUB((*benderssolvesub)), SCIP_DECL_BENDERSPOSTSOLVE((*benderspostsolve)), SCIP_DECL_BENDERSFREESUB((*bendersfreesub)), SCIP_BENDERSDATA *bendersdata)
SCIP_NODETYPE SCIPnodeGetType(SCIP_NODE *node)
SCIP_RETCODE SCIPresetParams(SCIP *scip)
SCIP_RETCODE SCIPcreateConsNonlinear(SCIP *scip, SCIP_CONS **cons, const char *name, int nlinvars, SCIP_VAR **linvars, SCIP_Real *lincoefs, int nexprtrees, SCIP_EXPRTREE **exprtrees, SCIP_Real *nonlincoefs, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
SCIP_Real SCIPgetCutEfficacy(SCIP *scip, SCIP_SOL *sol, SCIP_ROW *cut)
def readParams(self, file)
def releaseRow(self, Row, row, not, None)
def writeSol(self, Solution, solution, filename="origprob.sol", write_zeros=False)
def includeBranchrule(self, Branchrule, branchrule, name, desc, priority, maxdepth, maxbounddist)
def addConsCoeff(self, Constraint, cons, Variable, var, coeff)
SCIP_Bool SCIPvarIsInLP(SCIP_VAR *var)
def getCondition(self, exact=False)
SCIP_Real SCIPgetRhsLinear(SCIP *scip, SCIP_CONS *cons)
def getObjVal(self, original=True)
SCIP_RETCODE SCIPtightenVarLbGlobal(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound, SCIP_Bool force, SCIP_Bool *infeasible, SCIP_Bool *tightened)
def getObjectiveSense(self)
def setBoolParam(self, name, value)
def writeStatistics(self, filename="origprob.stats")
SCIP_Real SCIPgetPresolvingTime(SCIP *scip)
int SCIPgetNBilinTermsQuadratic(SCIP *scip, SCIP_CONS *cons)
SCIP_SOL ** SCIPgetSols(SCIP *scip)
def getActivity(self, Constraint, cons, Solution, sol=None)
SCIP_RETCODE SCIPincludeSepa(SCIP *scip, const char *name, const char *desc, int priority, int freq, SCIP_Real maxbounddist, SCIP_Bool usessubscip, SCIP_Bool delay, SCIP_DECL_SEPACOPY((*sepacopy)), SCIP_DECL_SEPAFREE((*sepafree)), SCIP_DECL_SEPAINIT((*sepainit)), SCIP_DECL_SEPAEXIT((*sepaexit)), SCIP_DECL_SEPAINITSOL((*sepainitsol)), SCIP_DECL_SEPAEXITSOL((*sepaexitsol)), SCIP_DECL_SEPAEXECLP((*sepaexeclp)), SCIP_DECL_SEPAEXECSOL((*sepaexecsol)), SCIP_SEPADATA *sepadata)
def branchVarVal(self, variable, value)
SCIP_Bool SCIPconsIsLocal(SCIP_CONS *cons)
SCIP_VAR ** SCIPgetVars(SCIP *scip)
SCIP_Bool SCIPinProbing(SCIP *scip)
def addObjoffset(self, offset, solutions=False)
def setObjective(self, coeffs, sense='minimize', clear='true')
SCIP_RETCODE SCIPcheckSol(SCIP *scip, SCIP_SOL *sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *feasible)
SCIP_RETCODE SCIPcreateConsOr(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_VAR *resvar, int nvars, SCIP_VAR **vars, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
def setLongintParam(self, name, value)
SCIP_RETCODE SCIPcreateCons(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_CONSHDLR *conshdlr, SCIP_CONSDATA *consdata, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
SCIP_RETCODE SCIPsetupBendersSubproblem(SCIP *scip, SCIP_BENDERS *benders, SCIP_SOL *sol, int probnumber)
SCIP_RETCODE SCIPdelCons(SCIP *scip, SCIP_CONS *cons)
def chgReoptObjective(self, coeffs, sense='minimize')
SCIP_RETCODE SCIPcatchVarEvent(SCIP *scip, SCIP_VAR *var, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int *filterpos)
def cacheRowExtensions(self, Row, row, not, None)
SCIP_RETCODE SCIPincludePricer(SCIP *scip, const char *name, const char *desc, int priority, SCIP_Bool delay, SCIP_DECL_PRICERCOPY((*pricercopy)), SCIP_DECL_PRICERFREE((*pricerfree)), SCIP_DECL_PRICERINIT((*pricerinit)), SCIP_DECL_PRICEREXIT((*pricerexit)), SCIP_DECL_PRICERINITSOL((*pricerinitsol)), SCIP_DECL_PRICEREXITSOL((*pricerexitsol)), SCIP_DECL_PRICERREDCOST((*pricerredcost)), SCIP_DECL_PRICERFARKAS((*pricerfarkas)), SCIP_PRICERDATA *pricerdata)
SCIP_RETCODE SCIPchgLhsLinear(SCIP *scip, SCIP_CONS *cons, SCIP_Real lhs)
SCIP_RETCODE SCIPreadSol(SCIP *scip, const char *filename)
SCIP_RETCODE SCIPsetConsEnforced(SCIP *scip, SCIP_CONS *cons, SCIP_Bool enforce)
def setSeparating(self, setting)
def addConsXor(self, vars, rhsvar, name="XORcons", initial=True, separate=True, enforce=True, check=True, propagate=True, local=False, modifiable=False, dynamic=False, removable=False, stickingatnode=False)
def setEmphasis(self, paraemphasis, quiet=True)
SCIP_RETCODE SCIPfixVar(SCIP *scip, SCIP_VAR *var, SCIP_Real fixedval, SCIP_Bool *infeasible, SCIP_Bool *fixed)
SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value)
def addPyCons(self, Constraint, cons)
SCIP_RETCODE SCIPaddVarLocks(SCIP *scip, SCIP_VAR *var, int nlocksdown, int nlocksup)
def getTransformedVar(self, Variable, var)
def writeBestSol(self, filename="origprob.sol", write_zeros=False)
def addConsSOS2(self, vars, weights=None, name="SOS2cons", initial=True, separate=True, enforce=True, check=True, propagate=True, local=False, dynamic=False, removable=False, stickingatnode=False)
SCIP_Real SCIPcolGetUb(SCIP_COL *col)
SCIP_RETCODE SCIPchgVarObjProbing(SCIP *scip, SCIP_VAR *var, SCIP_Real newobj)
def includeConshdlr(self, Conshdlr, conshdlr, name, desc, sepapriority=0, enfopriority=0, chckpriority=0, sepafreq=-1, propfreq=-1, eagerfreq=100, maxprerounds=-1, delaysepa=False, delayprop=False, needscons=True, proptiming=PY_SCIP_PROPTIMING.BEFORELP, presoltiming=PY_SCIP_PRESOLTIMING.MEDIUM)
SCIP_RETCODE SCIPprintRow(SCIP *scip, SCIP_ROW *row, FILE *file)
def writeParams(self, filename='param.set', comments=True, onlychanged=True)
SCIP_RETCODE SCIPsetParamsCountsols(SCIP *scip)
def delVar(self, Variable, var)
SCIP_Real SCIPgetTransObjoffset(SCIP *scip)
SCIP_RETCODE SCIPcatchEvent(SCIP *scip, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int *filterpos)
SCIP_RETCODE SCIPcreateConsSOS2(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *weights, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
int SCIPgetNLPBranchCands(SCIP *scip)
def getPresolvingTime(self)
SCIP_RETCODE SCIPaddPoolCut(SCIP *scip, SCIP_ROW *row)
def isLE(self, val1, val2)
const char * SCIPconsGetName(SCIP_CONS *cons)
SCIP_Longint SCIPgetNCountedSols(SCIP *scip, SCIP_Bool *valid)
SCIP_Real SCIPgetSolOrigObj(SCIP *scip, SCIP_SOL *sol)
SCIP_Real SCIPeventGetOldbound(SCIP_EVENT *event)
def createCons(self, Conshdlr, conshdlr, name, initial=True, separate=True, enforce=True, check=True, propagate=True, local=False, modifiable=False, dynamic=False, removable=False, stickingatnode=False)
def setParamsCountsols(self)
int SCIProwGetNLPNonz(SCIP_ROW *row)
SCIP_RETCODE SCIPgetLPBInvRow(SCIP *scip, int r, SCIP_Real *coefs, int *inds, int *ninds)
SCIP_Real SCIProwGetRhs(SCIP_ROW *row)
SCIP_RETCODE SCIPbranchVarVal(SCIP *scip, SCIP_VAR *var, SCIP_Real val, SCIP_NODE **downchild, SCIP_NODE **eqchild, SCIP_NODE **upchild)
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
int SCIPbendersGetNSubproblems(SCIP_BENDERS *benders)
SCIP_RETCODE SCIPfreeReoptSolve(SCIP *scip)
def getRowLPActivity(self, Row, row)
def chgRowRhsDive(self, Row, row, newrhs)
SCIP_Longint SCIPgetNNodes(SCIP *scip)
def setParam(self, name, value)
SCIP_BASESTAT SCIProwGetBasisStatus(SCIP_ROW *row)
SCIP_RETCODE SCIPfreeBendersSubproblem(SCIP *scip, SCIP_BENDERS *benders, int probnumber)
SCIP_Bool SCIPconsIsOriginal(SCIP_CONS *cons)
SCIP_RETCODE SCIPchgVarType(SCIP *scip, SCIP_VAR *var, SCIP_VARTYPE vartype, SCIP_Bool *infeasible)
SCIP_RETCODE SCIPdelConsLocal(SCIP *scip, SCIP_CONS *cons)
def createEmptyRowSepa(self, Sepa, sepa, name="row", lhs=0.0, rhs=None, local=True, modifiable=False, removable=True)
SCIP_RETCODE SCIPcacheRowExtensions(SCIP *scip, SCIP_ROW *row)
SCIP_RETCODE SCIPsetMessagehdlr(SCIP *scip, SCIP_MESSAGEHDLR *messagehdlr)
SCIP_RETCODE SCIPgetBendersMasterVar(SCIP *scip, SCIP_BENDERS *benders, SCIP_VAR *var, SCIP_VAR **mappedvar)
SCIP_RETCODE SCIPaddOrigObjoffset(SCIP *scip, SCIP_Real addval)
def setSolVal(self, Solution, solution, Variable, var, val)
SCIP_RETCODE SCIPaddVarCardinality(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_VAR *indvar, SCIP_Real weight)
SCIP_Real SCIPvarGetUbOriginal(SCIP_VAR *var)
SCIP_RETCODE SCIPsetEmphasis(SCIP *scip, SCIP_PARAMEMPHASIS paramemphasis, SCIP_Bool quiet)
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
def createSol(self, Heur, heur=None)
SCIP_RETCODE SCIPfreeSol(SCIP *scip, SCIP_SOL **sol)
SCIP_Bool SCIPcolIsIntegral(SCIP_COL *col)
SCIP_Real SCIPinfinity(SCIP *scip)
SCIP_STAGE SCIPgetStage(SCIP *scip)
def solveDiveLP(self, itlim=-1)
def updateNodeLowerbound(self, Node, node, lb)
def isPropagatedAgain(self)
def resetParam(self, name)
SCIP_BILINTERM * SCIPgetBilinTermsQuadratic(SCIP *scip, SCIP_CONS *cons)
def branchVar(self, variable)
void SCIPbendersUpdateSubproblemLowerbound(SCIP_BENDERS *benders, int probnumber, SCIP_Real lowerbound)
SCIP_COL * SCIPvarGetCol(SCIP_VAR *var)
SCIP_VAR ** SCIPgetOrigVars(SCIP *scip)
SCIP_RETCODE SCIPfree(SCIP **scip)
def delConsLocal(self, Constraint, cons)
SCIP_RETCODE SCIPdropRowEvent(SCIP *scip, SCIP_ROW *row, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int filterpos)
def isStickingAtNode(self)
def calcNodeselPriority(self, Variable, variable, branchdir, targetvalue)
SCIP_LPSOLSTAT SCIPgetLPSolstat(SCIP *scip)
SCIP_Real SCIPgetSolTransObj(SCIP *scip, SCIP_SOL *sol)
SCIP_RETCODE SCIPgetTransformedCons(SCIP *scip, SCIP_CONS *cons, SCIP_CONS **transcons)
SCIP_STATUS SCIPgetStatus(SCIP *scip)
SCIP_RETCODE SCIPgetBendersSubproblemVar(SCIP *scip, SCIP_BENDERS *benders, SCIP_VAR *var, SCIP_VAR **mappedvar, int probnumber)
SCIP_Real SCIPgetVarUbDive(SCIP *scip, SCIP_VAR *var)
def feasFrac(self, value)
def fixVar(self, Variable, var, val)
int SCIPnodeGetDepth(SCIP_NODE *node)
SCIP_Real SCIPgetRowLPActivity(SCIP *scip, SCIP_ROW *row)
SCIP_RETCODE SCIPstartDive(SCIP *scip)
SCIP_RETCODE SCIPcreateEmptyRowSepa(SCIP *scip, SCIP_ROW **row, SCIP_SEPA *sepa, const char *name, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool removable)
SCIP_RETCODE SCIPaddVarToRow(SCIP *scip, SCIP_ROW *row, SCIP_VAR *var, SCIP_Real val)
def addVarLocks(self, Variable, var, nlocksdown, nlocksup)
SCIP_RETCODE SCIPendDive(SCIP *scip)
SCIP_RETCODE SCIPchgVarUbNode(SCIP *scip, SCIP_NODE *node, SCIP_VAR *var, SCIP_Real newbound)
def getBendersVar(self, Variable, var, Benders, benders=None, probnumber=-1)
SCIP_COL ** SCIProwGetCols(SCIP_ROW *row)
SCIP_RETCODE SCIPdropEvent(SCIP *scip, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int filterpos)
SCIP_RETCODE SCIPcreateBendersDefault(SCIP *scip, SCIP **subproblems, int nsubproblems)
def addVarSOS1(self, Constraint, cons, Variable, var, weight)
SCIP_RETCODE SCIPappendVarSOS2(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var)
SCIP_RETCODE SCIPpresolve(SCIP *scip)
def chgRowLhsDive(self, Row, row, newlhs)
SCIP_RETCODE SCIPsetConsRemovable(SCIP *scip, SCIP_CONS *cons, SCIP_Bool removable)
def delCons(self, Constraint, cons)
SCIP_Bool SCIPvarIsOriginal(SCIP_VAR *var)
SCIP_RETCODE SCIPaddLinearVarQuadratic(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real coef)
SCIP_RETCODE SCIPstartProbing(SCIP *scip)
SCIP_RETCODE SCIPsetObjlimit(SCIP *scip, SCIP_Real objlimit)
def hideOutput(self, quiet=True)
SCIP_RETCODE SCIPaddBilinTermQuadratic(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var1, SCIP_VAR *var2, SCIP_Real coef)
SCIP_Bool SCIPisCutEfficacious(SCIP *scip, SCIP_SOL *sol, SCIP_ROW *cut)
def chgVarUb(self, Variable, var, ub)
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
SCIP_RETCODE SCIPcreateChild(SCIP *scip, SCIP_NODE **node, SCIP_Real nodeselprio, SCIP_Real estimate)
int SCIPgetNCutsApplied(SCIP *scip)
SCIP_CONS ** SCIPgetConss(SCIP *scip)
SCIP_RETCODE SCIPcreateConsSOS1(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *weights, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
SCIP_Real SCIPgetDualsolLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPbranchVar(SCIP *scip, SCIP_VAR *var, SCIP_NODE **downchild, SCIP_NODE **eqchild, SCIP_NODE **upchild)
def addCons(self, cons, name='', initial=True, separate=True, enforce=True, check=True, propagate=True, local=False, modifiable=False, dynamic=False, removable=False, stickingatnode=False)
SCIP_RETCODE SCIPdelVar(SCIP *scip, SCIP_VAR *var, SCIP_Bool *deleted)
def calcChildEstimate(self, Variable, variable, targetvalue)
SCIP_Real SCIPgetPrimalbound(SCIP *scip)
SCIP_RETCODE SCIPfixVarProbing(SCIP *scip, SCIP_VAR *var, SCIP_Real fixedval)
SCIP_RETCODE SCIPreadProb(SCIP *scip, const char *filename, const char *extension)
SCIP_RETCODE SCIPupdateNodeLowerbound(SCIP *scip, SCIP_NODE *node, SCIP_Real newbound)
def printSol(self, Solution, solution, write_zeros=False)
SCIP_Real SCIPgetSolvingTime(SCIP *scip)
SCIP_RETCODE SCIPsetPresolving(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
SCIP_RETCODE SCIPsetBoolParam(SCIP *scip, const char *name, SCIP_Bool value)
SCIP_RETCODE SCIPactivateBenders(SCIP *scip, SCIP_BENDERS *benders, int nsubproblems)
int SCIPgetNActiveBenders(SCIP *scip)
SCIP_Bool SCIPconsIsDynamic(SCIP_CONS *cons)
int SCIPgetNCuts(SCIP *scip)
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
SCIP_RETCODE SCIPaddSol(SCIP *scip, SCIP_SOL *sol, SCIP_Bool *stored)
SCIP_QUADVARTERM * SCIPgetQuadVarTermsQuadratic(SCIP *scip, SCIP_CONS *cons)
def getSolVal(self, Solution, sol, Variable, var)
def getDualsolLinear(self, Constraint, cons)
SCIP_Bool SCIPisObjChangedProbing(SCIP *scip)
SCIP_Real SCIPcolGetLb(SCIP_COL *col)
SCIP_RETCODE SCIPchgVarUb(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
SCIP_RETCODE SCIPendProbing(SCIP *scip)
def getLPBranchCands(self)
def addCut(self, Row, cut, not, None, forcecut=False)
SCIP_Bool SCIPconsIsInitial(SCIP_CONS *cons)
def isInfinity(self, value)
SCIP_Real SCIPgetOrigObjoffset(SCIP *scip)
SCIP_RETCODE SCIPcreateConsCardinality(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, int cardval, SCIP_VAR **indvars, SCIP_Real *weights, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
def isObjChangedProbing(self)
SCIP_RETCODE SCIPgetLPI(SCIP *scip, SCIP_LPI **lpi)
def chgVarLbGlobal(self, Variable, var, lb)
SCIP_Bool SCIPisZero(SCIP *scip, SCIP_Real val)
def getLPBInvRow(self, row)
SCIP_RETCODE SCIPappendVarSOS1(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var)
SCIP_Real SCIPepsilon(SCIP *scip)
SCIP_RETCODE SCIPchgVarObj(SCIP *scip, SCIP_VAR *var, SCIP_Real newobj)
SCIP_Real SCIPcalcNodeselPriority(SCIP *scip, SCIP_VAR *var, SCIP_BRANCHDIR branchdir, SCIP_Real targetvalue)
SCIP_RETCODE SCIPconstructLP(SCIP *scip, SCIP_Bool *cutoff)
SCIP_Real SCIPfrac(SCIP *scip, SCIP_Real val)
SCIP_RETCODE SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
def chgVarUbNode(self, Node, node, Variable, var, ub)
SCIP_RETCODE SCIPaddCoefLinear(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real val)
int SCIPcolGetLPPos(SCIP_COL *col)
def setStringParam(self, name, value)
def includeEventhdlr(self, Eventhdlr, eventhdlr, name, desc)
SCIP_Real SCIPgetLhsQuadratic(SCIP *scip, SCIP_CONS *cons)
def appendVarSOS1(self, Constraint, cons, Variable, var)
SCIP_RETCODE SCIPreleaseVar(SCIP *scip, SCIP_VAR **var)
SCIP_Real SCIPvarGetLPSol(SCIP_VAR *var)
SCIP_RETCODE SCIPchgVarLbDive(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
SCIP_Real SCIPnodeGetLowerbound(SCIP_NODE *node)
def setCharParam(self, name, value)
def readSolFile(self, filename)
SCIP_RETCODE SCIPaddVarSOS2(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real weight)
SCIP_RETCODE SCIPcreateVarBasic(SCIP *scip, SCIP_VAR **var, const char *name, SCIP_Real lb, SCIP_Real ub, SCIP_Real obj, SCIP_VARTYPE vartype)
def getRowActivity(self, Row, row)
def setInitial(self, Constraint, cons, newInit)
SCIP_Real SCIPgetDualbound(SCIP *scip)
SCIP_RETCODE SCIPchgVarLbNode(SCIP *scip, SCIP_NODE *node, SCIP_VAR *var, SCIP_Real newbound)
SCIP_RETCODE SCIPlpiGetRealSolQuality(SCIP_LPI *lpi, SCIP_LPSOLQUALITY qualityindicator, SCIP_Real *quality)
SCIP_PARAM * SCIPgetParam(SCIP *scip, const char *name)
SCIP_Bool SCIPisGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
def readSol(self, filename)
def computeBestSolSubproblems(self)
SCIP_RETCODE SCIPsetRelaxSolVal(SCIP *scip, SCIP_VAR *var, SCIP_Real val)
SCIP_Bool SCIPconsIsRemovable(SCIP_CONS *cons)
def setPresolve(self, setting)
SCIP_RETCODE SCIPchgReoptObjective(SCIP *scip, SCIP_OBJSENSE objsense, SCIP_VAR **vars, SCIP_Real *coefs, int nvars)
SCIP_RETCODE SCIPchgRhsLinear(SCIP *scip, SCIP_CONS *cons, SCIP_Real rhs)
SCIP_VAR * SCIPcolGetVar(SCIP_COL *col)
SCIP_RETCODE SCIPflushRowExtensions(SCIP *scip, SCIP_ROW *row)
SCIP_RETCODE SCIPchgRowLhsDive(SCIP *scip, SCIP_ROW *row, SCIP_Real newlhs)
def getTermsQuadratic(self, Constraint, cons)
SCIP_Real SCIPcalcChildEstimate(SCIP *scip, SCIP_VAR *var, SCIP_Real targetvalue)
def isCutEfficacious(self, Row, cut, not, None, Solution, sol=None)
def activateBenders(self, str, name, int, nsubproblems)
SCIP_Bool SCIPisLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_BENDERS ** SCIPgetBenders(SCIP *scip)
int SCIPgetNVarsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPgetLPBranchCands(SCIP *scip, SCIP_VAR ***lpcands, SCIP_Real **lpcandssol, SCIP_Real **lpcandsfrac, int *nlpcands, int *npriolpcands, int *nfracimplvars)
SCIP_BENDERS * SCIPfindBenders(SCIP *scip, const char *name)
SCIP_RETCODE SCIPreadParams(SCIP *scip, const char *filename)
def solveProbingLP(self, itlim=-1)
def setCheck(self, Constraint, cons, newCheck)
def chgVarUbGlobal(self, Variable, var, ub)
SCIP_Real SCIPgetDualfarkasLinear(SCIP *scip, SCIP_CONS *cons)
def writeProblem(self, filename='model.cip', trans=False)
def addConsSOS1(self, vars, weights=None, name="SOS1cons", initial=True, separate=True, enforce=True, check=True, propagate=True, local=False, dynamic=False, removable=False, stickingatnode=False)
def getCutEfficacy(self, Row, cut, not, None, Solution, sol=None)
int SCIPgetNLinearVarsQuadratic(SCIP *scip, SCIP_CONS *cons)
def printRow(self, Row, row, not, None)
int SCIPgetNSols(SCIP *scip)
SCIP_RETCODE SCIPincludePresol(SCIP *scip, const char *name, const char *desc, int priority, int maxrounds, SCIP_PRESOLTIMING timing, SCIP_DECL_PRESOLCOPY((*presolcopy)), SCIP_DECL_PRESOLFREE((*presolfree)), SCIP_DECL_PRESOLINIT((*presolinit)), SCIP_DECL_PRESOLEXIT((*presolexit)), SCIP_DECL_PRESOLINITPRE((*presolinitpre)), SCIP_DECL_PRESOLEXITPRE((*presolexitpre)), SCIP_DECL_PRESOLEXEC((*presolexec)), SCIP_PRESOLDATA *presoldata)
int SCIProwGetLPPos(SCIP_ROW *row)
SCIP_RETCODE SCIPchgVarUbGlobal(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
SCIP_RETCODE SCIPsetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real val)
SCIP_SEPA * SCIPfindSepa(SCIP *scip, const char *name)
int SCIPgetNLPRows(SCIP *scip)
def addSol(self, Solution, solution, free=True)
def getRhs(self, Constraint, cons)
SCIP_OBJSENSE SCIPgetObjsense(SCIP *scip)
def chgRhs(self, Constraint, cons, rhs)
SCIP_Real SCIProwGetConstant(SCIP_ROW *row)
def catchRowEvent(self, Row, row, eventtype, Eventhdlr, eventhdlr)
SCIP_NODE * SCIPnodeGetParent(SCIP_NODE *node)
SCIP_RETCODE SCIPsetConsChecked(SCIP *scip, SCIP_CONS *cons, SCIP_Bool check)
SCIP_Bool SCIProwIsIntegral(SCIP_ROW *row)
SCIP_RETCODE SCIPcreateEmptyRowUnspec(SCIP *scip, SCIP_ROW **row, const char *name, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool removable)
def getDualfarkasLinear(self, Constraint, cons)
def setEnforced(self, Constraint, cons, newEnf)
def disablePropagation(self, onlyroot=False)
SCIP_Bool SCIPisFeasZero(SCIP *scip, SCIP_Real val)
SCIP_Real SCIPgetObjlimit(SCIP *scip)
def tightenVarUbGlobal(self, Variable, var, ub, force=False)
SCIP_Real SCIPgetLPObjval(SCIP *scip)
SCIP_HEUR * SCIPfindHeur(SCIP *scip, const char *name)
SCIP_RETCODE SCIPreleaseRow(SCIP *scip, SCIP_ROW **row)
SCIP_RETCODE SCIPtrySolFree(SCIP *scip, SCIP_SOL **sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
def createProbBasic(self, problemName='model')
SCIP_RETCODE SCIPchgRowRhsDive(SCIP *scip, SCIP_ROW *row, SCIP_Real newrhs)
int SCIPgetNOrigVars(SCIP *scip)
SCIP_Longint SCIPgetNLPs(SCIP *scip)
SCIP_RETCODE SCIPwriteParams(SCIP *scip, const char *filename, SCIP_Bool comments, SCIP_Bool onlychanged)
def freeSol(self, Solution, solution)
SCIP_Real SCIPgetTotalTime(SCIP *scip)
def addVarSOS2(self, Constraint, cons, Variable, var, weight)
def getVarUbDive(self, Variable, var)
SCIP_RETCODE SCIPtrySol(SCIP *scip, SCIP_SOL *sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
def addConsIndicator(self, cons, binvar=None, name="IndicatorCons", initial=True, separate=True, enforce=True, check=True, propagate=True, local=False, dynamic=False, removable=False, stickingatnode=False)
SCIP_RETCODE SCIPaddRow(SCIP *scip, SCIP_ROW *row, SCIP_Bool forcecut, SCIP_Bool *infeasible)
def setObjlimit(self, objlimit)
SCIP_RETCODE SCIPchgVarLb(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
SCIP_RETCODE SCIPreadSolFile(SCIP *scip, const char *filename, SCIP_SOL *sol, SCIP_Bool xml, SCIP_Bool *partial, SCIP_Bool *error)
SCIP_RETCODE SCIPdropVarEvent(SCIP *scip, SCIP_VAR *var, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int filterpos)
SCIP_Longint SCIPnodeGetNumber(SCIP_NODE *node)
const char * SCIPgetProbName(SCIP *scip)
SCIP_RETCODE SCIPincludeRelax(SCIP *scip, const char *name, const char *desc, int priority, int freq, SCIP_DECL_RELAXCOPY((*relaxcopy)), SCIP_DECL_RELAXFREE((*relaxfree)), SCIP_DECL_RELAXINIT((*relaxinit)), SCIP_DECL_RELAXEXIT((*relaxexit)), SCIP_DECL_RELAXINITSOL((*relaxinitsol)), SCIP_DECL_RELAXEXITSOL((*relaxexitsol)), SCIP_DECL_RELAXEXEC((*relaxexec)), SCIP_RELAXDATA *relaxdata)
def getValsLinear(self, Constraint, cons)
SCIP_Bool SCIProwIsModifiable(SCIP_ROW *row)
def addConsAnd(self, vars, resvar, name="ANDcons", initial=True, separate=True, enforce=True, check=True, propagate=True, local=False, modifiable=False, dynamic=False, removable=False, stickingatnode=False)
def printStatistics(self)
def chgVarObjDive(self, Variable, var, newobj)
SCIP_Bool SCIPisFeasNegative(SCIP *scip, SCIP_Real val)
SCIP_RETCODE SCIPcreate(SCIP **scip)
int SCIProwGetNNonz(SCIP_ROW *row)
SCIP_RETCODE SCIPsetRealParam(SCIP *scip, const char *name, SCIP_Real value)
SCIP_RETCODE SCIPincludeHeur(SCIP *scip, const char *name, const char *desc, char dispchar, int priority, int freq, int freqofs, int maxdepth, SCIP_HEURTIMING timingmask, SCIP_Bool usessubscip, SCIP_DECL_HEURCOPY((*heurcopy)), SCIP_DECL_HEURFREE((*heurfree)), SCIP_DECL_HEURINIT((*heurinit)), SCIP_DECL_HEUREXIT((*heurexit)), SCIP_DECL_HEURINITSOL((*heurinitsol)), SCIP_DECL_HEUREXITSOL((*heurexitsol)), SCIP_DECL_HEUREXEC((*heurexec)), SCIP_HEURDATA *heurdata)
def getLPBInvARow(self, row)
SCIP_RETCODE SCIPwriteOrigProblem(SCIP *scip, const char *filename, const char *extension, SCIP_Bool genericnames)
def isGE(self, val1, val2)
SCIP_RETCODE SCIPfreeTransform(SCIP *scip)
SCIP_Real SCIPeventGetNewbound(SCIP_EVENT *event)
SCIP_RETCODE SCIPprintBestSol(SCIP *scip, FILE *file, SCIP_Bool printzeros)
def setIntParam(self, name, value)
SCIP_Real * SCIProwGetVals(SCIP_ROW *row)
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
def isGT(self, val1, val2)
SCIP_RETCODE SCIPsolveProbingLP(SCIP *scip, int itlim, SCIP_Bool *lperror, SCIP_Bool *cutoff)
def inRepropagation(self)
int SCIPgetNLPCols(SCIP *scip)
SCIP_Real SCIPgetReadingTime(SCIP *scip)
SCIP_VAR ** SCIPgetVarsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPcheckSolOrig(SCIP *scip, SCIP_SOL *sol, SCIP_Bool *feasible, SCIP_Bool printreason, SCIP_Bool completely)
SCIP_RETCODE SCIPsolveBendersSubproblem(SCIP *scip, SCIP_BENDERS *benders, SCIP_SOL *sol, int probnumber, SCIP_Bool *infeasible, SCIP_BENDERSENFOTYPE type, SCIP_Bool solvecip, SCIP_Real *objective)
SCIP_Real * SCIPgetCoefsLinearVarsQuadratic(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPaddVarIndicator(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real val)
def addVar(self, name='', vtype='C', lb=0.0, ub=None, obj=0.0, pricedVar=False)
SCIP_RETCODE SCIPtransformVar(SCIP *scip, SCIP_VAR *var, SCIP_VAR **transvar)
def includeRelax(self, Relax, relax, name, desc, priority=10000, freq=1)
SCIP_RETCODE SCIPgetLPColsData(SCIP *scip, SCIP_COL ***cols, int *ncols)
SCIP_RETCODE SCIPcreateProbBasic(SCIP *scip, const char *name)
SCIP_RETCODE SCIPincludeConshdlr(SCIP *scip, const char *name, const char *desc, int sepapriority, int enfopriority, int chckpriority, int sepafreq, int propfreq, int eagerfreq, int maxprerounds, SCIP_Bool delaysepa, SCIP_Bool delayprop, SCIP_Bool needscons, SCIP_PROPTIMING proptiming, SCIP_PRESOLTIMING presoltiming, SCIP_DECL_CONSHDLRCOPY((*conshdlrcopy)), SCIP_DECL_CONSFREE((*consfree)), SCIP_DECL_CONSINIT((*consinit)), SCIP_DECL_CONSEXIT((*consexit)), SCIP_DECL_CONSINITPRE((*consinitpre)), SCIP_DECL_CONSEXITPRE((*consexitpre)), SCIP_DECL_CONSINITSOL((*consinitsol)), SCIP_DECL_CONSEXITSOL((*consexitsol)), SCIP_DECL_CONSDELETE((*consdelete)), SCIP_DECL_CONSTRANS((*constrans)), SCIP_DECL_CONSINITLP((*consinitlp)), SCIP_DECL_CONSSEPALP((*conssepalp)), SCIP_DECL_CONSSEPASOL((*conssepasol)), SCIP_DECL_CONSENFOLP((*consenfolp)), SCIP_DECL_CONSENFORELAX((*consenforelax)), SCIP_DECL_CONSENFOPS((*consenfops)), SCIP_DECL_CONSCHECK((*conscheck)), SCIP_DECL_CONSPROP((*consprop)), SCIP_DECL_CONSPRESOL((*conspresol)), SCIP_DECL_CONSRESPROP((*consresprop)), SCIP_DECL_CONSLOCK((*conslock)), SCIP_DECL_CONSACTIVE((*consactive)), SCIP_DECL_CONSDEACTIVE((*consdeactive)), SCIP_DECL_CONSENABLE((*consenable)), SCIP_DECL_CONSDISABLE((*consdisable)), SCIP_DECL_CONSDELVARS((*consdelvars)), SCIP_DECL_CONSPRINT((*consprint)), SCIP_DECL_CONSCOPY((*conscopy)), SCIP_DECL_CONSPARSE((*consparse)), SCIP_DECL_CONSGETVARS((*consgetvars)), SCIP_DECL_CONSGETNVARS((*consgetnvars)), SCIP_DECL_CONSGETDIVEBDCHGS((*consgetdivebdchgs)), SCIP_CONSHDLRDATA *conshdlrdata)
int SCIPgetNQuadVarTermsQuadratic(SCIP *scip, SCIP_CONS *cons)
def getSolObjVal(self, Solution, sol, original=True)
def dropRowEvent(self, Row, row, eventtype, Eventhdlr, eventhdlr)
SCIP_NODE * SCIPeventGetNode(SCIP_EVENT *event)
SCIP_NODE * SCIPgetCurrentNode(SCIP *scip)
def catchVarEvent(self, Variable, var, eventtype, Eventhdlr, eventhdlr)
SCIP_RETCODE SCIPwriteTransProblem(SCIP *scip, const char *filename, const char *extension, SCIP_Bool genericnames)
SCIP_RETCODE SCIPchgLhsQuadratic(SCIP *scip, SCIP_CONS *cons, SCIP_Real lhs)
def getVal(self, Variable, var)
SCIP_RETCODE SCIPsetCharParam(SCIP *scip, const char *name, char value)
SCIP_RETCODE SCIPaddVarSOS1(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real weight)
SCIP_RETCODE SCIPsetProbName(SCIP *scip, const char *name)
SCIP_Real SCIPvarGetLbOriginal(SCIP_VAR *var)
def getNCountedSols(self)
def getObjoffset(self, original=True)
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
SCIP_Real SCIPgetRowActivity(SCIP *scip, SCIP_ROW *row)
SCIP_RETCODE SCIPcreateConsLinear(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *vals, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
def addVarToRow(self, Row, row, not, None, Variable, var, not, None, value)
void SCIPvarSetData(SCIP_VAR *var, SCIP_VARDATA *vardata)
def readProblem(self, file, extension=None)
SCIP_Bool SCIPisGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
def getDualMultiplier(self, Constraint, cons)
def getVars(self, transformed=False)
def getVarLbDive(self, Variable, var)
def setRelaxSolVal(self, Variable, var, val)
SCIP_Bool SCIPconsIsChecked(SCIP_CONS *cons)
SCIP_RETCODE SCIPresetParam(SCIP *scip, const char *name)
SCIP_EVENTTYPE SCIPeventGetType(SCIP_EVENT *event)
SCIP_RETCODE SCIPsolve(SCIP *scip)
SCIP_PRICER * SCIPfindPricer(SCIP *scip, const char *name)
SCIP_Bool SCIPconsIsModifiable(SCIP_CONS *cons)
SCIP_Real SCIProwGetLhs(SCIP_ROW *row)
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
SCIP_RETCODE SCIPinterruptSolve(SCIP *scip)
def includePricer(self, Pricer, pricer, name, desc, priority=1, delay=True)
SCIP_Real SCIPgetLhsLinear(SCIP *scip, SCIP_CONS *cons)
const char * SCIPvarGetName(SCIP_VAR *var)
SCIP_RETCODE SCIPwriteVarName(SCIP *scip, FILE *file, SCIP_VAR *var, SCIP_Bool type)
SCIP_RETCODE SCIPprintSol(SCIP *scip, SCIP_SOL *sol, FILE *file, SCIP_Bool printzeros)
SCIP_Bool SCIPisLPSolBasic(SCIP *scip)
def includePresol(self, Presol, presol, name, desc, priority, maxrounds, timing=SCIP_PRESOLTIMING_FAST)
SCIP_Real SCIPgetActivityLinear(SCIP *scip, SCIP_CONS *cons, SCIP_SOL *sol)
def addBendersSubproblem(self, str, name, subproblem)
SCIP_RETCODE SCIPsetConsInitial(SCIP *scip, SCIP_CONS *cons, SCIP_Bool initial)
SCIP_RETCODE SCIPaddObjoffset(SCIP *scip, SCIP_Real addval)
SCIP_Bool SCIPinRepropagation(SCIP *scip)
def includeDefaultPlugins(self)
def setRealParam(self, name, value)
def updateBendersLowerbounds(self, lowerbounds, Benders, benders=None)
SCIP_RETCODE SCIPincludeProp(SCIP *scip, const char *name, const char *desc, int priority, int freq, SCIP_Bool delay, SCIP_PROPTIMING timingmask, int presolpriority, int presolmaxrounds, SCIP_PRESOLTIMING presoltiming, SCIP_DECL_PROPCOPY((*propcopy)), SCIP_DECL_PROPFREE((*propfree)), SCIP_DECL_PROPINIT((*propinit)), SCIP_DECL_PROPEXIT((*propexit)), SCIP_DECL_PROPINITPRE((*propinitpre)), SCIP_DECL_PROPEXITPRE((*propexitpre)), SCIP_DECL_PROPINITSOL((*propinitsol)), SCIP_DECL_PROPEXITSOL((*propexitsol)), SCIP_DECL_PROPPRESOL((*proppresol)), SCIP_DECL_PROPEXEC((*propexec)), SCIP_DECL_PROPRESPROP((*propresprop)), SCIP_PROPDATA *propdata)
def isLT(self, val1, val2)
SCIP_Real SCIPgetVarRedcost(SCIP *scip, SCIP_VAR *var)
SCIP_Bool SCIPconsIsPropagated(SCIP_CONS *cons)
SCIP_Real SCIPcolGetPrimsol(SCIP_COL *col)
def chgVarLbDive(self, Variable, var, newbound)
def releaseVar(self, Variable, var)
SCIP_EVENTHDLR * SCIPfindEventhdlr(SCIP *scip, const char *name)
SCIP_RETCODE SCIPcount(SCIP *scip)
SCIP_RETCODE SCIPchgVarUbDive(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
def initBendersDefault(self, subproblems)
def createEmptyRowUnspec(self, name="row", lhs=0.0, rhs=None, local=True, modifiable=False, removable=True)
SCIP_Real SCIPversion(void)
SCIP_RETCODE SCIPaddBendersSubproblem(SCIP *scip, SCIP_BENDERS *benders, SCIP *subproblem)
def getTransformedCons(self, Constraint, cons)
SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
SCIP_RETCODE SCIPappendVarCardinality(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_VAR *indvar)
SCIP_RETCODE SCIPsetSeparating(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
SCIP_VAR * SCIPeventGetVar(SCIP_EVENT *event)
SCIP_RETCODE SCIPtightenVarUb(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound, SCIP_Bool force, SCIP_Bool *infeasible, SCIP_Bool *tightened)
SCIP_RETCODE SCIPcatchRowEvent(SCIP *scip, SCIP_ROW *row, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int *filterpos)
def chgVarType(self, Variable, var, vtype)
SCIP_RETCODE SCIPactivatePricer(SCIP *scip, SCIP_PRICER *pricer)
SCIP_RETCODE SCIPcreateConsIndicator(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_VAR *binvar, int nvars, SCIP_VAR **vars, SCIP_Real *vals, SCIP_Real rhs, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
SCIP_RETCODE SCIPaddCons(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPaddRowDive(SCIP *scip, SCIP_ROW *row)
SCIP_Bool SCIPconsIsSeparated(SCIP_CONS *cons)
SCIP_RETCODE SCIPgetLPBasisInd(SCIP *scip, int *basisind)
def addPoolCut(self, Row, row, not, None)
def includeSepa(self, Sepa, sepa, name, desc, priority=0, freq=10, maxbounddist=1.0, usessubscip=False, delay=False)
def getSlack(self, Constraint, cons, Solution, sol=None, side=None)
SCIP_RETCODE SCIPexprtreeSetVars(SCIP_EXPRTREE *tree, int nvars, SCIP_VAR **vars)
SCIP_RETCODE SCIPgetLPRowsData(SCIP *scip, SCIP_ROW ***rows, int *nrows)
def chgLhs(self, Constraint, cons, lhs)
def freeBendersSubproblems(self)
def writeName(self, Variable, var)
SCIP_VAR ** SCIPgetLinearVarsQuadratic(SCIP *scip, SCIP_CONS *cons)
def fixVarProbing(self, Variable, var, fixedval)
def includeBenders(self, Benders, benders, name, desc, priority=1, cutlp=True, cutpseudo=True, cutrelax=True, shareaux=False)
def tightenVarLb(self, Variable, var, lb, force=False)
def isFeasNegative(self, value)
SCIP_RETCODE SCIPcreateConsXor(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_Bool rhs, int nvars, SCIP_VAR **vars, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
SCIP_RETCODE SCIPaddVar(SCIP *scip, SCIP_VAR *var)
SCIP_RETCODE SCIPsetHeuristics(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
def includeProp(self, Prop, prop, name, desc, presolpriority, presolmaxrounds, proptiming, presoltiming=SCIP_PRESOLTIMING_FAST, priority=1, freq=1, delay=True)
SCIP_RETCODE SCIPchgRhsQuadratic(SCIP *scip, SCIP_CONS *cons, SCIP_Real rhs)
SCIP_RETCODE SCIPchgVarLbGlobal(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
def createChild(self, nodeselprio, estimate)
def flushRowExtensions(self, Row, row, not, None)
SCIP_Bool SCIPconsIsEnforced(SCIP_CONS *cons)
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
SCIP_RETCODE SCIPgetLPBInvARow(SCIP *scip, int r, SCIP_Real *binvrow, SCIP_Real *coefs, int *inds, int *ninds)
SCIP_Real SCIPgetVarLbDive(SCIP *scip, SCIP_VAR *var)
def tightenVarLbGlobal(self, Variable, var, lb, force=False)
SCIP_RETCODE SCIPincludeBranchrule(SCIP *scip, const char *name, const char *desc, int priority, int maxdepth, SCIP_Real maxbounddist, SCIP_DECL_BRANCHCOPY((*branchcopy)), SCIP_DECL_BRANCHFREE((*branchfree)), SCIP_DECL_BRANCHINIT((*branchinit)), SCIP_DECL_BRANCHEXIT((*branchexit)), SCIP_DECL_BRANCHINITSOL((*branchinitsol)), SCIP_DECL_BRANCHEXITSOL((*branchexitsol)), SCIP_DECL_BRANCHEXECLP((*branchexeclp)), SCIP_DECL_BRANCHEXECEXT((*branchexecext)), SCIP_DECL_BRANCHEXECPS((*branchexecps)), SCIP_BRANCHRULEDATA *branchruledata)
SCIP_Bool SCIPnodeIsActive(SCIP_NODE *node)
def chgVarLbNode(self, Node, node, Variable, var, lb)