PySCIPOpt  5.1.1
Python Interface for the SCIP Optimization Suite
scip.pxi
Go to the documentation of this file.
1 
3 import weakref
4 from os.path import abspath
5 from os.path import splitext
6 import os
7 import sys
8 import warnings
9 import locale
10 
11 cimport cython
12 from cpython cimport Py_INCREF, Py_DECREF
13 from cpython.pycapsule cimport PyCapsule_New, PyCapsule_IsValid, PyCapsule_GetPointer
14 from libc.stdlib cimport malloc, free
15 from libc.stdio cimport fdopen, fclose
16 from posix.stdio cimport fileno
17 
18 from collections.abc import Iterable
19 from itertools import repeat
20 from dataclasses import dataclass
21 
22 include "expr.pxi"
23 include "lp.pxi"
24 include "benders.pxi"
25 include "benderscut.pxi"
26 include "branchrule.pxi"
27 include "conshdlr.pxi"
28 include "cutsel.pxi"
29 include "event.pxi"
30 include "heuristic.pxi"
31 include "presol.pxi"
32 include "pricer.pxi"
33 include "propagator.pxi"
34 include "sepa.pxi"
35 include "reader.pxi"
36 include "relax.pxi"
37 include "nodesel.pxi"
38 
39 # recommended SCIP version; major version is required
40 MAJOR = 9
41 MINOR = 0
42 PATCH = 0
43 
44 # for external user functions use def; for functions used only inside the interface (starting with _) use cdef
45 # todo: check whether this is currently done like this
46 
47 if sys.version_info >= (3, 0):
48  str_conversion = lambda x:bytes(x,'utf-8')
49 else:
50  str_conversion = lambda x:x
51 
52 _SCIP_BOUNDTYPE_TO_STRING = {SCIP_BOUNDTYPE_UPPER: '<=',
53  SCIP_BOUNDTYPE_LOWER: '>='}
54 
55 # Mapping the SCIP_RESULT enum to a python class
56 # This is required to return SCIP_RESULT in the python code
57 # In __init__.py this is imported as SCIP_RESULT to keep the
58 # original naming scheme using capital letters
59 cdef class PY_SCIP_RESULT:
60  DIDNOTRUN = SCIP_DIDNOTRUN
61  DELAYED = SCIP_DELAYED
62  DIDNOTFIND = SCIP_DIDNOTFIND
63  FEASIBLE = SCIP_FEASIBLE
64  INFEASIBLE = SCIP_INFEASIBLE
65  UNBOUNDED = SCIP_UNBOUNDED
66  CUTOFF = SCIP_CUTOFF
67  SEPARATED = SCIP_SEPARATED
68  NEWROUND = SCIP_NEWROUND
69  REDUCEDDOM = SCIP_REDUCEDDOM
70  CONSADDED = SCIP_CONSADDED
71  CONSCHANGED = SCIP_CONSCHANGED
72  BRANCHED = SCIP_BRANCHED
73  SOLVELP = SCIP_SOLVELP
74  FOUNDSOL = SCIP_FOUNDSOL
75  SUSPENDED = SCIP_SUSPENDED
76  SUCCESS = SCIP_SUCCESS
77 
78 cdef class PY_SCIP_PARAMSETTING:
79  DEFAULT = SCIP_PARAMSETTING_DEFAULT
80  AGGRESSIVE = SCIP_PARAMSETTING_AGGRESSIVE
81  FAST = SCIP_PARAMSETTING_FAST
82  OFF = SCIP_PARAMSETTING_OFF
83 
84 cdef class PY_SCIP_PARAMEMPHASIS:
85  DEFAULT = SCIP_PARAMEMPHASIS_DEFAULT
86  CPSOLVER = SCIP_PARAMEMPHASIS_CPSOLVER
87  EASYCIP = SCIP_PARAMEMPHASIS_EASYCIP
88  FEASIBILITY = SCIP_PARAMEMPHASIS_FEASIBILITY
89  HARDLP = SCIP_PARAMEMPHASIS_HARDLP
90  OPTIMALITY = SCIP_PARAMEMPHASIS_OPTIMALITY
91  COUNTER = SCIP_PARAMEMPHASIS_COUNTER
92  PHASEFEAS = SCIP_PARAMEMPHASIS_PHASEFEAS
93  PHASEIMPROVE = SCIP_PARAMEMPHASIS_PHASEIMPROVE
94  PHASEPROOF = SCIP_PARAMEMPHASIS_PHASEPROOF
95  NUMERICS = SCIP_PARAMEMPHASIS_NUMERICS
96  BENCHMARK = SCIP_PARAMEMPHASIS_BENCHMARK
97 
98 cdef class PY_SCIP_STATUS:
99  UNKNOWN = SCIP_STATUS_UNKNOWN
100  USERINTERRUPT = SCIP_STATUS_USERINTERRUPT
101  NODELIMIT = SCIP_STATUS_NODELIMIT
102  TOTALNODELIMIT = SCIP_STATUS_TOTALNODELIMIT
103  STALLNODELIMIT = SCIP_STATUS_STALLNODELIMIT
104  TIMELIMIT = SCIP_STATUS_TIMELIMIT
105  MEMLIMIT = SCIP_STATUS_MEMLIMIT
106  GAPLIMIT = SCIP_STATUS_GAPLIMIT
107  SOLLIMIT = SCIP_STATUS_SOLLIMIT
108  BESTSOLLIMIT = SCIP_STATUS_BESTSOLLIMIT
109  RESTARTLIMIT = SCIP_STATUS_RESTARTLIMIT
110  PRIMALLIMIT = SCIP_STATUS_PRIMALLIMIT
111  DUALLIMIT = SCIP_STATUS_DUALLIMIT
112  OPTIMAL = SCIP_STATUS_OPTIMAL
113  INFEASIBLE = SCIP_STATUS_INFEASIBLE
114  UNBOUNDED = SCIP_STATUS_UNBOUNDED
115  INFORUNBD = SCIP_STATUS_INFORUNBD
116 
117 StageNames = {}
118 
119 cdef class PY_SCIP_STAGE:
120  INIT = SCIP_STAGE_INIT
121  PROBLEM = SCIP_STAGE_PROBLEM
122  TRANSFORMING = SCIP_STAGE_TRANSFORMING
123  TRANSFORMED = SCIP_STAGE_TRANSFORMED
124  INITPRESOLVE = SCIP_STAGE_INITPRESOLVE
125  PRESOLVING = SCIP_STAGE_PRESOLVING
126  EXITPRESOLVE = SCIP_STAGE_EXITPRESOLVE
127  PRESOLVED = SCIP_STAGE_PRESOLVED
128  INITSOLVE = SCIP_STAGE_INITSOLVE
129  SOLVING = SCIP_STAGE_SOLVING
130  SOLVED = SCIP_STAGE_SOLVED
131  EXITSOLVE = SCIP_STAGE_EXITSOLVE
132  FREETRANS = SCIP_STAGE_FREETRANS
133  FREE = SCIP_STAGE_FREE
134 
135 cdef class PY_SCIP_NODETYPE:
136  FOCUSNODE = SCIP_NODETYPE_FOCUSNODE
137  PROBINGNODE = SCIP_NODETYPE_PROBINGNODE
138  SIBLING = SCIP_NODETYPE_SIBLING
139  CHILD = SCIP_NODETYPE_CHILD
140  LEAF = SCIP_NODETYPE_LEAF
141  DEADEND = SCIP_NODETYPE_DEADEND
142  JUNCTION = SCIP_NODETYPE_JUNCTION
143  PSEUDOFORK = SCIP_NODETYPE_PSEUDOFORK
144  FORK = SCIP_NODETYPE_FORK
145  SUBROOT = SCIP_NODETYPE_SUBROOT
146  REFOCUSNODE = SCIP_NODETYPE_REFOCUSNODE
147 
148 
149 cdef class PY_SCIP_PROPTIMING:
150  BEFORELP = SCIP_PROPTIMING_BEFORELP
151  DURINGLPLOOP = SCIP_PROPTIMING_DURINGLPLOOP
152  AFTERLPLOOP = SCIP_PROPTIMING_AFTERLPLOOP
153  AFTERLPNODE = SCIP_PROPTIMING_AFTERLPNODE
154 
155 cdef class PY_SCIP_PRESOLTIMING:
156  NONE = SCIP_PRESOLTIMING_NONE
157  FAST = SCIP_PRESOLTIMING_FAST
158  MEDIUM = SCIP_PRESOLTIMING_MEDIUM
159  EXHAUSTIVE = SCIP_PRESOLTIMING_EXHAUSTIVE
160 
161 cdef class PY_SCIP_HEURTIMING:
162  BEFORENODE = SCIP_HEURTIMING_BEFORENODE
163  DURINGLPLOOP = SCIP_HEURTIMING_DURINGLPLOOP
164  AFTERLPLOOP = SCIP_HEURTIMING_AFTERLPLOOP
165  AFTERLPNODE = SCIP_HEURTIMING_AFTERLPNODE
166  AFTERPSEUDONODE = SCIP_HEURTIMING_AFTERPSEUDONODE
167  AFTERLPPLUNGE = SCIP_HEURTIMING_AFTERLPPLUNGE
168  AFTERPSEUDOPLUNGE = SCIP_HEURTIMING_AFTERPSEUDOPLUNGE
169  DURINGPRICINGLOOP = SCIP_HEURTIMING_DURINGPRICINGLOOP
170  BEFOREPRESOL = SCIP_HEURTIMING_BEFOREPRESOL
171  DURINGPRESOLLOOP = SCIP_HEURTIMING_DURINGPRESOLLOOP
172  AFTERPROPLOOP = SCIP_HEURTIMING_AFTERPROPLOOP
173 
174 EventNames = {}
175 
176 cdef class PY_SCIP_EVENTTYPE:
177  DISABLED = SCIP_EVENTTYPE_DISABLED
178  VARADDED = SCIP_EVENTTYPE_VARADDED
179  VARDELETED = SCIP_EVENTTYPE_VARDELETED
180  VARFIXED = SCIP_EVENTTYPE_VARFIXED
181  VARUNLOCKED = SCIP_EVENTTYPE_VARUNLOCKED
182  OBJCHANGED = SCIP_EVENTTYPE_OBJCHANGED
183  GLBCHANGED = SCIP_EVENTTYPE_GLBCHANGED
184  GUBCHANGED = SCIP_EVENTTYPE_GUBCHANGED
185  LBTIGHTENED = SCIP_EVENTTYPE_LBTIGHTENED
186  LBRELAXED = SCIP_EVENTTYPE_LBRELAXED
187  UBTIGHTENED = SCIP_EVENTTYPE_UBTIGHTENED
188  UBRELAXED = SCIP_EVENTTYPE_UBRELAXED
189  GHOLEADDED = SCIP_EVENTTYPE_GHOLEADDED
190  GHOLEREMOVED = SCIP_EVENTTYPE_GHOLEREMOVED
191  LHOLEADDED = SCIP_EVENTTYPE_LHOLEADDED
192  LHOLEREMOVED = SCIP_EVENTTYPE_LHOLEREMOVED
193  IMPLADDED = SCIP_EVENTTYPE_IMPLADDED
194  PRESOLVEROUND = SCIP_EVENTTYPE_PRESOLVEROUND
195  NODEFOCUSED = SCIP_EVENTTYPE_NODEFOCUSED
196  NODEFEASIBLE = SCIP_EVENTTYPE_NODEFEASIBLE
197  NODEINFEASIBLE = SCIP_EVENTTYPE_NODEINFEASIBLE
198  NODEBRANCHED = SCIP_EVENTTYPE_NODEBRANCHED
199  NODEDELETE = SCIP_EVENTTYPE_NODEDELETE
200  FIRSTLPSOLVED = SCIP_EVENTTYPE_FIRSTLPSOLVED
201  LPSOLVED = SCIP_EVENTTYPE_LPSOLVED
202  LPEVENT = SCIP_EVENTTYPE_LPEVENT
203  POORSOLFOUND = SCIP_EVENTTYPE_POORSOLFOUND
204  BESTSOLFOUND = SCIP_EVENTTYPE_BESTSOLFOUND
205  ROWADDEDSEPA = SCIP_EVENTTYPE_ROWADDEDSEPA
206  ROWDELETEDSEPA = SCIP_EVENTTYPE_ROWDELETEDSEPA
207  ROWADDEDLP = SCIP_EVENTTYPE_ROWADDEDLP
208  ROWDELETEDLP = SCIP_EVENTTYPE_ROWDELETEDLP
209  ROWCOEFCHANGED = SCIP_EVENTTYPE_ROWCOEFCHANGED
210  ROWCONSTCHANGED = SCIP_EVENTTYPE_ROWCONSTCHANGED
211  ROWSIDECHANGED = SCIP_EVENTTYPE_ROWSIDECHANGED
212  SYNC = SCIP_EVENTTYPE_SYNC
213  GBDCHANGED = SCIP_EVENTTYPE_GBDCHANGED
214  LBCHANGED = SCIP_EVENTTYPE_LBCHANGED
215  UBCHANGED = SCIP_EVENTTYPE_UBCHANGED
216  BOUNDTIGHTENED = SCIP_EVENTTYPE_BOUNDTIGHTENED
217  BOUNDRELAXED = SCIP_EVENTTYPE_BOUNDRELAXED
218  BOUNDCHANGED = SCIP_EVENTTYPE_BOUNDCHANGED
219  GHOLECHANGED = SCIP_EVENTTYPE_GHOLECHANGED
220  LHOLECHANGED = SCIP_EVENTTYPE_LHOLECHANGED
221  HOLECHANGED = SCIP_EVENTTYPE_HOLECHANGED
222  DOMCHANGED = SCIP_EVENTTYPE_DOMCHANGED
223  VARCHANGED = SCIP_EVENTTYPE_VARCHANGED
224  VAREVENT = SCIP_EVENTTYPE_VAREVENT
225  NODESOLVED = SCIP_EVENTTYPE_NODESOLVED
226  NODEEVENT = SCIP_EVENTTYPE_NODEEVENT
227  SOLFOUND = SCIP_EVENTTYPE_SOLFOUND
228  SOLEVENT = SCIP_EVENTTYPE_SOLEVENT
229  ROWCHANGED = SCIP_EVENTTYPE_ROWCHANGED
230  ROWEVENT = SCIP_EVENTTYPE_ROWEVENT
231 
232 
233 cdef class PY_SCIP_LPSOLSTAT:
234  NOTSOLVED = SCIP_LPSOLSTAT_NOTSOLVED
235  OPTIMAL = SCIP_LPSOLSTAT_OPTIMAL
236  INFEASIBLE = SCIP_LPSOLSTAT_INFEASIBLE
237  UNBOUNDEDRAY = SCIP_LPSOLSTAT_UNBOUNDEDRAY
238  OBJLIMIT = SCIP_LPSOLSTAT_OBJLIMIT
239  ITERLIMIT = SCIP_LPSOLSTAT_ITERLIMIT
240  TIMELIMIT = SCIP_LPSOLSTAT_TIMELIMIT
241  ERROR = SCIP_LPSOLSTAT_ERROR
242 
243 cdef class PY_SCIP_BRANCHDIR:
244  DOWNWARDS = SCIP_BRANCHDIR_DOWNWARDS
245  UPWARDS = SCIP_BRANCHDIR_UPWARDS
246  FIXED = SCIP_BRANCHDIR_FIXED
247  AUTO = SCIP_BRANCHDIR_AUTO
248 
249 cdef class PY_SCIP_BENDERSENFOTYPE:
250  LP = SCIP_BENDERSENFOTYPE_LP
251  RELAX = SCIP_BENDERSENFOTYPE_RELAX
252  PSEUDO = SCIP_BENDERSENFOTYPE_PSEUDO
253  CHECK = SCIP_BENDERSENFOTYPE_CHECK
254 
255 cdef class PY_SCIP_ROWORIGINTYPE:
256  UNSPEC = SCIP_ROWORIGINTYPE_UNSPEC
257  CONS = SCIP_ROWORIGINTYPE_CONS
258  SEPA = SCIP_ROWORIGINTYPE_SEPA
259  REOPT = SCIP_ROWORIGINTYPE_REOPT
260 
261 def PY_SCIP_CALL(SCIP_RETCODE rc):
262  if rc == SCIP_OKAY:
263  pass
264  elif rc == SCIP_ERROR:
265  raise Exception('SCIP: unspecified error!')
266  elif rc == SCIP_NOMEMORY:
267  raise MemoryError('SCIP: insufficient memory error!')
268  elif rc == SCIP_READERROR:
269  raise IOError('SCIP: read error!')
270  elif rc == SCIP_WRITEERROR:
271  raise IOError('SCIP: write error!')
272  elif rc == SCIP_NOFILE:
273  raise IOError('SCIP: file not found error!')
274  elif rc == SCIP_FILECREATEERROR:
275  raise IOError('SCIP: cannot create file!')
276  elif rc == SCIP_LPERROR:
277  raise Exception('SCIP: error in LP solver!')
278  elif rc == SCIP_NOPROBLEM:
279  raise Exception('SCIP: no problem exists!')
280  elif rc == SCIP_INVALIDCALL:
281  raise Exception('SCIP: method cannot be called at this time'
282  + ' in solution process!')
283  elif rc == SCIP_INVALIDDATA:
284  raise Exception('SCIP: error in input data!')
285  elif rc == SCIP_INVALIDRESULT:
286  raise Exception('SCIP: method returned an invalid result code!')
287  elif rc == SCIP_PLUGINNOTFOUND:
288  raise Exception('SCIP: a required plugin was not found !')
289  elif rc == SCIP_PARAMETERUNKNOWN:
290  raise KeyError('SCIP: the parameter with the given name was not found!')
291  elif rc == SCIP_PARAMETERWRONGTYPE:
292  raise LookupError('SCIP: the parameter is not of the expected type!')
293  elif rc == SCIP_PARAMETERWRONGVAL:
294  raise ValueError('SCIP: the value is invalid for the given parameter!')
295  elif rc == SCIP_KEYALREADYEXISTING:
296  raise KeyError('SCIP: the given key is already existing in table!')
297  elif rc == SCIP_MAXDEPTHLEVEL:
298  raise Exception('SCIP: maximal branching depth level exceeded!')
299  else:
300  raise Exception('SCIP: unknown return code!')
301 
302 cdef class Event:
303  """Base class holding a pointer to corresponding SCIP_EVENT"""
304 
305  @staticmethod
306  cdef create(SCIP_EVENT* scip_event):
307  if scip_event == NULL:
308  raise Warning("cannot create Event with SCIP_EVENT* == NULL")
309  event = Event()
310  event.event = scip_event
311  return event
312 
313  def getType(self):
314  """gets type of event"""
315  return SCIPeventGetType(self.event)
316 
317  def getName(self):
318  """gets name of event"""
319  if not EventNames:
320  self._getEventNames()
321  return EventNames[self.getType()]
322 
323  def _getEventNames(self):
324  """gets event names"""
325  for name in dir(PY_SCIP_EVENTTYPE):
326  attr = getattr(PY_SCIP_EVENTTYPE, name)
327  if isinstance(attr, int):
328  EventNames[attr] = name
329 
330  def __repr__(self):
331  return str(self.getType())
332 
333  def __str__(self):
334  return self.getName()
335 
336  def getNewBound(self):
337  """gets new bound for a bound change event"""
338  return SCIPeventGetNewbound(self.event)
339 
340  def getOldBound(self):
341  """gets old bound for a bound change event"""
342  return SCIPeventGetOldbound(self.event)
343 
344  def getVar(self):
345  """gets variable for a variable event (var added, var deleted, var fixed, objective value or domain change, domain hole added or removed)"""
346  cdef SCIP_VAR* var = SCIPeventGetVar(self.event)
347  return Variable.create(var)
348 
349  def getNode(self):
350  """gets node for a node or LP event"""
351  cdef SCIP_NODE* node = SCIPeventGetNode(self.event)
352  return Node.create(node)
353 
354  def getRow(self):
355  """gets row for a row event"""
356  cdef SCIP_ROW* row = SCIPeventGetRow(self.event)
357  return Row.create(row)
358 
359  def __hash__(self):
360  return hash(<size_t>self.event)
361 
362  def __eq__(self, other):
363  return (self.__class__ == other.__class__
364  and self.event == (<Event>other).event)
365 
366 cdef class Column:
367  """Base class holding a pointer to corresponding SCIP_COL"""
368 
369  @staticmethod
370  cdef create(SCIP_COL* scipcol):
371  if scipcol == NULL:
372  raise Warning("cannot create Column with SCIP_COL* == NULL")
373  col = Column()
374  col.scip_col = scipcol
375  return col
376 
377  def getLPPos(self):
378  """gets position of column in current LP, or -1 if it is not in LP"""
379  return SCIPcolGetLPPos(self.scip_col)
380 
381  def getBasisStatus(self):
382  """gets the basis status of a column in the LP solution, Note: returns basis status `zero` for columns not in the current SCIP LP"""
383  cdef SCIP_BASESTAT stat = SCIPcolGetBasisStatus(self.scip_col)
384  if stat == SCIP_BASESTAT_LOWER:
385  return "lower"
386  elif stat == SCIP_BASESTAT_BASIC:
387  return "basic"
388  elif stat == SCIP_BASESTAT_UPPER:
389  return "upper"
390  elif stat == SCIP_BASESTAT_ZERO:
391  return "zero"
392  else:
393  raise Exception('SCIP returned unknown base status!')
394 
395  def isIntegral(self):
396  """returns whether the associated variable is of integral type (binary, integer, implicit integer)"""
397  return SCIPcolIsIntegral(self.scip_col)
398 
399  def getVar(self):
400  """gets variable this column represents"""
401  cdef SCIP_VAR* var = SCIPcolGetVar(self.scip_col)
402  return Variable.create(var)
403 
404  def getPrimsol(self):
405  """gets the primal LP solution of a column"""
406  return SCIPcolGetPrimsol(self.scip_col)
407 
408  def getLb(self):
409  """gets lower bound of column"""
410  return SCIPcolGetLb(self.scip_col)
411 
412  def getUb(self):
413  """gets upper bound of column"""
414  return SCIPcolGetUb(self.scip_col)
415 
416  def getObjCoeff(self):
417  """gets objective value coefficient of a column"""
418  return SCIPcolGetObj(self.scip_col)
419 
420  def getAge(self):
421  """Gets the age of the column, i.e., the total number of successive times a column was in the LP
422  and was 0.0 in the solution"""
423  return SCIPcolGetAge(self.scip_col)
424 
425  def __hash__(self):
426  return hash(<size_t>self.scip_col)
427 
428  def __eq__(self, other):
429  return (self.__class__ == other.__class__
430  and self.scip_col == (<Column>other).scip_col)
431 
432 cdef class Row:
433  """Base class holding a pointer to corresponding SCIP_ROW"""
434 
435  @staticmethod
436  cdef create(SCIP_ROW* sciprow):
437  if sciprow == NULL:
438  raise Warning("cannot create Row with SCIP_ROW* == NULL")
439  row = Row()
440  row.scip_row = sciprow
441  return row
442 
443  property name:
444  def __get__(self):
445  cname = bytes( SCIProwGetName(self.scip_row) )
446  return cname.decode('utf-8')
447 
448  def getLhs(self):
449  """returns the left hand side of row"""
450  return SCIProwGetLhs(self.scip_row)
451 
452  def getRhs(self):
453  """returns the right hand side of row"""
454  return SCIProwGetRhs(self.scip_row)
455 
456  def getConstant(self):
457  """gets constant shift of row"""
458  return SCIProwGetConstant(self.scip_row)
459 
460  def getLPPos(self):
461  """gets position of row in current LP, or -1 if it is not in LP"""
462  return SCIProwGetLPPos(self.scip_row)
463 
464  def getBasisStatus(self):
465  """gets the basis status of a row in the LP solution, Note: returns basis status `basic` for rows not in the current SCIP LP"""
466  cdef SCIP_BASESTAT stat = SCIProwGetBasisStatus(self.scip_row)
467  if stat == SCIP_BASESTAT_LOWER:
468  return "lower"
469  elif stat == SCIP_BASESTAT_BASIC:
470  return "basic"
471  elif stat == SCIP_BASESTAT_UPPER:
472  return "upper"
473  elif stat == SCIP_BASESTAT_ZERO:
474  # this shouldn't happen!
475  raise Exception('SCIP returned base status zero for a row!')
476  else:
477  raise Exception('SCIP returned unknown base status!')
478 
479  def isIntegral(self):
480  """returns TRUE iff the activity of the row (without the row's constant) is always integral in a feasible solution """
481  return SCIProwIsIntegral(self.scip_row)
482 
483  def isLocal(self):
484  """returns TRUE iff the row is only valid locally """
485  return SCIProwIsLocal(self.scip_row)
486 
487  def isModifiable(self):
488  """returns TRUE iff row is modifiable during node processing (subject to column generation) """
489  return SCIProwIsModifiable(self.scip_row)
490 
491  def isRemovable(self):
492  """returns TRUE iff row is removable from the LP (due to aging or cleanup)"""
493  return SCIProwIsRemovable(self.scip_row)
494 
495  def isInGlobalCutpool(self):
496  """return TRUE iff row is a member of the global cut pool"""
498 
499  def getOrigintype(self):
500  """returns type of origin that created the row"""
501  return SCIProwGetOrigintype(self.scip_row)
502 
504  """returns type of constraint handler that created the row"""
505  cdef SCIP_CONS* scip_con = SCIProwGetOriginCons(self.scip_row)
506  return bytes(SCIPconshdlrGetName(SCIPconsGetHdlr(scip_con))).decode('UTF-8')
507 
508  def getNNonz(self):
509  """get number of nonzero entries in row vector"""
510  return SCIProwGetNNonz(self.scip_row)
511 
512  def getNLPNonz(self):
513  """get number of nonzero entries in row vector that correspond to columns currently in the SCIP LP"""
514  return SCIProwGetNLPNonz(self.scip_row)
515 
516  def getCols(self):
517  """gets list with columns of nonzero entries"""
518  cdef SCIP_COL** cols = SCIProwGetCols(self.scip_row)
519  return [Column.create(cols[i]) for i in range(self.getNNonz())]
520 
521  def getVals(self):
522  """gets list with coefficients of nonzero entries"""
523  cdef SCIP_Real* vals = SCIProwGetVals(self.scip_row)
524  return [vals[i] for i in range(self.getNNonz())]
525 
526  def getAge(self):
527  """Gets the age of the row. (The consecutive times the row has been non-active in the LP)"""
528  return SCIProwGetAge(self.scip_row)
529 
530  def getNorm(self):
531  """gets Euclidean norm of row vector """
532  return SCIProwGetNorm(self.scip_row)
533 
534  def __hash__(self):
535  return hash(<size_t>self.scip_row)
536 
537  def __eq__(self, other):
538  return (self.__class__ == other.__class__
539  and self.scip_row == (<Row>other).scip_row)
540 
541 cdef class NLRow:
542  """Base class holding a pointer to corresponding SCIP_NLROW"""
543 
544  @staticmethod
545  cdef create(SCIP_NLROW* scipnlrow):
546  if scipnlrow == NULL:
547  raise Warning("cannot create NLRow with SCIP_NLROW* == NULL")
548  nlrow = NLRow()
549  nlrow.scip_nlrow = scipnlrow
550  return nlrow
551 
552  property name:
553  def __get__(self):
554  cname = bytes( SCIPnlrowGetName(self.scip_nlrow) )
555  return cname.decode('utf-8')
556 
557  def getConstant(self):
558  """returns the constant of a nonlinear row"""
559  return SCIPnlrowGetConstant(self.scip_nlrow)
560 
561  def getLinearTerms(self):
562  """returns a list of tuples (var, coef) representing the linear part of a nonlinear row"""
563  cdef SCIP_VAR** linvars = SCIPnlrowGetLinearVars(self.scip_nlrow)
564  cdef SCIP_Real* lincoefs = SCIPnlrowGetLinearCoefs(self.scip_nlrow)
565  cdef int nlinvars = SCIPnlrowGetNLinearVars(self.scip_nlrow)
566  return [(Variable.create(linvars[i]), lincoefs[i]) for i in range(nlinvars)]
567 
568  def getLhs(self):
569  """returns the left hand side of a nonlinear row"""
570  return SCIPnlrowGetLhs(self.scip_nlrow)
571 
572  def getRhs(self):
573  """returns the right hand side of a nonlinear row"""
574  return SCIPnlrowGetRhs(self.scip_nlrow)
575 
576  def getDualsol(self):
577  """gets the dual NLP solution of a nonlinear row"""
578  return SCIPnlrowGetDualsol(self.scip_nlrow)
579 
580  def __hash__(self):
581  return hash(<size_t>self.scip_nlrow)
582 
583  def __eq__(self, other):
584  return (self.__class__ == other.__class__
585  and self.scip_nlrow == (<NLRow>other).scip_nlrow)
586 
587 cdef class Solution:
588  """Base class holding a pointer to corresponding SCIP_SOL"""
589 
590  # We are raising an error here to avoid creating a solution without an associated model. See Issue #625
591  def __init__(self, raise_error = False):
592  if not raise_error:
593  raise ValueError("To create a solution you should use the createSol method of the Model class.")
594 
595  @staticmethod
596  cdef create(SCIP* scip, SCIP_SOL* scip_sol):
597  if scip == NULL:
598  raise Warning("cannot create Solution with SCIP* == NULL")
599  sol = Solution(True)
600  sol.sol = scip_sol
601  sol.scip = scip
602  return sol
603 
604  def __getitem__(self, Expr expr):
605  # fast track for Variable
606  if isinstance(expr, Variable):
607  self._checkStage("SCIPgetSolVal")
608  var = <Variable> expr
609  return SCIPgetSolVal(self.scip, self.sol, var.scip_var)
610  return sum(self._evaluate(term)*coeff for term, coeff in expr.terms.items() if coeff != 0)
611 
612  def _evaluate(self, term):
613  self._checkStage("SCIPgetSolVal")
614  result = 1
615  for var in term.vartuple:
616  result *= SCIPgetSolVal(self.scip, self.sol, (<Variable> var).scip_var)
617  return result
618 
619  def __setitem__(self, Variable var, value):
620  PY_SCIP_CALL(SCIPsetSolVal(self.scip, self.sol, var.scip_var, value))
621 
622  def __repr__(self):
623  cdef SCIP_VAR* scip_var
624 
625  vals = {}
626  self._checkStage("SCIPgetSolVal")
627  for i in range(SCIPgetNOrigVars(self.scip)):
628  scip_var = SCIPgetOrigVars(self.scip)[i]
629 
630  # extract name
631  cname = bytes(SCIPvarGetName(scip_var))
632  name = cname.decode('utf-8')
633 
634  vals[name] = SCIPgetSolVal(self.scip, self.sol, scip_var)
635  return str(vals)
636 
637  def _checkStage(self, method):
638  if method in ["SCIPgetSolVal", "getSolObjVal"]:
639  stage_check = SCIPgetStage(self.scip) not in [SCIP_STAGE_INIT, SCIP_STAGE_FREE]
640 
641  if not stage_check or self.sol == NULL and SCIPgetStage(self.scip) != SCIP_STAGE_SOLVING:
642  raise Warning(f"{method} can only be called with a valid solution or in stage SOLVING (current stage: {SCIPgetStage(self.scip)})")
643 
644 
645 cdef class BoundChange:
646  """Bound change."""
647 
648  @staticmethod
649  cdef create(SCIP_BOUNDCHG* scip_boundchg):
650  if scip_boundchg == NULL:
651  raise Warning("cannot create BoundChange with SCIP_BOUNDCHG* == NULL")
652  boundchg = BoundChange()
653  boundchg.scip_boundchg = scip_boundchg
654  return boundchg
655 
656  def getNewBound(self):
657  """Returns the new value of the bound in the bound change."""
659 
660  def getVar(self):
661  """Returns the variable of the bound change."""
662  return Variable.create(SCIPboundchgGetVar(self.scip_boundchg))
663 
664  def getBoundchgtype(self):
665  """Returns the bound change type of the bound change."""
667 
668  def getBoundtype(self):
669  """Returns the bound type of the bound change."""
671 
672  def isRedundant(self):
673  """Returns whether the bound change is redundant due to a more global bound that is at least as strong."""
675 
676  def __repr__(self):
677  return "{} {} {}".format(self.getVar(),
678  _SCIP_BOUNDTYPE_TO_STRING[self.getBoundtype()],
679  self.getNewBound())
680 
681 cdef class DomainChanges:
682  """Set of domain changes."""
683 
684  @staticmethod
685  cdef create(SCIP_DOMCHG* scip_domchg):
686  if scip_domchg == NULL:
687  raise Warning("cannot create DomainChanges with SCIP_DOMCHG* == NULL")
688  domchg = DomainChanges()
689  domchg.scip_domchg = scip_domchg
690  return domchg
691 
692  def getBoundchgs(self):
693  """Returns the bound changes in the domain change."""
694  nboundchgs = SCIPdomchgGetNBoundchgs(self.scip_domchg)
695  return [BoundChange.create(SCIPdomchgGetBoundchg(self.scip_domchg, i))
696  for i in range(nboundchgs)]
697 
698 cdef class Node:
699  """Base class holding a pointer to corresponding SCIP_NODE"""
700 
701  @staticmethod
702  cdef create(SCIP_NODE* scipnode):
703  if scipnode == NULL:
704  return None
705  node = Node()
706  node.scip_node = scipnode
707  return node
708 
709  def getParent(self):
710  """Retrieve parent node (or None if the node has no parent node)."""
711  return Node.create(SCIPnodeGetParent(self.scip_node))
712 
713  def getNumber(self):
714  """Retrieve number of node."""
715  return SCIPnodeGetNumber(self.scip_node)
716 
717  def getDepth(self):
718  """Retrieve depth of node."""
719  return SCIPnodeGetDepth(self.scip_node)
720 
721  def getType(self):
722  """Retrieve type of node."""
723  return SCIPnodeGetType(self.scip_node)
724 
725  def getLowerbound(self):
726  """Retrieve lower bound of node."""
727  return SCIPnodeGetLowerbound(self.scip_node)
728 
729  def getEstimate(self):
730  """Retrieve the estimated value of the best feasible solution in subtree of the node"""
731  return SCIPnodeGetEstimate(self.scip_node)
732 
733  def getAddedConss(self):
734  """Retrieve all constraints added at this node."""
735  cdef int addedconsssize = SCIPnodeGetNAddedConss(self.scip_node)
736  if addedconsssize == 0:
737  return []
738  cdef SCIP_CONS** addedconss = <SCIP_CONS**> malloc(addedconsssize * sizeof(SCIP_CONS*))
739  cdef int nconss
740  SCIPnodeGetAddedConss(self.scip_node, addedconss, &nconss, addedconsssize)
741  assert nconss == addedconsssize
742  constraints = [Constraint.create(addedconss[i]) for i in range(nconss)]
743  free(addedconss)
744  return constraints
745 
746  def getNAddedConss(self):
747  """Retrieve number of added constraints at this node"""
748  return SCIPnodeGetNAddedConss(self.scip_node)
749 
750  def isActive(self):
751  """Is the node in the path to the current node?"""
752  return SCIPnodeIsActive(self.scip_node)
753 
754  def isPropagatedAgain(self):
755  """Is the node marked to be propagated again?"""
757 
759  """Retrieve the number of variable branchings that were performed in the parent node to create this node."""
760  cdef SCIP_VAR* dummy_branchvars
761  cdef SCIP_Real dummy_branchbounds
762  cdef SCIP_BOUNDTYPE dummy_boundtypes
763  cdef int nbranchvars
764  # This is a hack: the SCIP interface has no function to directly get the
765  # number of parent branchings, i.e., SCIPnodeGetNParentBranchings() does
766  # not exist.
767  SCIPnodeGetParentBranchings(self.scip_node, &dummy_branchvars,
768  &dummy_branchbounds, &dummy_boundtypes,
769  &nbranchvars, 0)
770  return nbranchvars
771 
773  """Retrieve the set of variable branchings that were performed in the parent node to create this node."""
774  cdef int nbranchvars = self.getNParentBranchings()
775  if nbranchvars == 0:
776  return None
777 
778  cdef SCIP_VAR** branchvars = <SCIP_VAR**> malloc(nbranchvars * sizeof(SCIP_VAR*))
779  cdef SCIP_Real* branchbounds = <SCIP_Real*> malloc(nbranchvars * sizeof(SCIP_Real))
780  cdef SCIP_BOUNDTYPE* boundtypes = <SCIP_BOUNDTYPE*> malloc(nbranchvars * sizeof(SCIP_BOUNDTYPE))
781 
782  SCIPnodeGetParentBranchings(self.scip_node, branchvars, branchbounds,
783  boundtypes, &nbranchvars, nbranchvars)
784 
785  py_variables = [Variable.create(branchvars[i]) for i in range(nbranchvars)]
786  py_branchbounds = [branchbounds[i] for i in range(nbranchvars)]
787  py_boundtypes = [boundtypes[i] for i in range(nbranchvars)]
788 
789  free(boundtypes)
790  free(branchbounds)
791  free(branchvars)
792  return py_variables, py_branchbounds, py_boundtypes
793 
794  def getNDomchg(self):
795  """Retrieve the number of bound changes due to branching, constraint propagation, and propagation."""
796  cdef int nbranchings
797  cdef int nconsprop
798  cdef int nprop
799  SCIPnodeGetNDomchg(self.scip_node, &nbranchings, &nconsprop, &nprop)
800  return nbranchings, nconsprop, nprop
801 
802  def getDomchg(self):
803  """Retrieve domain changes for this node."""
804  cdef SCIP_DOMCHG* domchg = SCIPnodeGetDomchg(self.scip_node)
805  if domchg == NULL:
806  return None
807  return DomainChanges.create(domchg)
808 
809  def __hash__(self):
810  return hash(<size_t>self.scip_node)
811 
812  def __eq__(self, other):
813  return (self.__class__ == other.__class__
814  and self.scip_node == (<Node>other).scip_node)
815 
816 cdef class Variable(Expr):
817  """Is a linear expression and has SCIP_VAR*"""
818 
819  @staticmethod
820  cdef create(SCIP_VAR* scipvar):
821  if scipvar == NULL:
822  raise Warning("cannot create Variable with SCIP_VAR* == NULL")
823  var = Variable()
824  var.scip_var = scipvar
825  Expr.__init__(var, {Term(var) : 1.0})
826  return var
827 
828  property name:
829  def __get__(self):
830  cname = bytes( SCIPvarGetName(self.scip_var) )
831  return cname.decode('utf-8')
832 
833  def ptr(self):
834  """ """
835  return <size_t>(self.scip_var)
836 
837  def __repr__(self):
838  return self.name
839 
840  def vtype(self):
841  """Retrieve the variables type (BINARY, INTEGER, IMPLINT or CONTINUOUS)"""
842  vartype = SCIPvarGetType(self.scip_var)
843  if vartype == SCIP_VARTYPE_BINARY:
844  return "BINARY"
845  elif vartype == SCIP_VARTYPE_INTEGER:
846  return "INTEGER"
847  elif vartype == SCIP_VARTYPE_CONTINUOUS:
848  return "CONTINUOUS"
849  elif vartype == SCIP_VARTYPE_IMPLINT:
850  return "IMPLINT"
851 
852  def isOriginal(self):
853  """Retrieve whether the variable belongs to the original problem"""
854  return SCIPvarIsOriginal(self.scip_var)
855 
856  def isInLP(self):
857  """Retrieve whether the variable is a COLUMN variable that is member of the current LP"""
858  return SCIPvarIsInLP(self.scip_var)
859 
860 
861  def getIndex(self):
862  """Retrieve the unique index of the variable."""
863  return SCIPvarGetIndex(self.scip_var)
864 
865  def getCol(self):
866  """Retrieve column of COLUMN variable"""
867  cdef SCIP_COL* scip_col
868  scip_col = SCIPvarGetCol(self.scip_var)
869  return Column.create(scip_col)
870 
871  def getLbOriginal(self):
872  """Retrieve original lower bound of variable"""
873  return SCIPvarGetLbOriginal(self.scip_var)
874 
875  def getUbOriginal(self):
876  """Retrieve original upper bound of variable"""
877  return SCIPvarGetUbOriginal(self.scip_var)
878 
879  def getLbGlobal(self):
880  """Retrieve global lower bound of variable"""
881  return SCIPvarGetLbGlobal(self.scip_var)
882 
883  def getUbGlobal(self):
884  """Retrieve global upper bound of variable"""
885  return SCIPvarGetUbGlobal(self.scip_var)
886 
887  def getLbLocal(self):
888  """Retrieve current lower bound of variable"""
889  return SCIPvarGetLbLocal(self.scip_var)
890 
891  def getUbLocal(self):
892  """Retrieve current upper bound of variable"""
893  return SCIPvarGetUbLocal(self.scip_var)
894 
895  def getObj(self):
896  """Retrieve current objective value of variable"""
897  return SCIPvarGetObj(self.scip_var)
898 
899  def getLPSol(self):
900  """Retrieve the current LP solution value of variable"""
901  return SCIPvarGetLPSol(self.scip_var)
902 
903  def getAvgSol(self):
904  """Get the weighted average solution of variable in all feasible primal solutions found"""
905  return SCIPvarGetAvgSol(self.scip_var)
906 
907 cdef class Constraint:
908  """Base class holding a pointer to corresponding SCIP_CONS"""
909 
910  @staticmethod
911  cdef create(SCIP_CONS* scipcons):
912  if scipcons == NULL:
913  raise Warning("cannot create Constraint with SCIP_CONS* == NULL")
914  cons = Constraint()
915  cons.scip_cons = scipcons
916  return cons
917 
918  property name:
919  def __get__(self):
920  cname = bytes( SCIPconsGetName(self.scip_cons) )
921  return cname.decode('utf-8')
922 
923  def __repr__(self):
924  return self.name
925 
926  def isOriginal(self):
927  """Retrieve whether the constraint belongs to the original problem"""
928  return SCIPconsIsOriginal(self.scip_cons)
929 
930  def isInitial(self):
931  """Retrieve True if the relaxation of the constraint should be in the initial LP"""
932  return SCIPconsIsInitial(self.scip_cons)
933 
934  def isSeparated(self):
935  """Retrieve True if constraint should be separated during LP processing"""
936  return SCIPconsIsSeparated(self.scip_cons)
937 
938  def isEnforced(self):
939  """Retrieve True if constraint should be enforced during node processing"""
940  return SCIPconsIsEnforced(self.scip_cons)
941 
942  def isChecked(self):
943  """Retrieve True if constraint should be checked for feasibility"""
944  return SCIPconsIsChecked(self.scip_cons)
945 
946  def isPropagated(self):
947  """Retrieve True if constraint should be propagated during node processing"""
948  return SCIPconsIsPropagated(self.scip_cons)
949 
950  def isLocal(self):
951  """Retrieve True if constraint is only locally valid or not added to any (sub)problem"""
952  return SCIPconsIsLocal(self.scip_cons)
953 
954  def isModifiable(self):
955  """Retrieve True if constraint is modifiable (subject to column generation)"""
956  return SCIPconsIsModifiable(self.scip_cons)
957 
958  def isDynamic(self):
959  """Retrieve True if constraint is subject to aging"""
960  return SCIPconsIsDynamic(self.scip_cons)
961 
962  def isRemovable(self):
963  """Retrieve True if constraint's relaxation should be removed from the LP due to aging or cleanup"""
964  return SCIPconsIsRemovable(self.scip_cons)
965 
966  def isStickingAtNode(self):
967  """Retrieve True if constraint is only locally valid or not added to any (sub)problem"""
969 
970  def isActive(self):
971  """returns True iff constraint is active in the current node"""
972  return SCIPconsIsActive(self.scip_cons)
973 
974  def isLinear(self):
975  """Retrieve True if constraint is linear"""
976  constype = bytes(SCIPconshdlrGetName(SCIPconsGetHdlr(self.scip_cons))).decode('UTF-8')
977  return constype == 'linear'
978 
979  def isNonlinear(self):
980  """Retrieve True if constraint is nonlinear"""
981  constype = bytes(SCIPconshdlrGetName(SCIPconsGetHdlr(self.scip_cons))).decode('UTF-8')
982  return constype == 'nonlinear'
983 
984  def getConshdlrName(self):
985  """Return the constraint handler's name"""
986  constype = bytes(SCIPconshdlrGetName(SCIPconsGetHdlr(self.scip_cons))).decode('UTF-8')
987  return constype
988 
989  def __hash__(self):
990  return hash(<size_t>self.scip_cons)
991 
992  def __eq__(self, other):
993  return (self.__class__ == other.__class__
994  and self.scip_cons == (<Constraint>other).scip_cons)
995 
996 
997 cdef void relayMessage(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char *msg) noexcept:
998  sys.stdout.write(msg.decode('UTF-8'))
999 
1000 cdef void relayErrorMessage(void *messagehdlr, FILE *file, const char *msg) noexcept:
1001  sys.stderr.write(msg.decode('UTF-8'))
1002 
1003 # - remove create(), includeDefaultPlugins(), createProbBasic() methods
1004 # - replace free() by "destructor"
1005 # - interface SCIPfreeProb()
1006 
1009 cdef class Model:
1010  """Main class holding a pointer to SCIP for managing most interactions"""
1011 
1012  def __init__(self, problemName='model', defaultPlugins=True, Model sourceModel=None, origcopy=False, globalcopy=True, enablepricing=False, createscip=True, threadsafe=False):
1013  """
1014  :param problemName: name of the problem (default 'model')
1015  :param defaultPlugins: use default plugins? (default True)
1016  :param sourceModel: create a copy of the given Model instance (default None)
1017  :param origcopy: whether to call copy or copyOrig (default False)
1018  :param globalcopy: whether to create a global or a local copy (default True)
1019  :param enablepricing: whether to enable pricing in copy (default False)
1020  :param createscip: initialize the Model object and creates a SCIP instance
1021  :param threadsafe: False if data can be safely shared between the source and target problem
1022  """
1023  if self.version() < MAJOR:
1024  raise Exception("linked SCIP is not compatible to this version of PySCIPOpt - use at least version", MAJOR)
1025  if self.version() < MAJOR + MINOR/10.0 + PATCH/100.0:
1026  warnings.warn("linked SCIP {} is not recommended for this version of PySCIPOpt - use version {}.{}.{}".format(self.version(), MAJOR, MINOR, PATCH))
1027 
1028  self._freescip = True
1029  self._modelvars = {}
1030 
1031  if not createscip:
1032  # if no SCIP instance should be created, then an empty Model object is created.
1033  self._scip = NULL
1034  self._bestSol = None
1035  self._freescip = False
1036  elif sourceModel is None:
1037  PY_SCIP_CALL(SCIPcreate(&self._scip))
1038  self._bestSol = None
1039  if defaultPlugins:
1040  self.includeDefaultPlugins()
1041  self.createProbBasic(problemName)
1042  else:
1043  PY_SCIP_CALL(SCIPcreate(&self._scip))
1044  self._bestSol = <Solution> sourceModel._bestSol
1045  n = str_conversion(problemName)
1046  if origcopy:
1047  PY_SCIP_CALL(SCIPcopyOrig(sourceModel._scip, self._scip, NULL, NULL, n, enablepricing, threadsafe, True, self._valid))
1048  else:
1049  PY_SCIP_CALL(SCIPcopy(sourceModel._scip, self._scip, NULL, NULL, n, globalcopy, enablepricing, threadsafe, True, self._valid))
1050 
1051  def __dealloc__(self):
1052  # call C function directly, because we can no longer call this object's methods, according to
1053  # http://docs.cython.org/src/reference/extension_types.html#finalization-dealloc
1054  if self._scip is not NULL and self._freescip and PY_SCIP_CALL:
1055  PY_SCIP_CALL( SCIPfree(&self._scip) )
1056 
1057  def __hash__(self):
1058  return hash(<size_t>self._scip)
1059 
1060  def __eq__(self, other):
1061  return (self.__class__ == other.__class__
1062  and self._scip == (<Model>other)._scip)
1063 
1064  @staticmethod
1065  cdef create(SCIP* scip):
1066  """Creates a model and appropriately assigns the scip and bestsol parameters
1067  """
1068  if scip == NULL:
1069  raise Warning("cannot create Model with SCIP* == NULL")
1070  model = Model(createscip=False)
1071  model._scip = scip
1072  model._bestSol = Solution.create(scip, SCIPgetBestSol(scip))
1073  return model
1074 
1075  @property
1076  def _freescip(self):
1077  """Return whether the underlying Scip pointer gets deallocted when the current
1078  object is deleted.
1079  """
1080  return self._freescip
1081 
1082  @_freescip.setter
1083  def _freescip(self, val):
1084  """Set whether the underlying Scip pointer gets deallocted when the current
1085  object is deleted.
1086  """
1087  self._freescip = val
1088 
1089  @cython.always_allow_keywords(True)
1090  @staticmethod
1091  def from_ptr(capsule, take_ownership):
1092  """Create a Model from a given pointer.
1093 
1094  :param cpasule: The PyCapsule containing the SCIP pointer under the name "scip".
1095  :param take_ownership: Whether the newly created Model assumes ownership of the
1096  underlying Scip pointer (see `_freescip`).
1097  """
1098  if not PyCapsule_IsValid(capsule, "scip"):
1099  raise ValueError("The given capsule does not contain a valid scip pointer")
1100  model = Model.create(<SCIP*>PyCapsule_GetPointer(capsule, "scip"))
1101  model._freescip = take_ownership
1102  return model
1103 
1104  @cython.always_allow_keywords(True)
1105  def to_ptr(self, give_ownership):
1106  """Return the underlying Scip pointer to the current Model.
1107 
1108  :param give_ownership: Whether the current Model gives away ownership of the
1109  underlying Scip pointer (see `_freescip`).
1110  :return capsule: The underlying pointer to the current Model, wrapped in a
1111  PyCapsule under the name "scip".
1112  """
1113  capsule = PyCapsule_New(<void*>self._scip, "scip", NULL)
1114  if give_ownership:
1115  self._freescip = False
1116  return capsule
1117 
1119  """Includes all default plug-ins into SCIP"""
1120  PY_SCIP_CALL(SCIPincludeDefaultPlugins(self._scip))
1121 
1122  def createProbBasic(self, problemName='model'):
1123  """Create new problem instance with given name
1124 
1125  :param problemName: name of model or problem (Default value = 'model')
1126 
1127  """
1128  n = str_conversion(problemName)
1129  PY_SCIP_CALL(SCIPcreateProbBasic(self._scip, n))
1130 
1131  def freeProb(self):
1132  """Frees problem and solution process data"""
1133  PY_SCIP_CALL(SCIPfreeProb(self._scip))
1134 
1135  def freeTransform(self):
1136  """Frees all solution process data including presolving and transformed problem, only original problem is kept"""
1137  self._modelvars = {
1138  var: value
1139  for var, value in self._modelvars.items()
1140  if value.isOriginal()
1141  }
1142  PY_SCIP_CALL(SCIPfreeTransform(self._scip))
1143 
1144  def version(self):
1145  """Retrieve SCIP version"""
1146  return SCIPversion()
1147 
1148  def printVersion(self):
1149  """Print version, copyright information and compile mode"""
1150  user_locale = locale.getlocale(category=locale.LC_NUMERIC)
1151  locale.setlocale(locale.LC_NUMERIC, "C")
1152 
1153  SCIPprintVersion(self._scip, NULL)
1154 
1155  locale.setlocale(locale.LC_NUMERIC,user_locale)
1156 
1158  """Print external code versions, e.g. symmetry, non-linear solver, lp solver"""
1159  user_locale = locale.getlocale(category=locale.LC_NUMERIC)
1160  locale.setlocale(locale.LC_NUMERIC, "C")
1161 
1162  SCIPprintExternalCodes(self._scip, NULL)
1163 
1164  locale.setlocale(locale.LC_NUMERIC,user_locale)
1165 
1166  def getProbName(self):
1167  """Retrieve problem name"""
1168  return bytes(SCIPgetProbName(self._scip)).decode('UTF-8')
1169 
1170  def getTotalTime(self):
1171  """Retrieve the current total SCIP time in seconds, i.e. the total time since the SCIP instance has been created"""
1172  return SCIPgetTotalTime(self._scip)
1173 
1174  def getSolvingTime(self):
1175  """Retrieve the current solving time in seconds"""
1176  return SCIPgetSolvingTime(self._scip)
1177 
1178  def getReadingTime(self):
1179  """Retrieve the current reading time in seconds"""
1180  return SCIPgetReadingTime(self._scip)
1181 
1183  """Retrieve the curernt presolving time in seconds"""
1184  return SCIPgetPresolvingTime(self._scip)
1185 
1186  def getNLPIterations(self):
1187  """Retrieve the total number of LP iterations so far."""
1188  return SCIPgetNLPIterations(self._scip)
1189 
1190  def getNNodes(self):
1191  """gets number of processed nodes in current run, including the focus node."""
1192  return SCIPgetNNodes(self._scip)
1193 
1194  def getNTotalNodes(self):
1195  """gets number of processed nodes in all runs, including the focus node."""
1196  return SCIPgetNTotalNodes(self._scip)
1197 
1199  """Retrieve number of leaf nodes processed with feasible relaxation solution."""
1200  return SCIPgetNFeasibleLeaves(self._scip)
1201 
1203  """gets number of infeasible leaf nodes processed."""
1204  return SCIPgetNInfeasibleLeaves(self._scip)
1205 
1206  def getNLeaves(self):
1207  """gets number of leaves in the tree."""
1208  return SCIPgetNLeaves(self._scip)
1209 
1210  def getNChildren(self):
1211  """gets number of children of focus node."""
1212  return SCIPgetNChildren(self._scip)
1213 
1214  def getNSiblings(self):
1215  """gets number of siblings of focus node."""
1216  return SCIPgetNSiblings(self._scip)
1217 
1218  def getCurrentNode(self):
1219  """Retrieve current node."""
1220  return Node.create(SCIPgetCurrentNode(self._scip))
1221 
1222  def getGap(self):
1223  """Retrieve the gap, i.e. |(primalbound - dualbound)/min(|primalbound|,|dualbound|)|."""
1224  return SCIPgetGap(self._scip)
1225 
1226  def getDepth(self):
1227  """Retrieve the depth of the current node"""
1228  return SCIPgetDepth(self._scip)
1229 
1230  def infinity(self):
1231  """Retrieve SCIP's infinity value"""
1232  return SCIPinfinity(self._scip)
1233 
1234  def epsilon(self):
1235  """Retrieve epsilon for e.g. equality checks"""
1236  return SCIPepsilon(self._scip)
1237 
1238  def feastol(self):
1239  """Retrieve feasibility tolerance"""
1240  return SCIPfeastol(self._scip)
1241 
1242  def feasFrac(self, value):
1243  """returns fractional part of value, i.e. x - floor(x) in feasible tolerance: x - floor(x+feastol)"""
1244  return SCIPfeasFrac(self._scip, value)
1245 
1246  def frac(self, value):
1247  """returns fractional part of value, i.e. x - floor(x) in epsilon tolerance: x - floor(x+eps)"""
1248  return SCIPfrac(self._scip, value)
1249 
1250  def isZero(self, value):
1251  """returns whether abs(value) < eps"""
1252  return SCIPisZero(self._scip, value)
1253 
1254  def isFeasZero(self, value):
1255  """returns whether abs(value) < feastol"""
1256  return SCIPisFeasZero(self._scip, value)
1257 
1258  def isInfinity(self, value):
1259  """returns whether value is SCIP's infinity"""
1260  return SCIPisInfinity(self._scip, value)
1261 
1262  def isFeasNegative(self, value):
1263  """returns whether value < -feastol"""
1264  return SCIPisFeasNegative(self._scip, value)
1265 
1266  def isFeasIntegral(self, value):
1267  """returns whether value is integral within the LP feasibility bounds"""
1268  return SCIPisFeasIntegral(self._scip, value)
1269 
1270  def isEQ(self, val1, val2):
1271  """checks, if values are in range of epsilon"""
1272  return SCIPisEQ(self._scip, val1, val2)
1273 
1274  def isFeasEQ(self, val1, val2):
1275  """checks, if relative difference of values is in range of feasibility tolerance"""
1276  return SCIPisFeasEQ(self._scip, val1, val2)
1277 
1278  def isLE(self, val1, val2):
1279  """returns whether val1 <= val2 + eps"""
1280  return SCIPisLE(self._scip, val1, val2)
1281 
1282  def isLT(self, val1, val2):
1283  """returns whether val1 < val2 - eps"""
1284  return SCIPisLT(self._scip, val1, val2)
1285 
1286  def isGE(self, val1, val2):
1287  """returns whether val1 >= val2 - eps"""
1288  return SCIPisGE(self._scip, val1, val2)
1289 
1290  def isGT(self, val1, val2):
1291  """returns whether val1 > val2 + eps"""
1292  return SCIPisGT(self._scip, val1, val2)
1293 
1294  def getCondition(self, exact=False):
1295  """Get the current LP's condition number
1296 
1297  :param exact: whether to get an estimate or the exact value (Default value = False)
1298 
1299  """
1300  cdef SCIP_LPI* lpi
1301  PY_SCIP_CALL(SCIPgetLPI(self._scip, &lpi))
1302  cdef SCIP_Real quality = 0
1303  if exact:
1304  PY_SCIP_CALL(SCIPlpiGetRealSolQuality(lpi, SCIP_LPSOLQUALITY_EXACTCONDITION, &quality))
1305  else:
1306  PY_SCIP_CALL(SCIPlpiGetRealSolQuality(lpi, SCIP_LPSOLQUALITY_ESTIMCONDITION, &quality))
1307 
1308  return quality
1309 
1310  def enableReoptimization(self, enable=True):
1311  """include specific heuristics and branching rules for reoptimization"""
1312  PY_SCIP_CALL(SCIPenableReoptimization(self._scip, enable))
1313 
1314  def lpiGetIterations(self):
1315  """Get the iteration count of the last solved LP"""
1316  cdef SCIP_LPI* lpi
1317  PY_SCIP_CALL(SCIPgetLPI(self._scip, &lpi))
1318  cdef int iters = 0
1319  PY_SCIP_CALL(SCIPlpiGetIterations(lpi, &iters))
1320  return iters
1321 
1322  # Objective function
1323 
1324  def setMinimize(self):
1325  """Set the objective sense to minimization."""
1326  PY_SCIP_CALL(SCIPsetObjsense(self._scip, SCIP_OBJSENSE_MINIMIZE))
1327 
1328  def setMaximize(self):
1329  """Set the objective sense to maximization."""
1330  PY_SCIP_CALL(SCIPsetObjsense(self._scip, SCIP_OBJSENSE_MAXIMIZE))
1331 
1332  def setObjlimit(self, objlimit):
1333  """Set a limit on the objective function.
1334  Only solutions with objective value better than this limit are accepted.
1335 
1336  :param objlimit: limit on the objective function
1337 
1338  """
1339  PY_SCIP_CALL(SCIPsetObjlimit(self._scip, objlimit))
1340 
1341  def getObjlimit(self):
1342  """returns current limit on objective function."""
1343  return SCIPgetObjlimit(self._scip)
1344 
1345  def setObjective(self, expr, sense = 'minimize', clear = 'true'):
1346  """Establish the objective function as a linear expression.
1347 
1348  :param expr: the objective function SCIP Expr, or constant value
1349  :param sense: the objective sense (Default value = 'minimize')
1350  :param clear: set all other variables objective coefficient to zero (Default value = 'true')
1351 
1352  """
1353 
1354  cdef SCIP_VAR** _vars
1355  cdef int _nvars
1356 
1357  # turn the constant value into an Expr instance for further processing
1358  if not isinstance(expr, Expr):
1359  assert(_is_number(expr)), "given coefficients are neither Expr or number but %s" % expr.__class__.__name__
1360  expr = Expr() + expr
1361 
1362  if expr.degree() > 1:
1363  raise ValueError("SCIP does not support nonlinear objective functions. Consider using set_nonlinear_objective in the pyscipopt.recipe.nonlinear")
1364 
1365  if clear:
1366  # clear existing objective function
1367  self.addObjoffset(-self.getObjoffset())
1368  _vars = SCIPgetOrigVars(self._scip)
1369  _nvars = SCIPgetNOrigVars(self._scip)
1370  for i in range(_nvars):
1371  PY_SCIP_CALL(SCIPchgVarObj(self._scip, _vars[i], 0.0))
1372 
1373  if expr[CONST] != 0.0:
1374  self.addObjoffset(expr[CONST])
1375 
1376  for term, coef in expr.terms.items():
1377  # avoid CONST term of Expr
1378  if term != CONST:
1379  assert len(term) == 1
1380  var = <Variable>term[0]
1381  PY_SCIP_CALL(SCIPchgVarObj(self._scip, var.scip_var, coef))
1382 
1383  if sense == "minimize":
1384  self.setMinimize()
1385  elif sense == "maximize":
1386  self.setMaximize()
1387  else:
1388  raise Warning("unrecognized optimization sense: %s" % sense)
1389 
1390  def getObjective(self):
1391  """Retrieve objective function as Expr"""
1392  variables = self.getVars()
1393  objective = Expr()
1394  for var in variables:
1395  coeff = var.getObj()
1396  if coeff != 0:
1397  objective += coeff * var
1398  objective.normalize()
1399  return objective
1400 
1401  def addObjoffset(self, offset, solutions = False):
1402  """Add constant offset to objective
1403 
1404  :param offset: offset to add
1405  :param solutions: add offset also to existing solutions (Default value = False)
1406 
1407  """
1408  if solutions:
1409  PY_SCIP_CALL(SCIPaddObjoffset(self._scip, offset))
1410  else:
1411  PY_SCIP_CALL(SCIPaddOrigObjoffset(self._scip, offset))
1412 
1413  def getObjoffset(self, original = True):
1414  """Retrieve constant objective offset
1415 
1416  :param original: offset of original or transformed problem (Default value = True)
1417 
1418  """
1419  if original:
1420  return SCIPgetOrigObjoffset(self._scip)
1421  else:
1422  return SCIPgetTransObjoffset(self._scip)
1423 
1424  def setObjIntegral(self):
1425  """informs SCIP that the objective value is always integral in every feasible solution
1426  Note: This function should be used to inform SCIP that the objective function is integral, helping to improve the
1427  performance. This is useful when using column generation. If no column generation (pricing) is used, SCIP
1428  automatically detects whether the objective function is integral or can be scaled to be integral. However, in
1429  any case, the user has to make sure that no variable is added during the solving process that destroys this
1430  property.
1431  """
1432  PY_SCIP_CALL(SCIPsetObjIntegral(self._scip))
1433 
1434  def getLocalEstimate(self, original = False):
1435  """gets estimate of best primal solution w.r.t. original or transformed problem contained in current subtree
1436 
1437  :param original: estimate of original or transformed problem (Default value = False)
1438  """
1439  if original:
1440  return SCIPgetLocalOrigEstimate(self._scip)
1441  else:
1442  return SCIPgetLocalTransEstimate(self._scip)
1443 
1444  # Setting parameters
1445  def setPresolve(self, setting):
1446  """Set presolving parameter settings.
1447 
1448  :param setting: the parameter settings (SCIP_PARAMSETTING)
1449 
1450  """
1451  PY_SCIP_CALL(SCIPsetPresolving(self._scip, setting, True))
1452 
1453  def setProbName(self, name):
1454  """Set problem name"""
1455  n = str_conversion(name)
1456  PY_SCIP_CALL(SCIPsetProbName(self._scip, n))
1457 
1458  def setSeparating(self, setting):
1459  """Set separating parameter settings.
1460 
1461  :param setting: the parameter settings (SCIP_PARAMSETTING)
1462 
1463  """
1464  PY_SCIP_CALL(SCIPsetSeparating(self._scip, setting, True))
1465 
1466  def setHeuristics(self, setting):
1467  """Set heuristics parameter settings.
1468 
1469  :param setting: the parameter setting (SCIP_PARAMSETTING)
1470 
1471  """
1472  PY_SCIP_CALL(SCIPsetHeuristics(self._scip, setting, True))
1473 
1474  def disablePropagation(self, onlyroot=False):
1475  """Disables propagation in SCIP to avoid modifying the original problem during transformation.
1476 
1477  :param onlyroot: use propagation when root processing is finished (Default value = False)
1478 
1479  """
1480  self.setIntParam("propagating/maxroundsroot", 0)
1481  if not onlyroot:
1482  self.setIntParam("propagating/maxrounds", 0)
1483 
1484  def writeProblem(self, filename='model.cip', trans=False, genericnames=False, verbose=True):
1485  """Write current model/problem to a file.
1486 
1487  :param filename: the name of the file to be used (Default value = 'model.cip'). Should have an extension corresponding to one of the readable file formats, described in https://www.scipopt.org/doc/html/group__FILEREADERS.php.
1488  :param trans: indicates whether the transformed problem is written to file (Default value = False)
1489  :param genericnames: indicates whether the problem should be written with generic variable and constraint names (Default value = False)
1490  :param verbose: indicates whether a success message should be printed
1491  """
1492  user_locale = locale.getlocale(category=locale.LC_NUMERIC)
1493  locale.setlocale(locale.LC_NUMERIC, "C")
1494 
1495  str_absfile = abspath(filename)
1496  absfile = str_conversion(str_absfile)
1497  fn, ext = splitext(absfile)
1498 
1499  if len(ext) == 0:
1500  ext = str_conversion('.cip')
1501  fn = fn + ext
1502  ext = ext[1:]
1503 
1504  if trans:
1505  PY_SCIP_CALL(SCIPwriteTransProblem(self._scip, fn, ext, genericnames))
1506  else:
1507  PY_SCIP_CALL(SCIPwriteOrigProblem(self._scip, fn, ext, genericnames))
1508 
1509  if verbose:
1510  print('wrote problem to file ' + str_absfile)
1511 
1512  locale.setlocale(locale.LC_NUMERIC,user_locale)
1513 
1514  # Variable Functions
1515 
1516  def addVar(self, name='', vtype='C', lb=0.0, ub=None, obj=0.0, pricedVar=False, pricedVarScore=1.0):
1517  """Create a new variable. Default variable is non-negative and continuous.
1518 
1519  :param name: name of the variable, generic if empty (Default value = '')
1520  :param vtype: type of the variable: 'C' continuous, 'I' integer, 'B' binary, and 'M' implicit integer
1521  (see https://www.scipopt.org/doc/html/FAQ.php#implicitinteger) (Default value = 'C')
1522  :param lb: lower bound of the variable, use None for -infinity (Default value = 0.0)
1523  :param ub: upper bound of the variable, use None for +infinity (Default value = None)
1524  :param obj: objective value of variable (Default value = 0.0)
1525  :param pricedVar: is the variable a pricing candidate? (Default value = False)
1526  :param pricedVarScore: score of variable in case it is priced, the higher the better (Default value = 1.0)
1527 
1528  """
1529  cdef SCIP_VAR* scip_var
1530 
1531  # replace empty name with generic one
1532  if name == '':
1533  name = 'x'+str(SCIPgetNVars(self._scip)+1)
1534  cname = str_conversion(name)
1535 
1536  # replace None with corresponding infinity
1537  if lb is None:
1538  lb = -SCIPinfinity(self._scip)
1539  if ub is None:
1540  ub = SCIPinfinity(self._scip)
1541 
1542  vtype = vtype.upper()
1543  if vtype in ['C', 'CONTINUOUS']:
1544  PY_SCIP_CALL(SCIPcreateVarBasic(self._scip, &scip_var, cname, lb, ub, obj, SCIP_VARTYPE_CONTINUOUS))
1545  elif vtype in ['B', 'BINARY']:
1546  if ub > 1.0:
1547  ub = 1.0
1548  if lb < 0.0:
1549  lb = 0.0
1550  PY_SCIP_CALL(SCIPcreateVarBasic(self._scip, &scip_var, cname, lb, ub, obj, SCIP_VARTYPE_BINARY))
1551  elif vtype in ['I', 'INTEGER']:
1552  PY_SCIP_CALL(SCIPcreateVarBasic(self._scip, &scip_var, cname, lb, ub, obj, SCIP_VARTYPE_INTEGER))
1553  elif vtype in ['M', 'IMPLINT']:
1554  PY_SCIP_CALL(SCIPcreateVarBasic(self._scip, &scip_var, cname, lb, ub, obj, SCIP_VARTYPE_IMPLINT))
1555  else:
1556  raise Warning("unrecognized variable type")
1557 
1558  if pricedVar:
1559  PY_SCIP_CALL(SCIPaddPricedVar(self._scip, scip_var, pricedVarScore))
1560  else:
1561  PY_SCIP_CALL(SCIPaddVar(self._scip, scip_var))
1562 
1563  pyVar = Variable.create(scip_var)
1564 
1565  # store variable in the model to avoid creating new python variable objects in getVars()
1566  assert not pyVar.ptr() in self._modelvars
1567  self._modelvars[pyVar.ptr()] = pyVar
1568 
1569  #setting the variable data
1570  SCIPvarSetData(scip_var, <SCIP_VARDATA*>pyVar)
1571  PY_SCIP_CALL(SCIPreleaseVar(self._scip, &scip_var))
1572  return pyVar
1573 
1574  def getTransformedVar(self, Variable var):
1575  """Retrieve the transformed variable.
1576 
1577  :param Variable var: original variable to get the transformed of
1578 
1579  """
1580  cdef SCIP_VAR* _tvar
1581  PY_SCIP_CALL(SCIPgetTransformedVar(self._scip, var.scip_var, &_tvar))
1582 
1583  return Variable.create(_tvar)
1584 
1585  def addVarLocks(self, Variable var, nlocksdown, nlocksup):
1586  """adds given values to lock numbers of variable for rounding
1587 
1588  :param Variable var: variable to adjust the locks for
1589  :param nlocksdown: new number of down locks
1590  :param nlocksup: new number of up locks
1591 
1592  """
1593  PY_SCIP_CALL(SCIPaddVarLocks(self._scip, var.scip_var, nlocksdown, nlocksup))
1594 
1595  def fixVar(self, Variable var, val):
1596  """Fixes the variable var to the value val if possible.
1597 
1598  :param Variable var: variable to fix
1599  :param val: float, the fix value
1600  :return: tuple (infeasible, fixed) of booleans
1601 
1602  """
1603  cdef SCIP_Bool infeasible
1604  cdef SCIP_Bool fixed
1605  PY_SCIP_CALL(SCIPfixVar(self._scip, var.scip_var, val, &infeasible, &fixed))
1606  return infeasible, fixed
1607 
1608  def delVar(self, Variable var):
1609  """Delete a variable.
1610 
1611  :param var: the variable which shall be deleted
1612  :return: bool, was deleting succesful
1613 
1614  """
1615  cdef SCIP_Bool deleted
1616  if var.ptr() in self._modelvars:
1617  del self._modelvars[var.ptr()]
1618  PY_SCIP_CALL(SCIPdelVar(self._scip, var.scip_var, &deleted))
1619  return deleted
1620 
1621  def tightenVarLb(self, Variable var, lb, force=False):
1622  """Tighten the lower bound in preprocessing or current node, if the bound is tighter.
1623 
1624  :param var: SCIP variable
1625  :param lb: possible new lower bound
1626  :param force: force tightening even if below bound strengthening tolerance
1627  :return: tuple of bools, (infeasible, tightened)
1628  infeasible: whether new domain is empty
1629  tightened: whether the bound was tightened
1630 
1631  """
1632  cdef SCIP_Bool infeasible
1633  cdef SCIP_Bool tightened
1634  PY_SCIP_CALL(SCIPtightenVarLb(self._scip, var.scip_var, lb, force, &infeasible, &tightened))
1635  return infeasible, tightened
1636 
1637  def tightenVarUb(self, Variable var, ub, force=False):
1638  """Tighten the upper bound in preprocessing or current node, if the bound is tighter.
1639 
1640  :param var: SCIP variable
1641  :param ub: possible new upper bound
1642  :param force: force tightening even if below bound strengthening tolerance
1643  :return: tuple of bools, (infeasible, tightened)
1644  infeasible: whether new domain is empty
1645  tightened: whether the bound was tightened
1646 
1647  """
1648  cdef SCIP_Bool infeasible
1649  cdef SCIP_Bool tightened
1650  PY_SCIP_CALL(SCIPtightenVarUb(self._scip, var.scip_var, ub, force, &infeasible, &tightened))
1651  return infeasible, tightened
1652 
1653  def tightenVarUbGlobal(self, Variable var, ub, force=False):
1654  """Tighten the global upper bound, if the bound is tighter.
1655 
1656  :param var: SCIP variable
1657  :param ub: possible new upper bound
1658  :param force: force tightening even if below bound strengthening tolerance
1659  :return: tuple of bools, (infeasible, tightened)
1660  infeasible: whether new domain is empty
1661  tightened: whether the bound was tightened
1662 
1663  """
1664  cdef SCIP_Bool infeasible
1665  cdef SCIP_Bool tightened
1666  PY_SCIP_CALL(SCIPtightenVarUbGlobal(self._scip, var.scip_var, ub, force, &infeasible, &tightened))
1667  return infeasible, tightened
1668 
1669  def tightenVarLbGlobal(self, Variable var, lb, force=False):
1670  """Tighten the global upper bound, if the bound is tighter.
1671 
1672  :param var: SCIP variable
1673  :param lb: possible new upper bound
1674  :param force: force tightening even if below bound strengthening tolerance
1675  :return: tuple of bools, (infeasible, tightened)
1676  infeasible: whether new domain is empty
1677  tightened: whether the bound was tightened
1678 
1679  """
1680  cdef SCIP_Bool infeasible
1681  cdef SCIP_Bool tightened
1682  PY_SCIP_CALL(SCIPtightenVarLbGlobal(self._scip, var.scip_var, lb, force, &infeasible, &tightened))
1683  return infeasible, tightened
1684 
1685  def chgVarLb(self, Variable var, lb):
1686  """Changes the lower bound of the specified variable.
1687 
1688  :param Variable var: variable to change bound of
1689  :param lb: new lower bound (set to None for -infinity)
1690 
1691  """
1692  if lb is None:
1693  lb = -SCIPinfinity(self._scip)
1694  PY_SCIP_CALL(SCIPchgVarLb(self._scip, var.scip_var, lb))
1695 
1696  def chgVarUb(self, Variable var, ub):
1697  """Changes the upper bound of the specified variable.
1698 
1699  :param Variable var: variable to change bound of
1700  :param ub: new upper bound (set to None for +infinity)
1701 
1702  """
1703  if ub is None:
1704  ub = SCIPinfinity(self._scip)
1705  PY_SCIP_CALL(SCIPchgVarUb(self._scip, var.scip_var, ub))
1706 
1707  def chgVarLbGlobal(self, Variable var, lb):
1708  """Changes the global lower bound of the specified variable.
1709 
1710  :param Variable var: variable to change bound of
1711  :param lb: new lower bound (set to None for -infinity)
1712 
1713  """
1714  if lb is None:
1715  lb = -SCIPinfinity(self._scip)
1716  PY_SCIP_CALL(SCIPchgVarLbGlobal(self._scip, var.scip_var, lb))
1717 
1718  def chgVarUbGlobal(self, Variable var, ub):
1719  """Changes the global upper bound of the specified variable.
1720 
1721  :param Variable var: variable to change bound of
1722  :param ub: new upper bound (set to None for +infinity)
1723 
1724  """
1725  if ub is None:
1726  ub = SCIPinfinity(self._scip)
1727  PY_SCIP_CALL(SCIPchgVarUbGlobal(self._scip, var.scip_var, ub))
1728 
1729  def chgVarLbNode(self, Node node, Variable var, lb):
1730  """Changes the lower bound of the specified variable at the given node.
1731 
1732  :param Variable var: variable to change bound of
1733  :param lb: new lower bound (set to None for -infinity)
1734  """
1735 
1736  if lb is None:
1737  lb = -SCIPinfinity(self._scip)
1738  PY_SCIP_CALL(SCIPchgVarLbNode(self._scip, node.scip_node, var.scip_var, lb))
1739 
1740  def chgVarUbNode(self, Node node, Variable var, ub):
1741  """Changes the upper bound of the specified variable at the given node.
1742 
1743  :param Variable var: variable to change bound of
1744  :param ub: new upper bound (set to None for +infinity)
1745 
1746  """
1747  if ub is None:
1748  ub = SCIPinfinity(self._scip)
1749  PY_SCIP_CALL(SCIPchgVarUbNode(self._scip, node.scip_node, var.scip_var, ub))
1750 
1751  def chgVarType(self, Variable var, vtype):
1752  """Changes the type of a variable
1753 
1754  :param Variable var: variable to change type of
1755  :param vtype: new variable type
1756 
1757  """
1758  cdef SCIP_Bool infeasible
1759  if vtype in ['C', 'CONTINUOUS']:
1760  PY_SCIP_CALL(SCIPchgVarType(self._scip, var.scip_var, SCIP_VARTYPE_CONTINUOUS, &infeasible))
1761  elif vtype in ['B', 'BINARY']:
1762  PY_SCIP_CALL(SCIPchgVarType(self._scip, var.scip_var, SCIP_VARTYPE_BINARY, &infeasible))
1763  elif vtype in ['I', 'INTEGER']:
1764  PY_SCIP_CALL(SCIPchgVarType(self._scip, var.scip_var, SCIP_VARTYPE_INTEGER, &infeasible))
1765  elif vtype in ['M', 'IMPLINT']:
1766  PY_SCIP_CALL(SCIPchgVarType(self._scip, var.scip_var, SCIP_VARTYPE_IMPLINT, &infeasible))
1767  else:
1768  raise Warning("unrecognized variable type")
1769  if infeasible:
1770  print('could not change variable type of variable %s' % var)
1771 
1772  def getVars(self, transformed=False):
1773  """Retrieve all variables.
1774 
1775  :param transformed: get transformed variables instead of original (Default value = False)
1776 
1777  """
1778  cdef SCIP_VAR** _vars
1779  cdef SCIP_VAR* _var
1780  cdef int _nvars
1781  vars = []
1782 
1783  if transformed:
1784  _vars = SCIPgetVars(self._scip)
1785  _nvars = SCIPgetNVars(self._scip)
1786  else:
1787  _vars = SCIPgetOrigVars(self._scip)
1788  _nvars = SCIPgetNOrigVars(self._scip)
1789 
1790  for i in range(_nvars):
1791  ptr = <size_t>(_vars[i])
1792 
1793  # check whether the corresponding variable exists already
1794  if ptr in self._modelvars:
1795  vars.append(self._modelvars[ptr])
1796  else:
1797  # create a new variable
1798  var = Variable.create(_vars[i])
1799  assert var.ptr() == ptr
1800  self._modelvars[ptr] = var
1801  vars.append(var)
1802 
1803  return vars
1804 
1805  def getNVars(self, transformed=True):
1806  """Retrieve number of variables in the problems.
1807 
1808  :param transformed: get transformed variables instead of original (Default value = True)
1809  """
1810  if transformed:
1811  return SCIPgetNVars(self._scip)
1812  else:
1813  return SCIPgetNOrigVars(self._scip)
1814 
1815  def getNIntVars(self):
1816  """gets number of integer active problem variables"""
1817  return SCIPgetNIntVars(self._scip)
1818 
1819  def getNBinVars(self):
1820  """gets number of binary active problem variables"""
1821  return SCIPgetNBinVars(self._scip)
1822 
1823  def getVarDict(self):
1824  """gets dictionary with variables names as keys and current variable values as items"""
1825  var_dict = {}
1826  for var in self.getVars():
1827  var_dict[var.name] = self.getVal(var)
1828  return var_dict
1829 
1830  def updateNodeLowerbound(self, Node node, lb):
1831  """if given value is larger than the node's lower bound (in transformed problem),
1832  sets the node's lower bound to the new value
1833 
1834  :param node: Node, the node to update
1835  :param newbound: float, new bound (if greater) for the node
1836 
1837  """
1838  PY_SCIP_CALL(SCIPupdateNodeLowerbound(self._scip, node.scip_node, lb))
1839 
1840  def relax(self):
1841  """Relaxes the integrality restrictions of the model"""
1842  if self.getStage() != SCIP_STAGE_PROBLEM:
1843  raise Warning("method can only be called in stage PROBLEM")
1844 
1845  for var in self.getVars():
1846  self.chgVarType(var, "C")
1847 
1848  # Node methods
1849  def getBestChild(self):
1850  """gets the best child of the focus node w.r.t. the node selection strategy."""
1851  return Node.create(SCIPgetBestChild(self._scip))
1852 
1853  def getBestSibling(self):
1854  """gets the best sibling of the focus node w.r.t. the node selection strategy."""
1855  return Node.create(SCIPgetBestSibling(self._scip))
1856 
1857  def getBestLeaf(self):
1858  """gets the best leaf from the node queue w.r.t. the node selection strategy."""
1859  return Node.create(SCIPgetBestLeaf(self._scip))
1860 
1861  def getBestNode(self):
1862  """gets the best node from the tree (child, sibling, or leaf) w.r.t. the node selection strategy."""
1863  return Node.create(SCIPgetBestNode(self._scip))
1864 
1865  def getBestboundNode(self):
1866  """gets the node with smallest lower bound from the tree (child, sibling, or leaf)."""
1867  return Node.create(SCIPgetBestboundNode(self._scip))
1868 
1869  def getOpenNodes(self):
1870  """access to all data of open nodes (leaves, children, and siblings)
1871 
1872  :return: three lists containing open leaves, children, siblings
1873  """
1874  cdef SCIP_NODE** _leaves
1875  cdef SCIP_NODE** _children
1876  cdef SCIP_NODE** _siblings
1877  cdef int _nleaves
1878  cdef int _nchildren
1879  cdef int _nsiblings
1880 
1881  PY_SCIP_CALL(SCIPgetOpenNodesData(self._scip, &_leaves, &_children, &_siblings, &_nleaves, &_nchildren, &_nsiblings))
1882 
1883  leaves = [Node.create(_leaves[i]) for i in range(_nleaves)]
1884  children = [Node.create(_children[i]) for i in range(_nchildren)]
1885  siblings = [Node.create(_siblings[i]) for i in range(_nsiblings)]
1886 
1887  return leaves, children, siblings
1888 
1889  def repropagateNode(self, Node node):
1890  """marks the given node to be propagated again the next time a node of its subtree is processed"""
1891  PY_SCIP_CALL(SCIPrepropagateNode(self._scip, node.scip_node))
1892 
1893 
1894  # LP Methods
1895  def getLPSolstat(self):
1896  """Gets solution status of current LP"""
1897  return SCIPgetLPSolstat(self._scip)
1898 
1899 
1900  def constructLP(self):
1901  """makes sure that the LP of the current node is loaded and
1902  may be accessed through the LP information methods
1903 
1904  :return: bool cutoff, i.e. can the node be cut off?
1905 
1906  """
1907  cdef SCIP_Bool cutoff
1908  PY_SCIP_CALL(SCIPconstructLP(self._scip, &cutoff))
1909  return cutoff
1910 
1911  def getLPObjVal(self):
1912  """gets objective value of current LP (which is the sum of column and loose objective value)"""
1913 
1914  return SCIPgetLPObjval(self._scip)
1915 
1916  def getLPColsData(self):
1917  """Retrieve current LP columns"""
1918  cdef SCIP_COL** cols
1919  cdef int ncols
1920 
1921  PY_SCIP_CALL(SCIPgetLPColsData(self._scip, &cols, &ncols))
1922  return [Column.create(cols[i]) for i in range(ncols)]
1923 
1924  def getLPRowsData(self):
1925  """Retrieve current LP rows"""
1926  cdef SCIP_ROW** rows
1927  cdef int nrows
1928 
1929  PY_SCIP_CALL(SCIPgetLPRowsData(self._scip, &rows, &nrows))
1930  return [Row.create(rows[i]) for i in range(nrows)]
1931 
1932  def getNLPRows(self):
1933  """Retrieve the number of rows currently in the LP"""
1934  return SCIPgetNLPRows(self._scip)
1935 
1936  def getNLPCols(self):
1937  """Retrieve the number of cols currently in the LP"""
1938  return SCIPgetNLPCols(self._scip)
1939 
1940  def getLPBasisInd(self):
1941  """Gets all indices of basic columns and rows: index i >= 0 corresponds to column i, index i < 0 to row -i-1"""
1942  cdef int nrows = SCIPgetNLPRows(self._scip)
1943  cdef int* inds = <int *> malloc(nrows * sizeof(int))
1944 
1945  PY_SCIP_CALL(SCIPgetLPBasisInd(self._scip, inds))
1946  result = [inds[i] for i in range(nrows)]
1947  free(inds)
1948  return result
1949 
1950  def getLPBInvRow(self, row):
1951  """gets a row from the inverse basis matrix B^-1"""
1952  # TODO: sparsity information
1953  cdef int nrows = SCIPgetNLPRows(self._scip)
1954  cdef SCIP_Real* coefs = <SCIP_Real*> malloc(nrows * sizeof(SCIP_Real))
1955 
1956  PY_SCIP_CALL(SCIPgetLPBInvRow(self._scip, row, coefs, NULL, NULL))
1957  result = [coefs[i] for i in range(nrows)]
1958  free(coefs)
1959  return result
1960 
1961  def getLPBInvARow(self, row):
1962  """gets a row from B^-1 * A"""
1963  # TODO: sparsity information
1964  cdef int ncols = SCIPgetNLPCols(self._scip)
1965  cdef SCIP_Real* coefs = <SCIP_Real*> malloc(ncols * sizeof(SCIP_Real))
1966 
1967  PY_SCIP_CALL(SCIPgetLPBInvARow(self._scip, row, NULL, coefs, NULL, NULL))
1968  result = [coefs[i] for i in range(ncols)]
1969  free(coefs)
1970  return result
1971 
1972  def isLPSolBasic(self):
1973  """returns whether the current LP solution is basic, i.e. is defined by a valid simplex basis"""
1974  return SCIPisLPSolBasic(self._scip)
1975 
1976  def allColsInLP(self):
1977  """checks if all columns, i.e. every variable with non-empty column is present in the LP.
1978  This is not True when performing pricing for instance."""
1979 
1980  return SCIPallColsInLP(self._scip)
1981 
1982  # LP Col Methods
1983  def getColRedCost(self, Column col):
1984  """gets the reduced cost of the column in the current LP
1985 
1986  :param Column col: the column of the LP for which the reduced cost will be retrieved
1987  """
1988  return SCIPgetColRedcost(self._scip, col.scip_col)
1989 
1990  #TODO: documentation!!
1991  # LP Row Methods
1992  def createEmptyRowSepa(self, Sepa sepa, name="row", lhs = 0.0, rhs = None, local = True, modifiable = False, removable = True):
1993  """creates and captures an LP row without any coefficients from a separator
1994 
1995  :param sepa: separator that creates the row
1996  :param name: name of row (Default value = "row")
1997  :param lhs: left hand side of row (Default value = 0)
1998  :param rhs: right hand side of row (Default value = None)
1999  :param local: is row only valid locally? (Default value = True)
2000  :param modifiable: is row modifiable during node processing (subject to column generation)? (Default value = False)
2001  :param removable: should the row be removed from the LP due to aging or cleanup? (Default value = True)
2002  """
2003  cdef SCIP_ROW* row
2004  lhs = -SCIPinfinity(self._scip) if lhs is None else lhs
2005  rhs = SCIPinfinity(self._scip) if rhs is None else rhs
2006  scip_sepa = SCIPfindSepa(self._scip, str_conversion(sepa.name))
2007  PY_SCIP_CALL(SCIPcreateEmptyRowSepa(self._scip, &row, scip_sepa, str_conversion(name), lhs, rhs, local, modifiable, removable))
2008  PyRow = Row.create(row)
2009  return PyRow
2010 
2011  def createEmptyRowUnspec(self, name="row", lhs = 0.0, rhs = None, local = True, modifiable = False, removable = True):
2012  """creates and captures an LP row without any coefficients from an unspecified source
2013 
2014  :param name: name of row (Default value = "row")
2015  :param lhs: left hand side of row (Default value = 0)
2016  :param rhs: right hand side of row (Default value = None)
2017  :param local: is row only valid locally? (Default value = True)
2018  :param modifiable: is row modifiable during node processing (subject to column generation)? (Default value = False)
2019  :param removable: should the row be removed from the LP due to aging or cleanup? (Default value = True)
2020  """
2021  cdef SCIP_ROW* row
2022  lhs = -SCIPinfinity(self._scip) if lhs is None else lhs
2023  rhs = SCIPinfinity(self._scip) if rhs is None else rhs
2024  PY_SCIP_CALL(SCIPcreateEmptyRowUnspec(self._scip, &row, str_conversion(name), lhs, rhs, local, modifiable, removable))
2025  PyRow = Row.create(row)
2026  return PyRow
2027 
2028  def getRowActivity(self, Row row):
2029  """returns the activity of a row in the last LP or pseudo solution"""
2030  return SCIPgetRowActivity(self._scip, row.scip_row)
2031 
2032  def getRowLPActivity(self, Row row):
2033  """returns the activity of a row in the last LP solution"""
2034  return SCIPgetRowLPActivity(self._scip, row.scip_row)
2035 
2036  # TODO: do we need this? (also do we need release var??)
2037  def releaseRow(self, Row row not None):
2038  """decreases usage counter of LP row, and frees memory if necessary"""
2039  PY_SCIP_CALL(SCIPreleaseRow(self._scip, &row.scip_row))
2040 
2041  def cacheRowExtensions(self, Row row not None):
2042  """informs row, that all subsequent additions of variables to the row should be cached and not directly applied;
2043  after all additions were applied, flushRowExtensions() must be called;
2044  while the caching of row extensions is activated, information methods of the row give invalid results;
2045  caching should be used, if a row is build with addVarToRow() calls variable by variable to increase the performance"""
2046  PY_SCIP_CALL(SCIPcacheRowExtensions(self._scip, row.scip_row))
2047 
2048  def flushRowExtensions(self, Row row not None):
2049  """flushes all cached row extensions after a call of cacheRowExtensions() and merges coefficients with equal columns into a single coefficient"""
2050  PY_SCIP_CALL(SCIPflushRowExtensions(self._scip, row.scip_row))
2051 
2052  def addVarToRow(self, Row row not None, Variable var not None, value):
2053  """resolves variable to columns and adds them with the coefficient to the row"""
2054  PY_SCIP_CALL(SCIPaddVarToRow(self._scip, row.scip_row, var.scip_var, value))
2055 
2056  def printRow(self, Row row not None):
2057  """Prints row."""
2058  PY_SCIP_CALL(SCIPprintRow(self._scip, row.scip_row, NULL))
2059 
2060  def getRowNumIntCols(self, Row row):
2061  """Returns number of intergal columns in the row"""
2062  return SCIPgetRowNumIntCols(self._scip, row.scip_row)
2063 
2064  def getRowObjParallelism(self, Row row):
2065  """Returns 1 if the row is parallel, and 0 if orthogonal"""
2066  return SCIPgetRowObjParallelism(self._scip, row.scip_row)
2067 
2068  def getRowParallelism(self, Row row1, Row row2, orthofunc=101):
2069  """Returns the degree of parallelism between hyplerplanes. 1 if perfectly parallel, 0 if orthogonal.
2070  For two row vectors v, w the parallelism is calculated as: |v*w|/(|v|*|w|).
2071  101 in this case is an 'e' (euclidean) in ASCII. The other acceptable input is 100 (d for discrete)."""
2072  return SCIProwGetParallelism(row1.scip_row, row2.scip_row, orthofunc)
2073 
2074  def getRowDualSol(self, Row row):
2075  """Gets the dual LP solution of a row"""
2076  return SCIProwGetDualsol(row.scip_row)
2077 
2078  # Cutting Plane Methods
2079  def addPoolCut(self, Row row not None):
2080  """if not already existing, adds row to global cut pool"""
2081  PY_SCIP_CALL(SCIPaddPoolCut(self._scip, row.scip_row))
2082 
2083  def getCutEfficacy(self, Row cut not None, Solution sol = None):
2084  """returns efficacy of the cut with respect to the given primal solution or the current LP solution: e = -feasibility/norm"""
2085  return SCIPgetCutEfficacy(self._scip, NULL if sol is None else sol.sol, cut.scip_row)
2086 
2087  def isCutEfficacious(self, Row cut not None, Solution sol = None):
2088  """ 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"""
2089  return SCIPisCutEfficacious(self._scip, NULL if sol is None else sol.sol, cut.scip_row)
2090 
2091  def getCutLPSolCutoffDistance(self, Row cut not None, Solution sol not None):
2092  """ returns row's cutoff distance in the direction of the given primal solution"""
2093  return SCIPgetCutLPSolCutoffDistance(self._scip, sol.sol, cut.scip_row)
2094 
2095  def addCut(self, Row cut not None, forcecut = False):
2096  """adds cut to separation storage and returns whether cut has been detected to be infeasible for local bounds"""
2097  cdef SCIP_Bool infeasible
2098  PY_SCIP_CALL(SCIPaddRow(self._scip, cut.scip_row, forcecut, &infeasible))
2099  return infeasible
2100 
2101  def getNCuts(self):
2102  """Retrieve total number of cuts in storage"""
2103  return SCIPgetNCuts(self._scip)
2104 
2105  def getNCutsApplied(self):
2106  """Retrieve number of currently applied cuts"""
2107  return SCIPgetNCutsApplied(self._scip)
2108 
2109  def getNSepaRounds(self):
2110  """Retrieve the number of separation rounds that have been performed
2111  at the current node"""
2112  return SCIPgetNSepaRounds(self._scip)
2113 
2114  def separateSol(self, Solution sol = None, pretendroot = False, allowlocal = True, onlydelayed = False):
2115  """separates the given primal solution or the current LP solution by calling the separators and constraint handlers'
2116  separation methods;
2117  the generated cuts are stored in the separation storage and can be accessed with the methods SCIPgetCuts() and
2118  SCIPgetNCuts();
2119  after evaluating the cuts, you have to call SCIPclearCuts() in order to remove the cuts from the
2120  separation storage;
2121  it is possible to call SCIPseparateSol() multiple times with different solutions and evaluate the found cuts
2122  afterwards
2123  :param Solution sol: solution to separate, None to use current lp solution (Default value = None)
2124  :param pretendroot: should the cut separators be called as if we are at the root node? (Default value = "False")
2125  :param allowlocal: should the separator be asked to separate local cuts (Default value = True)
2126  :param onlydelayed: should only separators be called that were delayed in the previous round? (Default value = False)
2127  returns
2128  delayed -- whether a separator was delayed
2129  cutoff -- whether the node can be cut off
2130  """
2131  cdef SCIP_Bool delayed
2132  cdef SCIP_Bool cutoff
2133 
2134  PY_SCIP_CALL( SCIPseparateSol(self._scip, NULL if sol is None else sol.sol, pretendroot, allowlocal, onlydelayed, &delayed, &cutoff) )
2135  return delayed, cutoff
2136 
2137  def _createConsLinear(self, ExprCons lincons, **kwargs):
2138  assert isinstance(lincons, ExprCons), "given constraint is not ExprCons but %s" % lincons.__class__.__name__
2139 
2140  assert lincons.expr.degree() <= 1, "given constraint is not linear, degree == %d" % lincons.expr.degree()
2141  terms = lincons.expr.terms
2142 
2143  cdef SCIP_CONS* scip_cons
2144 
2145  cdef int nvars = len(terms.items())
2146 
2147  vars_array = <SCIP_VAR**> malloc(nvars * sizeof(SCIP_VAR*))
2148  coeffs_array = <SCIP_Real*> malloc(nvars * sizeof(SCIP_Real))
2149 
2150  for i, (key, coeff) in enumerate(terms.items()):
2151  vars_array[i] = <SCIP_VAR*>(<Variable>key[0]).scip_var
2152  coeffs_array[i] = <SCIP_Real>coeff
2153 
2154  PY_SCIP_CALL(SCIPcreateConsLinear(
2155  self._scip, &scip_cons, str_conversion(kwargs['name']), nvars, vars_array, coeffs_array,
2156  kwargs['lhs'], kwargs['rhs'], kwargs['initial'],
2157  kwargs['separate'], kwargs['enforce'], kwargs['check'],
2158  kwargs['propagate'], kwargs['local'], kwargs['modifiable'],
2159  kwargs['dynamic'], kwargs['removable'], kwargs['stickingatnode']))
2160 
2161  PyCons = Constraint.create(scip_cons)
2162 
2163  free(vars_array)
2164  free(coeffs_array)
2165  return PyCons
2166 
2167  def _createConsQuadratic(self, ExprCons quadcons, **kwargs):
2168  terms = quadcons.expr.terms
2169  assert quadcons.expr.degree() <= 2, "given constraint is not quadratic, degree == %d" % quadcons.expr.degree()
2170 
2171  cdef SCIP_CONS* scip_cons
2172  cdef SCIP_EXPR* prodexpr
2173  PY_SCIP_CALL(SCIPcreateConsQuadraticNonlinear(
2174  self._scip, &scip_cons, str_conversion(kwargs['name']),
2175  0, NULL, NULL, # linear
2176  0, NULL, NULL, NULL, # quadratc
2177  kwargs['lhs'], kwargs['rhs'],
2178  kwargs['initial'], kwargs['separate'], kwargs['enforce'],
2179  kwargs['check'], kwargs['propagate'], kwargs['local'],
2180  kwargs['modifiable'], kwargs['dynamic'], kwargs['removable']))
2181 
2182  for v, c in terms.items():
2183  if len(v) == 1: # linear
2184  var = <Variable>v[0]
2185  PY_SCIP_CALL(SCIPaddLinearVarNonlinear(self._scip, scip_cons, var.scip_var, c))
2186  else: # quadratic
2187  assert len(v) == 2, 'term length must be 1 or 2 but it is %s' % len(v)
2188 
2189  varexprs = <SCIP_EXPR**> malloc(2 * sizeof(SCIP_EXPR*))
2190  var1, var2 = <Variable>v[0], <Variable>v[1]
2191  PY_SCIP_CALL( SCIPcreateExprVar(self._scip, &varexprs[0], var1.scip_var, NULL, NULL) )
2192  PY_SCIP_CALL( SCIPcreateExprVar(self._scip, &varexprs[1], var2.scip_var, NULL, NULL) )
2193  PY_SCIP_CALL( SCIPcreateExprProduct(self._scip, &prodexpr, 2, varexprs, 1.0, NULL, NULL) )
2194 
2195  PY_SCIP_CALL( SCIPaddExprNonlinear(self._scip, scip_cons, prodexpr, c) )
2196 
2197  PY_SCIP_CALL( SCIPreleaseExpr(self._scip, &prodexpr) )
2198  PY_SCIP_CALL( SCIPreleaseExpr(self._scip, &varexprs[1]) )
2199  PY_SCIP_CALL( SCIPreleaseExpr(self._scip, &varexprs[0]) )
2200  free(varexprs)
2201 
2202  PyCons = Constraint.create(scip_cons)
2203 
2204  return PyCons
2205 
2206  def _createConsNonlinear(self, cons, **kwargs):
2207  cdef SCIP_EXPR* expr
2208  cdef SCIP_EXPR** varexprs
2209  cdef SCIP_EXPR** monomials
2210  cdef int* idxs
2211  cdef SCIP_CONS* scip_cons
2212 
2213  terms = cons.expr.terms
2214 
2215  # collect variables
2216  variables = {var.ptr():var for term in terms for var in term}
2217  variables = list(variables.values())
2218  varindex = {var.ptr():idx for (idx,var) in enumerate(variables)}
2219 
2220  # create monomials for terms
2221  monomials = <SCIP_EXPR**> malloc(len(terms) * sizeof(SCIP_EXPR*))
2222  termcoefs = <SCIP_Real*> malloc(len(terms) * sizeof(SCIP_Real))
2223  for i, (term, coef) in enumerate(terms.items()):
2224  termvars = <SCIP_VAR**> malloc(len(term) * sizeof(SCIP_VAR*))
2225  for j, var in enumerate(term):
2226  termvars[j] = (<Variable>var).scip_var
2227  PY_SCIP_CALL( SCIPcreateExprMonomial(self._scip, &monomials[i], <int>len(term), termvars, NULL, NULL, NULL) )
2228  termcoefs[i] = <SCIP_Real>coef
2229  free(termvars)
2230 
2231  # create polynomial from monomials
2232  PY_SCIP_CALL( SCIPcreateExprSum(self._scip, &expr, <int>len(terms), monomials, termcoefs, 0.0, NULL, NULL))
2233 
2234  # create nonlinear constraint for expr
2235  PY_SCIP_CALL( SCIPcreateConsNonlinear(
2236  self._scip,
2237  &scip_cons,
2238  str_conversion(kwargs['name']),
2239  expr,
2240  kwargs['lhs'],
2241  kwargs['rhs'],
2242  kwargs['initial'],
2243  kwargs['separate'],
2244  kwargs['enforce'],
2245  kwargs['check'],
2246  kwargs['propagate'],
2247  kwargs['local'],
2248  kwargs['modifiable'],
2249  kwargs['dynamic'],
2250  kwargs['removable']) )
2251 
2252  PyCons = Constraint.create(scip_cons)
2253 
2254  PY_SCIP_CALL( SCIPreleaseExpr(self._scip, &expr) )
2255  for i in range(<int>len(terms)):
2256  PY_SCIP_CALL(SCIPreleaseExpr(self._scip, &monomials[i]))
2257  free(monomials)
2258  free(termcoefs)
2259  return PyCons
2260 
2261  def _createConsGenNonlinear(self, cons, **kwargs):
2262  cdef SCIP_EXPR** childrenexpr
2263  cdef SCIP_EXPR** scipexprs
2264  cdef SCIP_CONS* scip_cons
2265  cdef int nchildren
2266 
2267  # get arrays from python's expression tree
2268  expr = cons.expr
2269  nodes = expr_to_nodes(expr)
2270 
2271  # in nodes we have a list of tuples: each tuple is of the form
2272  # (operator, [indices]) where indices are the indices of the tuples
2273  # that are the children of this operator. This is sorted,
2274  # so we are going to do is:
2275  # loop over the nodes and create the expression of each
2276  # Note1: when the operator is Operator.const, [indices] stores the value
2277  # Note2: we need to compute the number of variable operators to find out
2278  # how many variables are there.
2279  nvars = 0
2280  for node in nodes:
2281  if node[0] == Operator.varidx:
2282  nvars += 1
2283  vars = <SCIP_VAR**> malloc(nvars * sizeof(SCIP_VAR*))
2284 
2285  varpos = 0
2286  scipexprs = <SCIP_EXPR**> malloc(len(nodes) * sizeof(SCIP_EXPR*))
2287  for i,node in enumerate(nodes):
2288  opidx = node[0]
2289  if opidx == Operator.varidx:
2290  assert len(node[1]) == 1
2291  pyvar = node[1][0] # for vars we store the actual var!
2292  PY_SCIP_CALL( SCIPcreateExprVar(self._scip, &scipexprs[i], (<Variable>pyvar).scip_var, NULL, NULL) )
2293  vars[varpos] = (<Variable>pyvar).scip_var
2294  varpos += 1
2295  continue
2296  if opidx == Operator.const:
2297  assert len(node[1]) == 1
2298  value = node[1][0]
2299  PY_SCIP_CALL( SCIPcreateExprValue(self._scip, &scipexprs[i], <SCIP_Real>value, NULL, NULL) )
2300  continue
2301  if opidx == Operator.add:
2302  nchildren = len(node[1])
2303  childrenexpr = <SCIP_EXPR**> malloc(nchildren * sizeof(SCIP_EXPR*))
2304  coefs = <SCIP_Real*> malloc(nchildren * sizeof(SCIP_Real))
2305  for c, pos in enumerate(node[1]):
2306  childrenexpr[c] = scipexprs[pos]
2307  coefs[c] = 1
2308  PY_SCIP_CALL( SCIPcreateExprSum(self._scip, &scipexprs[i], nchildren, childrenexpr, coefs, 0, NULL, NULL))
2309  free(coefs)
2310  free(childrenexpr)
2311  continue
2312  if opidx == Operator.prod:
2313  nchildren = len(node[1])
2314  childrenexpr = <SCIP_EXPR**> malloc(nchildren * sizeof(SCIP_EXPR*))
2315  for c, pos in enumerate(node[1]):
2316  childrenexpr[c] = scipexprs[pos]
2317  PY_SCIP_CALL( SCIPcreateExprProduct(self._scip, &scipexprs[i], nchildren, childrenexpr, 1, NULL, NULL) )
2318  free(childrenexpr)
2319  continue
2320  if opidx == Operator.power:
2321  # the second child is the exponent which is a const
2322  valuenode = nodes[node[1][1]]
2323  assert valuenode[0] == Operator.const
2324  exponent = valuenode[1][0]
2325  PY_SCIP_CALL( SCIPcreateExprPow(self._scip, &scipexprs[i], scipexprs[node[1][0]], <SCIP_Real>exponent, NULL, NULL ))
2326  continue
2327  if opidx == Operator.exp:
2328  assert len(node[1]) == 1
2329  PY_SCIP_CALL( SCIPcreateExprExp(self._scip, &scipexprs[i], scipexprs[node[1][0]], NULL, NULL ))
2330  continue
2331  if opidx == Operator.log:
2332  assert len(node[1]) == 1
2333  PY_SCIP_CALL( SCIPcreateExprLog(self._scip, &scipexprs[i], scipexprs[node[1][0]], NULL, NULL ))
2334  continue
2335  if opidx == Operator.sqrt:
2336  assert len(node[1]) == 1
2337  PY_SCIP_CALL( SCIPcreateExprPow(self._scip, &scipexprs[i], scipexprs[node[1][0]], <SCIP_Real>0.5, NULL, NULL) )
2338  continue
2339  if opidx == Operator.sin:
2340  assert len(node[1]) == 1
2341  PY_SCIP_CALL( SCIPcreateExprSin(self._scip, &scipexprs[i], scipexprs[node[1][0]], NULL, NULL) )
2342  continue
2343  if opidx == Operator.cos:
2344  assert len(node[1]) == 1
2345  PY_SCIP_CALL( SCIPcreateExprCos(self._scip, &scipexprs[i], scipexprs[node[1][0]], NULL, NULL) )
2346  continue
2347  if opidx == Operator.fabs:
2348  assert len(node[1]) == 1
2349  PY_SCIP_CALL( SCIPcreateExprAbs(self._scip, &scipexprs[i], scipexprs[node[1][0]], NULL, NULL ))
2350  continue
2351  # default:
2352  raise NotImplementedError
2353  assert varpos == nvars
2354 
2355  # create nonlinear constraint for the expression root
2356  PY_SCIP_CALL( SCIPcreateConsNonlinear(
2357  self._scip,
2358  &scip_cons,
2359  str_conversion(kwargs['name']),
2360  scipexprs[len(nodes) - 1],
2361  kwargs['lhs'],
2362  kwargs['rhs'],
2363  kwargs['initial'],
2364  kwargs['separate'],
2365  kwargs['enforce'],
2366  kwargs['check'],
2367  kwargs['propagate'],
2368  kwargs['local'],
2369  kwargs['modifiable'],
2370  kwargs['dynamic'],
2371  kwargs['removable']) )
2372  PyCons = Constraint.create(scip_cons)
2373  for i in range(len(nodes)):
2374  PY_SCIP_CALL( SCIPreleaseExpr(self._scip, &scipexprs[i]) )
2375 
2376  # free more memory
2377  free(scipexprs)
2378  free(vars)
2379 
2380  return PyCons
2381 
2382  def createConsFromExpr(self, cons, name='', initial=True, separate=True,
2383  enforce=True, check=True, propagate=True, local=False,
2384  modifiable=False, dynamic=False, removable=False,
2385  stickingatnode=False):
2386  """Create a linear or nonlinear constraint without adding it to the SCIP problem. This is useful for creating disjunction constraints
2387  without also enforcing the individual constituents. Currently, this can only be used as an argument to `.addConsElemDisjunction`. To add
2388  an individual linear/nonlinear constraint, prefer `.addCons()`.
2389 
2390  :param cons: constraint object
2391  :param name: the name of the constraint, generic name if empty (Default value = '')
2392  :param initial: should the LP relaxation of constraint be in the initial LP? (Default value = True)
2393  :param separate: should the constraint be separated during LP processing? (Default value = True)
2394  :param enforce: should the constraint be enforced during node processing? (Default value = True)
2395  :param check: should the constraint be checked for feasibility? (Default value = True)
2396  :param propagate: should the constraint be propagated during node processing? (Default value = True)
2397  :param local: is the constraint only valid locally? (Default value = False)
2398  :param modifiable: is the constraint modifiable (subject to column generation)? (Default value = False)
2399  :param dynamic: is the constraint subject to aging? (Default value = False)
2400  :param removable: should the relaxation be removed from the LP due to aging or cleanup? (Default value = False)
2401  :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)
2402  :return The created @ref scip#Constraint "Constraint" object.
2403 
2404  """
2405  if name == '':
2406  name = 'c'+str(SCIPgetNConss(self._scip)+1)
2407 
2408  kwargs = dict(name=name, initial=initial, separate=separate,
2409  enforce=enforce, check=check,
2410  propagate=propagate, local=local,
2411  modifiable=modifiable, dynamic=dynamic,
2412  removable=removable,
2413  stickingatnode=stickingatnode)
2414  kwargs['lhs'] = -SCIPinfinity(self._scip) if cons._lhs is None else cons._lhs
2415  kwargs['rhs'] = SCIPinfinity(self._scip) if cons._rhs is None else cons._rhs
2416 
2417  deg = cons.expr.degree()
2418  if deg <= 1:
2419  return self._createConsLinear(cons, **kwargs)
2420  elif deg <= 2:
2421  return self._createConsQuadratic(cons, **kwargs)
2422  elif deg == float('inf'): # general nonlinear
2423  return self._createConsGenNonlinear(cons, **kwargs)
2424  else:
2425  return self._createConsNonlinear(cons, **kwargs)
2426 
2427  # Constraint functions
2428  def addCons(self, cons, name='', initial=True, separate=True,
2429  enforce=True, check=True, propagate=True, local=False,
2430  modifiable=False, dynamic=False, removable=False,
2431  stickingatnode=False):
2432  """Add a linear or nonlinear constraint.
2433 
2434  :param cons: constraint object
2435  :param name: the name of the constraint, generic name if empty (Default value = '')
2436  :param initial: should the LP relaxation of constraint be in the initial LP? (Default value = True)
2437  :param separate: should the constraint be separated during LP processing? (Default value = True)
2438  :param enforce: should the constraint be enforced during node processing? (Default value = True)
2439  :param check: should the constraint be checked for feasibility? (Default value = True)
2440  :param propagate: should the constraint be propagated during node processing? (Default value = True)
2441  :param local: is the constraint only valid locally? (Default value = False)
2442  :param modifiable: is the constraint modifiable (subject to column generation)? (Default value = False)
2443  :param dynamic: is the constraint subject to aging? (Default value = False)
2444  :param removable: should the relaxation be removed from the LP due to aging or cleanup? (Default value = False)
2445  :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)
2446  :return The added @ref scip#Constraint "Constraint" object.
2447 
2448  """
2449  assert isinstance(cons, ExprCons), "given constraint is not ExprCons but %s" % cons.__class__.__name__
2450 
2451  cdef SCIP_CONS* scip_cons
2452 
2453  kwargs = dict(name=name, initial=initial, separate=separate,
2454  enforce=enforce, check=check,
2455  propagate=propagate, local=local,
2456  modifiable=modifiable, dynamic=dynamic,
2457  removable=removable,
2458  stickingatnode=stickingatnode)
2459  # we have to pass this back to a SCIP_CONS*
2460  # object to create a new python constraint & handle constraint release
2461  # correctly. Otherwise, segfaults when trying to query information
2462  # about the created constraint later.
2463  pycons_initial = self.createConsFromExpr(cons, **kwargs)
2464  scip_cons = (<Constraint>pycons_initial).scip_cons
2465 
2466  PY_SCIP_CALL(SCIPaddCons(self._scip, scip_cons))
2467  pycons = Constraint.create(scip_cons)
2468  PY_SCIP_CALL(SCIPreleaseCons(self._scip, &scip_cons))
2469 
2470  return pycons
2471 
2472  def addConss(self, conss, name='', initial=True, separate=True,
2473  enforce=True, check=True, propagate=True, local=False,
2474  modifiable=False, dynamic=False, removable=False,
2475  stickingatnode=False):
2476  """Adds multiple linear or quadratic constraints.
2477 
2478  Each of the constraints is added to the model using Model.addCons().
2479 
2480  For all parameters, except @p conss, this method behaves differently depending on the type of the passed argument:
2481  1. If the value is iterable, it must be of the same length as @p conss. For each constraint, Model.addCons() will be called with the value at the corresponding index.
2482  2. Else, the (default) value will be applied to all of the constraints.
2483 
2484  :param conss An iterable of constraint objects. Any iterable will be converted into a list before further processing.
2485  :param name: the names of the constraints, generic name if empty (Default value = ''). If a single string is passed, it will be suffixed by an underscore and the enumerated index of the constraint (starting with 0).
2486  :param initial: should the LP relaxation of constraints be in the initial LP? (Default value = True)
2487  :param separate: should the constraints be separated during LP processing? (Default value = True)
2488  :param enforce: should the constraints be enforced during node processing? (Default value = True)
2489  :param check: should the constraints be checked for feasibility? (Default value = True)
2490  :param propagate: should the constraints be propagated during node processing? (Default value = True)
2491  :param local: are the constraints only valid locally? (Default value = False)
2492  :param modifiable: are the constraints modifiable (subject to column generation)? (Default value = False)
2493  :param dynamic: are the constraints subject to aging? (Default value = False)
2494  :param removable: should the relaxation be removed from the LP due to aging or cleanup? (Default value = False)
2495  :param stickingatnode: should the constraints always be kept at the node where it was added, even if it may be @oved to a more global node? (Default value = False)
2496  :return A list of added @ref scip#Constraint "Constraint" objects.
2497 
2498  :see addCons()
2499  """
2500  def ensure_iterable(elem, length):
2501  if isinstance(elem, Iterable):
2502  return elem
2503  else:
2504  return list(repeat(elem, length))
2505 
2506  assert isinstance(conss, Iterable), "Given constraint list is not iterable."
2507 
2508  conss = list(conss)
2509  n_conss = len(conss)
2510 
2511  if isinstance(name, str):
2512  if name == "":
2513  name = ["" for idx in range(n_conss)]
2514  else:
2515  name = ["%s_%s" % (name, idx) for idx in range(n_conss)]
2516  initial = ensure_iterable(initial, n_conss)
2517  separate = ensure_iterable(separate, n_conss)
2518  enforce = ensure_iterable(enforce, n_conss)
2519  check = ensure_iterable(check, n_conss)
2520  propagate = ensure_iterable(propagate, n_conss)
2521  local = ensure_iterable(local, n_conss)
2522  modifiable = ensure_iterable(modifiable, n_conss)
2523  dynamic = ensure_iterable(dynamic, n_conss)
2524  removable = ensure_iterable(removable, n_conss)
2525  stickingatnode = ensure_iterable(stickingatnode, n_conss)
2526 
2527  constraints = []
2528  for i, cons in enumerate(conss):
2529  constraints.append(
2530  self.addCons(cons, name[i], initial[i], separate[i], enforce[i],
2531  check[i], propagate[i], local[i], modifiable[i],
2532  dynamic[i], removable[i], stickingatnode[i])
2533  )
2534 
2535  return constraints
2536 
2537  def addConsDisjunction(self, conss, name = '', initial = True,
2538  relaxcons = None, enforce=True, check =True,
2539  local=False, modifiable = False, dynamic = False):
2540  """Add a disjunction constraint.
2541 
2542  :param Iterable[Constraint] conss: An iterable of constraint objects to be included initially in the disjunction. Currently, these must be expressions.
2543  :param name: the name of the disjunction constraint.
2544  :param initial: should the LP relaxation of disjunction constraint be in the initial LP? (Default value = True)
2545  :param relaxcons: a conjunction constraint containing the linear relaxation of the disjunction constraint, or None. (Default value = None)
2546  :param enforce: should the constraint be enforced during node processing? (Default value = True)
2547  :param check: should the constraint be checked for feasibility? (Default value = True)
2548  :param local: is the constraint only valid locally? (Default value = False)
2549  :param modifiable: is the constraint modifiable (subject to column generation)? (Default value = False)
2550  :param dynamic: is the constraint subject to aging? (Default value = False)
2551  :return The added @ref scip#Constraint "Constraint" object.
2552  """
2553  def ensure_iterable(elem, length):
2554  if isinstance(elem, Iterable):
2555  return elem
2556  else:
2557  return list(repeat(elem, length))
2558  assert isinstance(conss, Iterable), "Given constraint list is not iterable"
2559 
2560  conss = list(conss)
2561  n_conss = len(conss)
2562 
2563  cdef SCIP_CONS* disj_cons
2564 
2565  cdef SCIP_CONS* scip_cons
2566 
2567  cdef SCIP_EXPR* scip_expr
2568 
2569  PY_SCIP_CALL(SCIPcreateConsDisjunction(
2570  self._scip, &disj_cons, str_conversion(name), 0, &scip_cons, NULL,
2571  initial, enforce, check, local, modifiable, dynamic
2572  ))
2573 
2574 
2575  # TODO add constraints to disjunction
2576  for i, cons in enumerate(conss):
2577  pycons = self.createConsFromExpr(cons, name=name, initial = initial,
2578  enforce=enforce, check=check,
2579  local=local, modifiable=modifiable, dynamic=dynamic
2580  )
2581  PY_SCIP_CALL(SCIPaddConsElemDisjunction(self._scip,disj_cons, (<Constraint>pycons).scip_cons))
2582  PY_SCIP_CALL(SCIPreleaseCons(self._scip, &(<Constraint>pycons).scip_cons))
2583  PY_SCIP_CALL(SCIPaddCons(self._scip, disj_cons))
2584  PyCons = Constraint.create(disj_cons)
2585  PY_SCIP_CALL(SCIPreleaseCons(self._scip, &disj_cons))
2586  return PyCons
2587 
2588  def addConsElemDisjunction(self, Constraint disj_cons, Constraint cons):
2589  """Appends a constraint to a disjunction.
2590 
2591  :param Constraint disj_cons: the disjunction constraint to append to.
2592  :param Constraint cons: the Constraint to append
2593  :return The disjunction constraint with added @ref scip#Constraint object.
2594  """
2595  PY_SCIP_CALL(SCIPaddConsElemDisjunction(self._scip, (<Constraint>disj_cons).scip_cons, (<Constraint>cons).scip_cons))
2596  PY_SCIP_CALL(SCIPreleaseCons(self._scip, &(<Constraint>cons).scip_cons))
2597  return disj_cons
2598 
2599  def getConsNVars(self, Constraint constraint):
2600  """
2601  Gets number of variables in a constraint.
2602 
2603  :param constraint: Constraint to get the number of variables from.
2604  """
2605  cdef int nvars
2606  cdef SCIP_Bool success
2607 
2608  PY_SCIP_CALL(SCIPgetConsNVars(self._scip, constraint.scip_cons, &nvars, &success))
2609 
2610  if not success:
2611  conshdlr = SCIPconsGetHdlr(constraint.scip_cons)
2612  conshdrlname = SCIPconshdlrGetName(conshdlr)
2613  raise TypeError("The constraint handler %s does not have this functionality." % conshdrlname)
2614 
2615  return nvars
2616 
2617  def getConsVars(self, Constraint constraint):
2618  """
2619  Gets variables in a constraint.
2620 
2621  :param constraint: Constraint to get the variables from.
2622  """
2623  cdef SCIP_Bool success
2624  cdef int _nvars
2625 
2626  SCIPgetConsNVars(self._scip, constraint.scip_cons, &_nvars, &success)
2627 
2628  cdef SCIP_VAR** _vars = <SCIP_VAR**> malloc(_nvars * sizeof(SCIP_VAR*))
2629  SCIPgetConsVars(self._scip, constraint.scip_cons, _vars, _nvars*sizeof(SCIP_VAR*), &success)
2630 
2631  vars = []
2632  for i in range(_nvars):
2633  ptr = <size_t>(_vars[i])
2634  # check whether the corresponding variable exists already
2635  if ptr in self._modelvars:
2636  vars.append(self._modelvars[ptr])
2637  else:
2638  # create a new variable
2639  var = Variable.create(_vars[i])
2640  assert var.ptr() == ptr
2641  self._modelvars[ptr] = var
2642  vars.append(var)
2643  return vars
2644 
2645  def printCons(self, Constraint constraint):
2646  return PY_SCIP_CALL(SCIPprintCons(self._scip, constraint.scip_cons, NULL))
2647 
2648  # TODO Find a better way to retrieve a scip expression from a python expression. Consider making GenExpr include Expr, to avoid using Union. See PR #760.
2649  from typing import Union
2650  def addExprNonlinear(self, Constraint cons, expr: Union[Expr,GenExpr], float coef):
2651  """
2652  Add coef*expr to nonlinear constraint.
2653  """
2654  assert self.getStage() == 1, "addExprNonlinear cannot be called in stage %i." % self.getStage()
2655  assert cons.isNonlinear(), "addExprNonlinear can only be called with nonlinear constraints."
2656 
2657  cdef Constraint temp_cons
2658  cdef SCIP_EXPR* scip_expr
2659 
2660  temp_cons = self.addCons(expr <= 0)
2661  scip_expr = SCIPgetExprNonlinear(temp_cons.scip_cons)
2662 
2663  PY_SCIP_CALL(SCIPaddExprNonlinear(self._scip, cons.scip_cons, scip_expr, coef))
2664  self.delCons(temp_cons)
2665 
2666  def addConsCoeff(self, Constraint cons, Variable var, coeff):
2667  """Add coefficient to the linear constraint (if non-zero).
2668 
2669  :param Constraint cons: constraint to be changed
2670  :param Variable var: variable to be added
2671  :param coeff: coefficient of new variable
2672 
2673  """
2674  PY_SCIP_CALL(SCIPaddCoefLinear(self._scip, cons.scip_cons, var.scip_var, coeff))
2675 
2676  def addConsNode(self, Node node, Constraint cons, Node validnode=None):
2677  """Add a constraint to the given node
2678 
2679  :param Node node: node to add the constraint to
2680  :param Constraint cons: constraint to add
2681  :param Node validnode: more global node where cons is also valid
2682 
2683  """
2684  if isinstance(validnode, Node):
2685  PY_SCIP_CALL(SCIPaddConsNode(self._scip, node.scip_node, cons.scip_cons, validnode.scip_node))
2686  else:
2687  PY_SCIP_CALL(SCIPaddConsNode(self._scip, node.scip_node, cons.scip_cons, NULL))
2688  Py_INCREF(cons)
2689 
2690  def addConsLocal(self, Constraint cons, Node validnode=None):
2691  """Add a constraint to the current node
2692 
2693  :param Constraint cons: constraint to add
2694  :param Node validnode: more global node where cons is also valid
2695 
2696  """
2697  if isinstance(validnode, Node):
2698  PY_SCIP_CALL(SCIPaddConsLocal(self._scip, cons.scip_cons, validnode.scip_node))
2699  else:
2700  PY_SCIP_CALL(SCIPaddConsLocal(self._scip, cons.scip_cons, NULL))
2701  Py_INCREF(cons)
2702 
2703  def addConsSOS1(self, vars, weights=None, name="SOS1cons",
2704  initial=True, separate=True, enforce=True, check=True,
2705  propagate=True, local=False, dynamic=False,
2706  removable=False, stickingatnode=False):
2707  """Add an SOS1 constraint.
2708 
2709  :param vars: list of variables to be included
2710  :param weights: list of weights (Default value = None)
2711  :param name: name of the constraint (Default value = "SOS1cons")
2712  :param initial: should the LP relaxation of constraint be in the initial LP? (Default value = True)
2713  :param separate: should the constraint be separated during LP processing? (Default value = True)
2714  :param enforce: should the constraint be enforced during node processing? (Default value = True)
2715  :param check: should the constraint be checked for feasibility? (Default value = True)
2716  :param propagate: should the constraint be propagated during node processing? (Default value = True)
2717  :param local: is the constraint only valid locally? (Default value = False)
2718  :param dynamic: is the constraint subject to aging? (Default value = False)
2719  :param removable: should the relaxation be removed from the LP due to aging or cleanup? (Default value = False)
2720  :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)
2721 
2722  """
2723  cdef SCIP_CONS* scip_cons
2724  cdef int _nvars
2725 
2726  PY_SCIP_CALL(SCIPcreateConsSOS1(self._scip, &scip_cons, str_conversion(name), 0, NULL, NULL,
2727  initial, separate, enforce, check, propagate, local, dynamic, removable, stickingatnode))
2728 
2729  if weights is None:
2730  for v in vars:
2731  var = <Variable>v
2732  PY_SCIP_CALL(SCIPappendVarSOS1(self._scip, scip_cons, var.scip_var))
2733  else:
2734  nvars = len(vars)
2735  for i in range(nvars):
2736  var = <Variable>vars[i]
2737  PY_SCIP_CALL(SCIPaddVarSOS1(self._scip, scip_cons, var.scip_var, weights[i]))
2738 
2739  PY_SCIP_CALL(SCIPaddCons(self._scip, scip_cons))
2740  return Constraint.create(scip_cons)
2741 
2742  def addConsSOS2(self, vars, weights=None, name="SOS2cons",
2743  initial=True, separate=True, enforce=True, check=True,
2744  propagate=True, local=False, dynamic=False,
2745  removable=False, stickingatnode=False):
2746  """Add an SOS2 constraint.
2747 
2748  :param vars: list of variables to be included
2749  :param weights: list of weights (Default value = None)
2750  :param name: name of the constraint (Default value = "SOS2cons")
2751  :param initial: should the LP relaxation of constraint be in the initial LP? (Default value = True)
2752  :param separate: should the constraint be separated during LP processing? (Default value = True)
2753  :param enforce: should the constraint be enforced during node processing? (Default value = True)
2754  :param check: should the constraint be checked for feasibility? (Default value = True)
2755  :param propagate: is the constraint only valid locally? (Default value = True)
2756  :param local: is the constraint only valid locally? (Default value = False)
2757  :param dynamic: is the constraint subject to aging? (Default value = False)
2758  :param removable: should the relaxation be removed from the LP due to aging or cleanup? (Default value = False)
2759  :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)
2760 
2761  """
2762  cdef SCIP_CONS* scip_cons
2763  cdef int _nvars
2764 
2765  PY_SCIP_CALL(SCIPcreateConsSOS2(self._scip, &scip_cons, str_conversion(name), 0, NULL, NULL,
2766  initial, separate, enforce, check, propagate, local, dynamic, removable, stickingatnode))
2767 
2768  if weights is None:
2769  for v in vars:
2770  var = <Variable>v
2771  PY_SCIP_CALL(SCIPappendVarSOS2(self._scip, scip_cons, var.scip_var))
2772  else:
2773  nvars = len(vars)
2774  for i in range(nvars):
2775  var = <Variable>vars[i]
2776  PY_SCIP_CALL(SCIPaddVarSOS2(self._scip, scip_cons, var.scip_var, weights[i]))
2777 
2778  PY_SCIP_CALL(SCIPaddCons(self._scip, scip_cons))
2779  return Constraint.create(scip_cons)
2780 
2781  def addConsAnd(self, vars, resvar, name="ANDcons",
2782  initial=True, separate=True, enforce=True, check=True,
2783  propagate=True, local=False, modifiable=False, dynamic=False,
2784  removable=False, stickingatnode=False):
2785  """Add an AND-constraint.
2786  :param vars: list of BINARY variables to be included (operators)
2787  :param resvar: BINARY variable (resultant)
2788  :param name: name of the constraint (Default value = "ANDcons")
2789  :param initial: should the LP relaxation of constraint be in the initial LP? (Default value = True)
2790  :param separate: should the constraint be separated during LP processing? (Default value = True)
2791  :param enforce: should the constraint be enforced during node processing? (Default value = True)
2792  :param check: should the constraint be checked for feasibility? (Default value = True)
2793  :param propagate: should the constraint be propagated during node processing? (Default value = True)
2794  :param local: is the constraint only valid locally? (Default value = False)
2795  :param modifiable: is the constraint modifiable (subject to column generation)? (Default value = False)
2796  :param dynamic: is the constraint subject to aging? (Default value = False)
2797  :param removable: should the relaxation be removed from the LP due to aging or cleanup? (Default value = False)
2798  :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)
2799  """
2800  cdef SCIP_CONS* scip_cons
2801 
2802  nvars = len(vars)
2803 
2804  _vars = <SCIP_VAR**> malloc(len(vars) * sizeof(SCIP_VAR*))
2805  for idx, var in enumerate(vars):
2806  _vars[idx] = (<Variable>var).scip_var
2807  _resVar = (<Variable>resvar).scip_var
2808 
2809  PY_SCIP_CALL(SCIPcreateConsAnd(self._scip, &scip_cons, str_conversion(name), _resVar, nvars, _vars,
2810  initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode))
2811 
2812  PY_SCIP_CALL(SCIPaddCons(self._scip, scip_cons))
2813  pyCons = Constraint.create(scip_cons)
2814  PY_SCIP_CALL(SCIPreleaseCons(self._scip, &scip_cons))
2815 
2816  free(_vars)
2817 
2818  return pyCons
2819 
2820  def addConsOr(self, vars, resvar, name="ORcons",
2821  initial=True, separate=True, enforce=True, check=True,
2822  propagate=True, local=False, modifiable=False, dynamic=False,
2823  removable=False, stickingatnode=False):
2824  """Add an OR-constraint.
2825  :param vars: list of BINARY variables to be included (operators)
2826  :param resvar: BINARY variable (resultant)
2827  :param name: name of the constraint (Default value = "ORcons")
2828  :param initial: should the LP relaxation of constraint be in the initial LP? (Default value = True)
2829  :param separate: should the constraint be separated during LP processing? (Default value = True)
2830  :param enforce: should the constraint be enforced during node processing? (Default value = True)
2831  :param check: should the constraint be checked for feasibility? (Default value = True)
2832  :param propagate: should the constraint be propagated during node processing? (Default value = True)
2833  :param local: is the constraint only valid locally? (Default value = False)
2834  :param modifiable: is the constraint modifiable (subject to column generation)? (Default value = False)
2835  :param dynamic: is the constraint subject to aging? (Default value = False)
2836  :param removable: should the relaxation be removed from the LP due to aging or cleanup? (Default value = False)
2837  :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)
2838  """
2839  cdef SCIP_CONS* scip_cons
2840 
2841  nvars = len(vars)
2842 
2843  _vars = <SCIP_VAR**> malloc(len(vars) * sizeof(SCIP_VAR*))
2844  for idx, var in enumerate(vars):
2845  _vars[idx] = (<Variable>var).scip_var
2846  _resVar = (<Variable>resvar).scip_var
2847 
2848  PY_SCIP_CALL(SCIPcreateConsOr(self._scip, &scip_cons, str_conversion(name), _resVar, nvars, _vars,
2849  initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode))
2850 
2851  PY_SCIP_CALL(SCIPaddCons(self._scip, scip_cons))
2852  pyCons = Constraint.create(scip_cons)
2853  PY_SCIP_CALL(SCIPreleaseCons(self._scip, &scip_cons))
2854 
2855  free(_vars)
2856 
2857  return pyCons
2858 
2859  def addConsXor(self, vars, rhsvar, name="XORcons",
2860  initial=True, separate=True, enforce=True, check=True,
2861  propagate=True, local=False, modifiable=False, dynamic=False,
2862  removable=False, stickingatnode=False):
2863  """Add a XOR-constraint.
2864  :param vars: list of BINARY variables to be included (operators)
2865  :param rhsvar: BOOLEAN value, explicit True, False or bool(obj) is needed (right-hand side)
2866  :param name: name of the constraint (Default value = "XORcons")
2867  :param initial: should the LP relaxation of constraint be in the initial LP? (Default value = True)
2868  :param separate: should the constraint be separated during LP processing? (Default value = True)
2869  :param enforce: should the constraint be enforced during node processing? (Default value = True)
2870  :param check: should the constraint be checked for feasibility? (Default value = True)
2871  :param propagate: should the constraint be propagated during node processing? (Default value = True)
2872  :param local: is the constraint only valid locally? (Default value = False)
2873  :param modifiable: is the constraint modifiable (subject to column generation)? (Default value = False)
2874  :param dynamic: is the constraint subject to aging? (Default value = False)
2875  :param removable: should the relaxation be removed from the LP due to aging or cleanup? (Default value = False)
2876  :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)
2877  """
2878  cdef SCIP_CONS* scip_cons
2879 
2880  nvars = len(vars)
2881 
2882  assert type(rhsvar) is type(bool()), "Provide BOOLEAN value as rhsvar, you gave %s." % type(rhsvar)
2883  _vars = <SCIP_VAR**> malloc(len(vars) * sizeof(SCIP_VAR*))
2884  for idx, var in enumerate(vars):
2885  _vars[idx] = (<Variable>var).scip_var
2886 
2887  PY_SCIP_CALL(SCIPcreateConsXor(self._scip, &scip_cons, str_conversion(name), rhsvar, nvars, _vars,
2888  initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode))
2889 
2890  PY_SCIP_CALL(SCIPaddCons(self._scip, scip_cons))
2891  pyCons = Constraint.create(scip_cons)
2892  PY_SCIP_CALL(SCIPreleaseCons(self._scip, &scip_cons))
2893 
2894  free(_vars)
2895 
2896  return pyCons
2897 
2898  def addConsCardinality(self, consvars, cardval, indvars=None, weights=None, name="CardinalityCons",
2899  initial=True, separate=True, enforce=True, check=True,
2900  propagate=True, local=False, dynamic=False,
2901  removable=False, stickingatnode=False):
2902  """Add a cardinality constraint that allows at most 'cardval' many nonzero variables.
2903 
2904  :param consvars: list of variables to be included
2905  :param cardval: nonnegative integer
2906  :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)
2907  :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)
2908  :param name: name of the constraint (Default value = "CardinalityCons")
2909  :param initial: should the LP relaxation of constraint be in the initial LP? (Default value = True)
2910  :param separate: should the constraint be separated during LP processing? (Default value = True)
2911  :param enforce: should the constraint be enforced during node processing? (Default value = True)
2912  :param check: should the constraint be checked for feasibility? (Default value = True)
2913  :param propagate: should the constraint be propagated during node processing? (Default value = True)
2914  :param local: is the constraint only valid locally? (Default value = False)
2915  :param dynamic: is the constraint subject to aging? (Default value = False)
2916  :param removable: should the relaxation be removed from the LP due to aging or cleanup? (Default value = False)
2917  :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)
2918 
2919  """
2920  cdef SCIP_CONS* scip_cons
2921  cdef SCIP_VAR* indvar
2922 
2923  PY_SCIP_CALL(SCIPcreateConsCardinality(self._scip, &scip_cons, str_conversion(name), 0, NULL, cardval, NULL, NULL,
2924  initial, separate, enforce, check, propagate, local, dynamic, removable, stickingatnode))
2925 
2926  # circumvent an annoying bug in SCIP 4.0.0 that does not allow uninitialized weights
2927  if weights is None:
2928  weights = list(range(1, len(consvars) + 1))
2929 
2930  for i, v in enumerate(consvars):
2931  var = <Variable>v
2932  if indvars:
2933  indvar = (<Variable>indvars[i]).scip_var
2934  else:
2935  indvar = NULL
2936  if weights is None:
2937  PY_SCIP_CALL(SCIPappendVarCardinality(self._scip, scip_cons, var.scip_var, indvar))
2938  else:
2939  PY_SCIP_CALL(SCIPaddVarCardinality(self._scip, scip_cons, var.scip_var, indvar, <SCIP_Real>weights[i]))
2940 
2941  PY_SCIP_CALL(SCIPaddCons(self._scip, scip_cons))
2942  pyCons = Constraint.create(scip_cons)
2943 
2944  PY_SCIP_CALL(SCIPreleaseCons(self._scip, &scip_cons))
2945 
2946  return pyCons
2947 
2948  def addConsIndicator(self, cons, binvar=None, activeone=True, name="IndicatorCons",
2949  initial=True, separate=True, enforce=True, check=True,
2950  propagate=True, local=False, dynamic=False,
2951  removable=False, stickingatnode=False):
2952  """Add an indicator constraint for the linear inequality 'cons'.
2953 
2954  The 'binvar' argument models the redundancy of the linear constraint. A solution for which
2955  'binvar' is 1 must satisfy the constraint.
2956 
2957  :param cons: a linear inequality of the form "<="
2958  :param binvar: binary indicator variable, or None if it should be created (Default value = None)
2959  :param activeone: constraint should active if binvar is 1 (0 if activeone = False)
2960  :param name: name of the constraint (Default value = "IndicatorCons")
2961  :param initial: should the LP relaxation of constraint be in the initial LP? (Default value = True)
2962  :param separate: should the constraint be separated during LP processing? (Default value = True)
2963  :param enforce: should the constraint be enforced during node processing? (Default value = True)
2964  :param check: should the constraint be checked for feasibility? (Default value = True)
2965  :param propagate: should the constraint be propagated during node processing? (Default value = True)
2966  :param local: is the constraint only valid locally? (Default value = False)
2967  :param dynamic: is the constraint subject to aging? (Default value = False)
2968  :param removable: should the relaxation be removed from the LP due to aging or cleanup? (Default value = False)
2969  :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)
2970 
2971  """
2972  assert isinstance(cons, ExprCons), "given constraint is not ExprCons but %s" % cons.__class__.__name__
2973  cdef SCIP_CONS* scip_cons
2974  cdef SCIP_VAR* _binVar
2975  if cons._lhs is not None and cons._rhs is not None:
2976  raise ValueError("expected inequality that has either only a left or right hand side")
2977 
2978  if cons.expr.degree() > 1:
2979  raise ValueError("expected linear inequality, expression has degree %d" % cons.expr.degree())
2980 
2981  if cons._rhs is not None:
2982  rhs = cons._rhs
2983  negate = False
2984  else:
2985  rhs = -cons._lhs
2986  negate = True
2987 
2988  if binvar is not None:
2989  _binVar = (<Variable>binvar).scip_var
2990  if not activeone:
2991  PY_SCIP_CALL(SCIPgetNegatedVar(self._scip, _binVar, &_binVar))
2992  else:
2993  _binVar = NULL
2994 
2995  PY_SCIP_CALL(SCIPcreateConsIndicator(self._scip, &scip_cons, str_conversion(name), _binVar, 0, NULL, NULL, rhs,
2996  initial, separate, enforce, check, propagate, local, dynamic, removable, stickingatnode))
2997  terms = cons.expr.terms
2998 
2999  for key, coeff in terms.items():
3000  var = <Variable>key[0]
3001  if negate:
3002  coeff = -coeff
3003  PY_SCIP_CALL(SCIPaddVarIndicator(self._scip, scip_cons, var.scip_var, <SCIP_Real>coeff))
3004 
3005  PY_SCIP_CALL(SCIPaddCons(self._scip, scip_cons))
3006  pyCons = Constraint.create(scip_cons)
3007 
3008  PY_SCIP_CALL(SCIPreleaseCons(self._scip, &scip_cons))
3009 
3010  return pyCons
3011 
3012  def getSlackVarIndicator(self, Constraint cons):
3013  """Get slack variable of an indicator constraint.
3014 
3015  :param Constraint cons: indicator constraint
3016 
3017  """
3018  cdef SCIP_VAR* var = SCIPgetSlackVarIndicator(cons.scip_cons);
3019  return Variable.create(var)
3020 
3021  def addPyCons(self, Constraint cons):
3022  """Adds a customly created cons.
3023 
3024  :param Constraint cons: constraint to add
3025 
3026  """
3027  PY_SCIP_CALL(SCIPaddCons(self._scip, cons.scip_cons))
3028  Py_INCREF(cons)
3029 
3030  def addVarSOS1(self, Constraint cons, Variable var, weight):
3031  """Add variable to SOS1 constraint.
3032 
3033  :param Constraint cons: SOS1 constraint
3034  :param Variable var: new variable
3035  :param weight: weight of new variable
3036 
3037  """
3038  PY_SCIP_CALL(SCIPaddVarSOS1(self._scip, cons.scip_cons, var.scip_var, weight))
3039 
3040  def appendVarSOS1(self, Constraint cons, Variable var):
3041  """Append variable to SOS1 constraint.
3042 
3043  :param Constraint cons: SOS1 constraint
3044  :param Variable var: variable to append
3045 
3046  """
3047  PY_SCIP_CALL(SCIPappendVarSOS1(self._scip, cons.scip_cons, var.scip_var))
3048 
3049  def addVarSOS2(self, Constraint cons, Variable var, weight):
3050  """Add variable to SOS2 constraint.
3051 
3052  :param Constraint cons: SOS2 constraint
3053  :param Variable var: new variable
3054  :param weight: weight of new variable
3055 
3056  """
3057  PY_SCIP_CALL(SCIPaddVarSOS2(self._scip, cons.scip_cons, var.scip_var, weight))
3058 
3059  def appendVarSOS2(self, Constraint cons, Variable var):
3060  """Append variable to SOS2 constraint.
3061 
3062  :param Constraint cons: SOS2 constraint
3063  :param Variable var: variable to append
3064 
3065  """
3066  PY_SCIP_CALL(SCIPappendVarSOS2(self._scip, cons.scip_cons, var.scip_var))
3067 
3068  def setInitial(self, Constraint cons, newInit):
3069  """Set "initial" flag of a constraint.
3070 
3071  Keyword arguments:
3072  cons -- constraint
3073  newInit -- new initial value
3074  """
3075  PY_SCIP_CALL(SCIPsetConsInitial(self._scip, cons.scip_cons, newInit))
3076 
3077  def setRemovable(self, Constraint cons, newRem):
3078  """Set "removable" flag of a constraint.
3079 
3080  Keyword arguments:
3081  cons -- constraint
3082  newRem -- new removable value
3083  """
3084  PY_SCIP_CALL(SCIPsetConsRemovable(self._scip, cons.scip_cons, newRem))
3085 
3086  def setEnforced(self, Constraint cons, newEnf):
3087  """Set "enforced" flag of a constraint.
3088 
3089  Keyword arguments:
3090  cons -- constraint
3091  newEnf -- new enforced value
3092  """
3093  PY_SCIP_CALL(SCIPsetConsEnforced(self._scip, cons.scip_cons, newEnf))
3094 
3095  def setCheck(self, Constraint cons, newCheck):
3096  """Set "check" flag of a constraint.
3097 
3098  Keyword arguments:
3099  cons -- constraint
3100  newCheck -- new check value
3101  """
3102  PY_SCIP_CALL(SCIPsetConsChecked(self._scip, cons.scip_cons, newCheck))
3103 
3104  def chgRhs(self, Constraint cons, rhs):
3105  """Change right hand side value of a constraint.
3106 
3107  :param Constraint cons: linear or quadratic constraint
3108  :param rhs: new right hand side (set to None for +infinity)
3109 
3110  """
3111 
3112  if rhs is None:
3113  rhs = SCIPinfinity(self._scip)
3114 
3115  constype = bytes(SCIPconshdlrGetName(SCIPconsGetHdlr(cons.scip_cons))).decode('UTF-8')
3116  if constype == 'linear':
3117  PY_SCIP_CALL(SCIPchgRhsLinear(self._scip, cons.scip_cons, rhs))
3118  elif constype == 'nonlinear':
3119  PY_SCIP_CALL(SCIPchgRhsNonlinear(self._scip, cons.scip_cons, rhs))
3120  else:
3121  raise Warning("method cannot be called for constraints of type " + constype)
3122 
3123  def chgLhs(self, Constraint cons, lhs):
3124  """Change left hand side value of a constraint.
3125 
3126  :param Constraint cons: linear or quadratic constraint
3127  :param lhs: new left hand side (set to None for -infinity)
3128 
3129  """
3130 
3131  if lhs is None:
3132  lhs = -SCIPinfinity(self._scip)
3133 
3134  constype = bytes(SCIPconshdlrGetName(SCIPconsGetHdlr(cons.scip_cons))).decode('UTF-8')
3135  if constype == 'linear':
3136  PY_SCIP_CALL(SCIPchgLhsLinear(self._scip, cons.scip_cons, lhs))
3137  elif constype == 'nonlinear':
3138  PY_SCIP_CALL(SCIPchgLhsNonlinear(self._scip, cons.scip_cons, lhs))
3139  else:
3140  raise Warning("method cannot be called for constraints of type " + constype)
3141 
3142  def getRhs(self, Constraint cons):
3143  """Retrieve right hand side value of a constraint.
3144 
3145  :param Constraint cons: linear or quadratic constraint
3146 
3147  """
3148  constype = bytes(SCIPconshdlrGetName(SCIPconsGetHdlr(cons.scip_cons))).decode('UTF-8')
3149  if constype == 'linear':
3150  return SCIPgetRhsLinear(self._scip, cons.scip_cons)
3151  elif constype == 'quadratic':
3152  return SCIPgetRhsNonlinear(cons.scip_cons)
3153  else:
3154  raise Warning("method cannot be called for constraints of type " + constype)
3155 
3156  def getLhs(self, Constraint cons):
3157  """Retrieve left hand side value of a constraint.
3158 
3159  :param Constraint cons: linear or quadratic constraint
3160 
3161  """
3162  constype = bytes(SCIPconshdlrGetName(SCIPconsGetHdlr(cons.scip_cons))).decode('UTF-8')
3163  if constype == 'linear':
3164  return SCIPgetLhsLinear(self._scip, cons.scip_cons)
3165  elif constype == 'quadratic':
3166  return SCIPgetLhsNonlinear(cons.scip_cons)
3167  else:
3168  raise Warning("method cannot be called for constraints of type " + constype)
3169 
3170  def chgCoefLinear(self, Constraint cons, Variable var, value):
3171  """Changes coefficient of variable in linear constraint;
3172  deletes the variable if coefficient is zero; adds variable if not yet contained in the constraint
3173  This method may only be called during problem creation stage for an original constraint and variable.
3174  This method requires linear time to search for occurences of the variable in the constraint data.
3175 
3176  :param Constraint cons: linear constraint
3177  :param Variable var: variable of constraint entry
3178  :param value: new coefficient of constraint entry
3179 
3180  """
3181  PY_SCIP_CALL( SCIPchgCoefLinear(self._scip, cons.scip_cons, var.scip_var, value) )
3182 
3183  def delCoefLinear(self, Constraint cons, Variable var):
3184  """Deletes variable from linear constraint
3185  This method may only be called during problem creation stage for an original constraint and variable.
3186  This method requires linear time to search for occurences of the variable in the constraint data.
3187 
3188  :param Constraint cons: linear constraint
3189  :param Variable var: variable of constraint entry
3190 
3191  """
3192 
3193  PY_SCIP_CALL( SCIPdelCoefLinear(self._scip, cons.scip_cons, var.scip_var) )
3194 
3195  def addCoefLinear(self, Constraint cons, Variable var, value):
3196  """Adds coefficient to linear constraint (if it is not zero)
3197 
3198  :param Constraint cons: linear constraint
3199  :param Variable var: variable of constraint entry
3200  :param value: coefficient of constraint entry
3201 
3202  """
3203 
3204  PY_SCIP_CALL( SCIPaddCoefLinear(self._scip, cons.scip_cons, var.scip_var, value) )
3205 
3206  def getActivity(self, Constraint cons, Solution sol = None):
3207  """Retrieve activity of given constraint.
3208  Can only be called after solving is completed.
3209 
3210  :param Constraint cons: linear or quadratic constraint
3211  :param Solution sol: solution to compute activity of, None to use current node's solution (Default value = None)
3212 
3213  """
3214  cdef SCIP_Real activity
3215  cdef SCIP_SOL* scip_sol
3216 
3217  if not self.getStage() >= SCIP_STAGE_SOLVING:
3218  raise Warning("method cannot be called before problem is solved")
3219 
3220  if isinstance(sol, Solution):
3221  scip_sol = sol.sol
3222  else:
3223  scip_sol = NULL
3224 
3225  constype = bytes(SCIPconshdlrGetName(SCIPconsGetHdlr(cons.scip_cons))).decode('UTF-8')
3226  if constype == 'linear':
3227  activity = SCIPgetActivityLinear(self._scip, cons.scip_cons, scip_sol)
3228  else:
3229  raise Warning("method cannot be called for constraints of type " + constype)
3230 
3231  return activity
3232 
3233 
3234  def getSlack(self, Constraint cons, Solution sol = None, side = None):
3235  """Retrieve slack of given constraint.
3236  Can only be called after solving is completed.
3237 
3238 
3239  :param Constraint cons: linear or quadratic constraint
3240  :param Solution sol: solution to compute slack of, None to use current node's solution (Default value = None)
3241  :param side: whether to use 'lhs' or 'rhs' for ranged constraints, None to return minimum (Default value = None)
3242 
3243  """
3244  cdef SCIP_Real activity
3245  cdef SCIP_SOL* scip_sol
3246 
3247 
3248  if not self.getStage() >= SCIP_STAGE_SOLVING:
3249  raise Warning("method cannot be called before problem is solved")
3250 
3251  if isinstance(sol, Solution):
3252  scip_sol = sol.sol
3253  else:
3254  scip_sol = NULL
3255 
3256  constype = bytes(SCIPconshdlrGetName(SCIPconsGetHdlr(cons.scip_cons))).decode('UTF-8')
3257  if constype == 'linear':
3258  lhs = SCIPgetLhsLinear(self._scip, cons.scip_cons)
3259  rhs = SCIPgetRhsLinear(self._scip, cons.scip_cons)
3260  activity = SCIPgetActivityLinear(self._scip, cons.scip_cons, scip_sol)
3261  else:
3262  raise Warning("method cannot be called for constraints of type " + constype)
3263 
3264  lhsslack = activity - lhs
3265  rhsslack = rhs - activity
3266 
3267  if side == 'lhs':
3268  return lhsslack
3269  elif side == 'rhs':
3270  return rhsslack
3271  else:
3272  return min(lhsslack, rhsslack)
3273 
3274  def getTransformedCons(self, Constraint cons):
3275  """Retrieve transformed constraint.
3276 
3277  :param Constraint cons: constraint
3278 
3279  """
3280  cdef SCIP_CONS* transcons
3281  PY_SCIP_CALL(SCIPgetTransformedCons(self._scip, cons.scip_cons, &transcons))
3282  return Constraint.create(transcons)
3283 
3284  def isNLPConstructed(self):
3285  """returns whether SCIP's internal NLP has been constructed"""
3286  return SCIPisNLPConstructed(self._scip)
3287 
3288  def getNNlRows(self):
3289  """gets current number of nonlinear rows in SCIP's internal NLP"""
3290  return SCIPgetNNLPNlRows(self._scip)
3291 
3292  def getNlRows(self):
3293  """returns a list with the nonlinear rows in SCIP's internal NLP"""
3294  cdef SCIP_NLROW** nlrows
3295 
3296  nlrows = SCIPgetNLPNlRows(self._scip)
3297  return [NLRow.create(nlrows[i]) for i in range(self.getNNlRows())]
3298 
3299  def getNlRowSolActivity(self, NLRow nlrow, Solution sol = None):
3300  """gives the activity of a nonlinear row for a given primal solution
3301  Keyword arguments:
3302  nlrow -- nonlinear row
3303  solution -- a primal solution, if None, then the current LP solution is used
3304  """
3305  cdef SCIP_Real activity
3306  cdef SCIP_SOL* solptr
3307 
3308  solptr = sol.sol if not sol is None else NULL
3309  PY_SCIP_CALL( SCIPgetNlRowSolActivity(self._scip, nlrow.scip_nlrow, solptr, &activity) )
3310  return activity
3311 
3312  def getNlRowSolFeasibility(self, NLRow nlrow, Solution sol = None):
3313  """gives the feasibility of a nonlinear row for a given primal solution
3314  Keyword arguments:
3315  nlrow -- nonlinear row
3316  solution -- a primal solution, if None, then the current LP solution is used
3317  """
3318  cdef SCIP_Real feasibility
3319  cdef SCIP_SOL* solptr
3320 
3321  solptr = sol.sol if not sol is None else NULL
3322  PY_SCIP_CALL( SCIPgetNlRowSolFeasibility(self._scip, nlrow.scip_nlrow, solptr, &feasibility) )
3323  return feasibility
3324 
3325  def getNlRowActivityBounds(self, NLRow nlrow):
3326  """gives the minimal and maximal activity of a nonlinear row w.r.t. the variable's bounds"""
3327  cdef SCIP_Real minactivity
3328  cdef SCIP_Real maxactivity
3329 
3330  PY_SCIP_CALL( SCIPgetNlRowActivityBounds(self._scip, nlrow.scip_nlrow, &minactivity, &maxactivity) )
3331  return (minactivity, maxactivity)
3332 
3333  def printNlRow(self, NLRow nlrow):
3334  """prints nonlinear row"""
3335  PY_SCIP_CALL( SCIPprintNlRow(self._scip, nlrow.scip_nlrow, NULL) )
3336 
3337  def checkQuadraticNonlinear(self, Constraint cons):
3338  """returns if the given constraint is quadratic
3339 
3340  :param Constraint cons: constraint
3341 
3342  """
3343  cdef SCIP_Bool isquadratic
3344  PY_SCIP_CALL( SCIPcheckQuadraticNonlinear(self._scip, cons.scip_cons, &isquadratic) )
3345  return isquadratic
3346 
3347  def getTermsQuadratic(self, Constraint cons):
3348  """Retrieve bilinear, quadratic, and linear terms of a quadratic constraint.
3349 
3350  :param Constraint cons: constraint
3351 
3352  """
3353  cdef SCIP_EXPR* expr
3354 
3355  # linear terms
3356  cdef SCIP_EXPR** _linexprs
3357  cdef SCIP_Real* _lincoefs
3358  cdef int _nlinvars
3359 
3360  # bilinear terms
3361  cdef int _nbilinterms
3362  cdef SCIP_EXPR* bilinterm1
3363  cdef SCIP_EXPR* bilinterm2
3364  cdef SCIP_Real bilincoef
3365 
3366  # quadratic terms
3367  cdef int _nquadterms
3368  cdef SCIP_Real sqrcoef
3369  cdef SCIP_Real lincoef
3370  cdef SCIP_EXPR* sqrexpr
3371 
3372  # variables
3373  cdef SCIP_VAR* scipvar1
3374  cdef SCIP_VAR* scipvar2
3375 
3376  assert cons.isNonlinear(), "constraint is not nonlinear"
3377  assert self.checkQuadraticNonlinear(cons), "constraint is not quadratic"
3378 
3379  expr = SCIPgetExprNonlinear(cons.scip_cons)
3380  SCIPexprGetQuadraticData(expr, NULL, &_nlinvars, &_linexprs, &_lincoefs, &_nquadterms, &_nbilinterms, NULL, NULL)
3381 
3382  linterms = []
3383  bilinterms = []
3384  quadterms = []
3385 
3386  for termidx in range(_nlinvars):
3387  var = Variable.create(SCIPgetVarExprVar(_linexprs[termidx]))
3388  linterms.append((var,_lincoefs[termidx]))
3389 
3390  for termidx in range(_nbilinterms):
3391  SCIPexprGetQuadraticBilinTerm(expr, termidx, &bilinterm1, &bilinterm2, &bilincoef, NULL, NULL)
3392  scipvar1 = SCIPgetVarExprVar(bilinterm1)
3393  scipvar2 = SCIPgetVarExprVar(bilinterm2)
3394  var1 = Variable.create(scipvar1)
3395  var2 = Variable.create(scipvar2)
3396  if scipvar1 != scipvar2:
3397  bilinterms.append((var1,var2,bilincoef))
3398  else:
3399  quadterms.append((var1,bilincoef,0.0))
3400 
3401  for termidx in range(_nquadterms):
3402  SCIPexprGetQuadraticQuadTerm(expr, termidx, NULL, &lincoef, &sqrcoef, NULL, NULL, &sqrexpr)
3403  if sqrexpr == NULL:
3404  continue
3405  var = Variable.create(SCIPgetVarExprVar(sqrexpr))
3406  quadterms.append((var,sqrcoef,lincoef))
3407 
3408  return (bilinterms, quadterms, linterms)
3409 
3410  def setRelaxSolVal(self, Variable var, val):
3411  """sets the value of the given variable in the global relaxation solution"""
3412  PY_SCIP_CALL(SCIPsetRelaxSolVal(self._scip, NULL, var.scip_var, val))
3413 
3414  def getConss(self, transformed=True):
3415  """Retrieve all constraints.
3416 
3417  :param transformed: get transformed variables instead of original (Default value = True)
3418  """
3419  cdef SCIP_CONS** _conss
3420  cdef int _nconss
3421  conss = []
3422 
3423  if transformed:
3424  _conss = SCIPgetConss(self._scip)
3425  _nconss = SCIPgetNConss(self._scip)
3426  else:
3427  _conss = SCIPgetOrigConss(self._scip)
3428  _nconss = SCIPgetNOrigConss(self._scip)
3429  return [Constraint.create(_conss[i]) for i in range(_nconss)]
3430 
3431  def getNConss(self, transformed=True):
3432  """Retrieve number of all constraints"""
3433  if transformed:
3434  return SCIPgetNConss(self._scip)
3435  else:
3436  return SCIPgetNOrigConss(self._scip)
3437 
3438  def delCons(self, Constraint cons):
3439  """Delete constraint from the model
3440 
3441  :param Constraint cons: constraint to be deleted
3442 
3443  """
3444  PY_SCIP_CALL(SCIPdelCons(self._scip, cons.scip_cons))
3445 
3446  def delConsLocal(self, Constraint cons):
3447  """Delete constraint from the current node and it's children
3448 
3449  :param Constraint cons: constraint to be deleted
3450 
3451  """
3452  PY_SCIP_CALL(SCIPdelConsLocal(self._scip, cons.scip_cons))
3453 
3454  def getValsLinear(self, Constraint cons):
3455  """Retrieve the coefficients of a linear constraint
3456 
3457  :param Constraint cons: linear constraint to get the coefficients of
3458 
3459  """
3460  cdef SCIP_Real* _vals
3461  cdef SCIP_VAR** _vars
3462 
3463  constype = bytes(SCIPconshdlrGetName(SCIPconsGetHdlr(cons.scip_cons))).decode('UTF-8')
3464  if not constype == 'linear':
3465  raise Warning("coefficients not available for constraints of type ", constype)
3466 
3467  _vals = SCIPgetValsLinear(self._scip, cons.scip_cons)
3468  _vars = SCIPgetVarsLinear(self._scip, cons.scip_cons)
3469 
3470  valsdict = {}
3471  for i in range(SCIPgetNVarsLinear(self._scip, cons.scip_cons)):
3472  valsdict[bytes(SCIPvarGetName(_vars[i])).decode('utf-8')] = _vals[i]
3473  return valsdict
3474 
3475  def getRowLinear(self, Constraint cons):
3476  """Retrieve the linear relaxation of the given linear constraint as a row.
3477  may return NULL if no LP row was yet created; the user must not modify the row!
3478 
3479  :param Constraint cons: linear constraint to get the coefficients of
3480 
3481  """
3482  constype = bytes(SCIPconshdlrGetName(SCIPconsGetHdlr(cons.scip_cons))).decode('UTF-8')
3483  if not constype == 'linear':
3484  raise Warning("coefficients not available for constraints of type ", constype)
3485 
3486  cdef SCIP_ROW* row = SCIPgetRowLinear(self._scip, cons.scip_cons)
3487  return Row.create(row)
3488 
3489  def getDualsolLinear(self, Constraint cons):
3490  """Retrieve the dual solution to a linear constraint.
3491 
3492  :param Constraint cons: linear constraint
3493 
3494  """
3495  constype = bytes(SCIPconshdlrGetName(SCIPconsGetHdlr(cons.scip_cons))).decode('UTF-8')
3496  if not constype == 'linear':
3497  raise Warning("dual solution values not available for constraints of type ", constype)
3498  if cons.isOriginal():
3499  transcons = <Constraint>self.getTransformedCons(cons)
3500  else:
3501  transcons = cons
3502  return SCIPgetDualsolLinear(self._scip, transcons.scip_cons)
3503 
3504  def getDualMultiplier(self, Constraint cons):
3505  """DEPRECATED: Retrieve the dual solution to a linear constraint.
3506 
3507  :param Constraint cons: linear constraint
3508 
3509  """
3510  raise Warning("model.getDualMultiplier(cons) is deprecated: please use model.getDualsolLinear(cons)")
3511  return self.getDualsolLinear(cons)
3512 
3513  def getDualfarkasLinear(self, Constraint cons):
3514  """Retrieve the dual farkas value to a linear constraint.
3515 
3516  :param Constraint cons: linear constraint
3517 
3518  """
3519  # TODO this should ideally be handled on the SCIP side
3520  if cons.isOriginal():
3521  transcons = <Constraint>self.getTransformedCons(cons)
3522  return SCIPgetDualfarkasLinear(self._scip, transcons.scip_cons)
3523  else:
3524  return SCIPgetDualfarkasLinear(self._scip, cons.scip_cons)
3525 
3526  def getVarRedcost(self, Variable var):
3527  """Retrieve the reduced cost of a variable.
3528 
3529  :param Variable var: variable to get the reduced cost of
3530 
3531  """
3532  redcost = None
3533  try:
3534  redcost = SCIPgetVarRedcost(self._scip, var.scip_var)
3535  if self.getObjectiveSense() == "maximize":
3536  redcost = -redcost
3537  except:
3538  raise Warning("no reduced cost available for variable " + var.name)
3539  return redcost
3540 
3541  def getDualSolVal(self, Constraint cons, boundconstraint=False):
3542  """Retrieve returns dual solution value of a constraint.
3543 
3544  :param Constraint cons: constraint to get the dual solution value of
3545  :param boundconstraint bool: Decides whether to store a bool if the constraint is a bound constraint
3546 
3547  """
3548  cdef SCIP_Real _dualsol
3549  cdef SCIP_Bool _bounded
3550 
3551  if boundconstraint:
3552  SCIPgetDualSolVal(self._scip, cons.scip_cons, &_dualsol, &_bounded)
3553  else:
3554  SCIPgetDualSolVal(self._scip, cons.scip_cons, &_dualsol, NULL)
3555 
3556  return _dualsol
3557 
3558  def optimize(self):
3559  """Optimize the problem."""
3560  PY_SCIP_CALL(SCIPsolve(self._scip))
3561  self._bestSol = Solution.create(self._scip, SCIPgetBestSol(self._scip))
3562 
3563  def solveConcurrent(self):
3564  """Transforms, presolves, and solves problem using additional solvers which emphasize on
3565  finding solutions."""
3566  if SCIPtpiGetNumThreads() == 1:
3567  warnings.warn("SCIP was compiled without task processing interface. Parallel solve not possible - using optimize() instead of solveConcurrent()")
3568  self.optimize()
3569  else:
3570  PY_SCIP_CALL(SCIPsolveConcurrent(self._scip))
3571  self._bestSol = Solution.create(self._scip, SCIPgetBestSol(self._scip))
3572 
3573  def presolve(self):
3574  """Presolve the problem."""
3575  PY_SCIP_CALL(SCIPpresolve(self._scip))
3576  self._bestSol = Solution.create(self._scip, SCIPgetBestSol(self._scip))
3577 
3578  # Benders' decomposition methods
3579  def initBendersDefault(self, subproblems):
3580  """initialises the default Benders' decomposition with a dictionary of subproblems
3581 
3582  Keyword arguments:
3583  subproblems -- a single Model instance or dictionary of Model instances
3584  """
3585  cdef SCIP** subprobs
3586  cdef SCIP_BENDERS* benders
3587 
3588  # checking whether subproblems is a dictionary
3589  if isinstance(subproblems, dict):
3590  isdict = True
3591  nsubproblems = len(subproblems)
3592  else:
3593  isdict = False
3594  nsubproblems = 1
3595 
3596  # create array of SCIP instances for the subproblems
3597  subprobs = <SCIP**> malloc(nsubproblems * sizeof(SCIP*))
3598 
3599  # if subproblems is a dictionary, then the dictionary is turned into a c array
3600  if isdict:
3601  for idx, subprob in enumerate(subproblems.values()):
3602  subprobs[idx] = (<Model>subprob)._scip
3603  else:
3604  subprobs[0] = (<Model>subproblems)._scip
3605 
3606  # creating the default Benders' decomposition
3607  PY_SCIP_CALL(SCIPcreateBendersDefault(self._scip, subprobs, nsubproblems))
3608  benders = SCIPfindBenders(self._scip, "default")
3609 
3610  # activating the Benders' decomposition constraint handlers
3611  self.setBoolParam("constraints/benderslp/active", True)
3612  self.setBoolParam("constraints/benders/active", True)
3613  #self.setIntParam("limits/maxorigsol", 0)
3614 
3616  """Solves the subproblems with the best solution to the master problem.
3617  Afterwards, the best solution from each subproblem can be queried to get
3618  the solution to the original problem.
3619 
3620  If the user wants to resolve the subproblems, they must free them by
3621  calling freeBendersSubproblems()
3622  """
3623  cdef SCIP_BENDERS** _benders
3624  cdef SCIP_Bool _infeasible
3625  cdef int nbenders
3626  cdef int nsubproblems
3627 
3628  solvecip = True
3629 
3630  nbenders = SCIPgetNActiveBenders(self._scip)
3631  _benders = SCIPgetBenders(self._scip)
3632 
3633  # solving all subproblems from all Benders' decompositions
3634  for i in range(nbenders):
3635  nsubproblems = SCIPbendersGetNSubproblems(_benders[i])
3636  for j in range(nsubproblems):
3637  PY_SCIP_CALL(SCIPsetupBendersSubproblem(self._scip,
3638  _benders[i], self._bestSol.sol, j, SCIP_BENDERSENFOTYPE_CHECK))
3639  PY_SCIP_CALL(SCIPsolveBendersSubproblem(self._scip,
3640  _benders[i], self._bestSol.sol, j, &_infeasible, solvecip, NULL))
3641 
3643  """Calls the free subproblem function for the Benders' decomposition.
3644  This will free all subproblems for all decompositions.
3645  """
3646  cdef SCIP_BENDERS** _benders
3647  cdef int nbenders
3648  cdef int nsubproblems
3649 
3650  nbenders = SCIPgetNActiveBenders(self._scip)
3651  _benders = SCIPgetBenders(self._scip)
3652 
3653  # solving all subproblems from all Benders' decompositions
3654  for i in range(nbenders):
3655  nsubproblems = SCIPbendersGetNSubproblems(_benders[i])
3656  for j in range(nsubproblems):
3657  PY_SCIP_CALL(SCIPfreeBendersSubproblem(self._scip, _benders[i],
3658  j))
3659 
3660  def updateBendersLowerbounds(self, lowerbounds, Benders benders=None):
3661  """"updates the subproblem lower bounds for benders using
3662  the lowerbounds dict. If benders is None, then the default
3663  Benders' decomposition is updated
3664  """
3665  cdef SCIP_BENDERS* _benders
3666 
3667  assert type(lowerbounds) is dict
3668 
3669  if benders is None:
3670  _benders = SCIPfindBenders(self._scip, "default")
3671  else:
3672  _benders = benders._benders
3673 
3674  for d in lowerbounds.keys():
3675  SCIPbendersUpdateSubproblemLowerbound(_benders, d, lowerbounds[d])
3676 
3677  def activateBenders(self, Benders benders, int nsubproblems):
3678  """Activates the Benders' decomposition plugin with the input name
3679 
3680  Keyword arguments:
3681  benders -- the Benders' decomposition to which the subproblem belongs to
3682  nsubproblems -- the number of subproblems in the Benders' decomposition
3683  """
3684  PY_SCIP_CALL(SCIPactivateBenders(self._scip, benders._benders, nsubproblems))
3685 
3686  def addBendersSubproblem(self, Benders benders, subproblem):
3687  """adds a subproblem to the Benders' decomposition given by the input
3688  name.
3689 
3690  Keyword arguments:
3691  benders -- the Benders' decomposition to which the subproblem belongs to
3692  subproblem -- the subproblem to add to the decomposition
3693  isconvex -- can be used to specify whether the subproblem is convex
3694  """
3695  PY_SCIP_CALL(SCIPaddBendersSubproblem(self._scip, benders._benders, (<Model>subproblem)._scip))
3696 
3697  def setBendersSubproblemIsConvex(self, Benders benders, probnumber, isconvex = True):
3698  """sets a flag indicating whether the subproblem is convex
3699 
3700  Keyword arguments:
3701  benders -- the Benders' decomposition which contains the subproblem
3702  probnumber -- the problem number of the subproblem that the convexity will be set for
3703  isconvex -- flag to indicate whether the subproblem is convex
3704  """
3705  SCIPbendersSetSubproblemIsConvex(benders._benders, probnumber, isconvex)
3706 
3707  def setupBendersSubproblem(self, probnumber, Benders benders = None, Solution solution = None, checktype = PY_SCIP_BENDERSENFOTYPE.LP):
3708  """ sets up the Benders' subproblem given the master problem solution
3709 
3710  Keyword arguments:
3711  probnumber -- the index of the problem that is to be set up
3712  benders -- the Benders' decomposition to which the subproblem belongs to
3713  solution -- the master problem solution that is used for the set up, if None, then the LP solution is used
3714  checktype -- the type of solution check that prompted the solving of the Benders' subproblems, either
3715  PY_SCIP_BENDERSENFOTYPE: LP, RELAX, PSEUDO or CHECK. Default is LP
3716  """
3717  cdef SCIP_BENDERS* scip_benders
3718  cdef SCIP_SOL* scip_sol
3719 
3720  if isinstance(solution, Solution):
3721  scip_sol = solution.sol
3722  else:
3723  scip_sol = NULL
3724 
3725  if benders is None:
3726  scip_benders = SCIPfindBenders(self._scip, "default")
3727  else:
3728  scip_benders = benders._benders
3729 
3730  retcode = SCIPsetupBendersSubproblem(self._scip, scip_benders, scip_sol, probnumber, checktype)
3731 
3732  PY_SCIP_CALL(retcode)
3733 
3734  def solveBendersSubproblem(self, probnumber, solvecip, Benders benders = None, Solution solution = None):
3735  """ solves the Benders' decomposition subproblem. The convex relaxation will be solved unless
3736  the parameter solvecip is set to True.
3737 
3738  Keyword arguments:
3739  probnumber -- the index of the problem that is to be set up
3740  solvecip -- should the CIP of the subproblem be solved, if False, then only the convex relaxation is solved
3741  benders -- the Benders' decomposition to which the subproblem belongs to
3742  solution -- the master problem solution that is used for the set up, if None, then the LP solution is used
3743  """
3744 
3745  cdef SCIP_BENDERS* scip_benders
3746  cdef SCIP_SOL* scip_sol
3747  cdef SCIP_Real objective
3748  cdef SCIP_Bool infeasible
3749 
3750  if isinstance(solution, Solution):
3751  scip_sol = solution.sol
3752  else:
3753  scip_sol = NULL
3754 
3755  if benders is None:
3756  scip_benders = SCIPfindBenders(self._scip, "default")
3757  else:
3758  scip_benders = benders._benders
3759 
3760  PY_SCIP_CALL(SCIPsolveBendersSubproblem(self._scip, scip_benders, scip_sol,
3761  probnumber, &infeasible, solvecip, &objective))
3762 
3763  return infeasible, objective
3764 
3765  def getBendersSubproblem(self, probnumber, Benders benders = None):
3766  """Returns a Model object that wraps around the SCIP instance of the subproblem.
3767  NOTE: This Model object is just a place holder and SCIP instance will not be freed when the object is destroyed.
3768 
3769  Keyword arguments:
3770  probnumber -- the problem number for subproblem that is required
3771  benders -- the Benders' decomposition object for the that the subproblem belongs to (Default = None)
3772  """
3773  cdef SCIP_BENDERS* scip_benders
3774  cdef SCIP* scip_subprob
3775 
3776  if benders is None:
3777  scip_benders = SCIPfindBenders(self._scip, "default")
3778  else:
3779  scip_benders = benders._benders
3780 
3781  scip_subprob = SCIPbendersSubproblem(scip_benders, probnumber)
3782 
3783  return Model.create(scip_subprob)
3784 
3785  def getBendersVar(self, Variable var, Benders benders = None, probnumber = -1):
3786  """Returns the variable for the subproblem or master problem
3787  depending on the input probnumber
3788 
3789  Keyword arguments:
3790  var -- the source variable for which the target variable is requested
3791  benders -- the Benders' decomposition to which the subproblem variables belong to
3792  probnumber -- the problem number for which the target variable belongs, -1 for master problem
3793  """
3794  cdef SCIP_BENDERS* _benders
3795  cdef SCIP_VAR* _mappedvar
3796 
3797  if benders is None:
3798  _benders = SCIPfindBenders(self._scip, "default")
3799  else:
3800  _benders = benders._benders
3801 
3802  if probnumber == -1:
3803  PY_SCIP_CALL(SCIPgetBendersMasterVar(self._scip, _benders, var.scip_var, &_mappedvar))
3804  else:
3805  PY_SCIP_CALL(SCIPgetBendersSubproblemVar(self._scip, _benders, var.scip_var, &_mappedvar, probnumber))
3806 
3807  if _mappedvar == NULL:
3808  mappedvar = None
3809  else:
3810  mappedvar = Variable.create(_mappedvar)
3811 
3812  return mappedvar
3813 
3814  def getBendersAuxiliaryVar(self, probnumber, Benders benders = None):
3815  """Returns the auxiliary variable that is associated with the input problem number
3816 
3817  Keyword arguments:
3818  probnumber -- the problem number for which the target variable belongs, -1 for master problem
3819  benders -- the Benders' decomposition to which the subproblem variables belong to
3820  """
3821  cdef SCIP_BENDERS* _benders
3822  cdef SCIP_VAR* _auxvar
3823 
3824  if benders is None:
3825  _benders = SCIPfindBenders(self._scip, "default")
3826  else:
3827  _benders = benders._benders
3828 
3829  _auxvar = SCIPbendersGetAuxiliaryVar(_benders, probnumber)
3830  auxvar = Variable.create(_auxvar)
3831 
3832  return auxvar
3833 
3834  def checkBendersSubproblemOptimality(self, Solution solution, probnumber, Benders benders = None):
3835  """Returns whether the subproblem is optimal w.r.t the master problem auxiliary variables.
3836 
3837  Keyword arguments:
3838  solution -- the master problem solution that is being checked for optimamlity
3839  probnumber -- the problem number for which optimality is being checked
3840  benders -- the Benders' decomposition to which the subproblem belongs to
3841  """
3842  cdef SCIP_BENDERS* _benders
3843  cdef SCIP_SOL* scip_sol
3844  cdef SCIP_Bool optimal
3845 
3846  if benders is None:
3847  _benders = SCIPfindBenders(self._scip, "default")
3848  else:
3849  _benders = benders._benders
3850 
3851  if isinstance(solution, Solution):
3852  scip_sol = solution.sol
3853  else:
3854  scip_sol = NULL
3855 
3856  PY_SCIP_CALL( SCIPcheckBendersSubproblemOptimality(self._scip, _benders,
3857  scip_sol, probnumber, &optimal) )
3858 
3859  return optimal
3860 
3861  def includeBendersDefaultCuts(self, Benders benders):
3862  """includes the default Benders' decomposition cuts to the custom Benders' decomposition plugin
3863 
3864  Keyword arguments:
3865  benders -- the Benders' decomposition that the default cuts will be applied to
3866  """
3867  PY_SCIP_CALL( SCIPincludeBendersDefaultCuts(self._scip, benders._benders) )
3868 
3869 
3870  def includeEventhdlr(self, Eventhdlr eventhdlr, name, desc):
3871  """Include an event handler.
3872 
3873  Keyword arguments:
3874  eventhdlr -- event handler
3875  name -- name of event handler
3876  desc -- description of event handler
3877  """
3878  n = str_conversion(name)
3879  d = str_conversion(desc)
3880  PY_SCIP_CALL(SCIPincludeEventhdlr(self._scip, n, d,
3881  PyEventCopy,
3882  PyEventFree,
3883  PyEventInit,
3884  PyEventExit,
3885  PyEventInitsol,
3886  PyEventExitsol,
3887  PyEventDelete,
3888  PyEventExec,
3889  <SCIP_EVENTHDLRDATA*>eventhdlr))
3890  eventhdlr.model = <Model>weakref.proxy(self)
3891  eventhdlr.name = name
3892  Py_INCREF(eventhdlr)
3893 
3894  def includePricer(self, Pricer pricer, name, desc, priority=1, delay=True):
3895  """Include a pricer.
3896 
3897  :param Pricer pricer: pricer
3898  :param name: name of pricer
3899  :param desc: description of pricer
3900  :param priority: priority of pricer (Default value = 1)
3901  :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)
3902 
3903  """
3904  n = str_conversion(name)
3905  d = str_conversion(desc)
3906  PY_SCIP_CALL(SCIPincludePricer(self._scip, n, d,
3907  priority, delay,
3908  PyPricerCopy, PyPricerFree, PyPricerInit, PyPricerExit, PyPricerInitsol, PyPricerExitsol, PyPricerRedcost, PyPricerFarkas,
3909  <SCIP_PRICERDATA*>pricer))
3910  cdef SCIP_PRICER* scip_pricer
3911  scip_pricer = SCIPfindPricer(self._scip, n)
3912  PY_SCIP_CALL(SCIPactivatePricer(self._scip, scip_pricer))
3913  pricer.model = <Model>weakref.proxy(self)
3914  Py_INCREF(pricer)
3915 
3916  def includeConshdlr(self, Conshdlr conshdlr, name, desc, sepapriority=0,
3917  enfopriority=0, chckpriority=0, sepafreq=-1, propfreq=-1,
3918  eagerfreq=100, maxprerounds=-1, delaysepa=False,
3919  delayprop=False, needscons=True,
3920  proptiming=PY_SCIP_PROPTIMING.BEFORELP,
3921  presoltiming=PY_SCIP_PRESOLTIMING.MEDIUM):
3922  """Include a constraint handler
3923 
3924  :param Conshdlr conshdlr: constraint handler
3925  :param name: name of constraint handler
3926  :param desc: description of constraint handler
3927  :param sepapriority: priority for separation (Default value = 0)
3928  :param enfopriority: priority for constraint enforcing (Default value = 0)
3929  :param chckpriority: priority for checking feasibility (Default value = 0)
3930  :param sepafreq: frequency for separating cuts; 0 = only at root node (Default value = -1)
3931  :param propfreq: frequency for propagating domains; 0 = only preprocessing propagation (Default value = -1)
3932  :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)
3933  :param maxprerounds: maximal number of presolving rounds the constraint handler participates in (Default value = -1)
3934  :param delaysepa: should separation method be delayed, if other separators found cuts? (Default value = False)
3935  :param delayprop: should propagation method be delayed, if other propagators found reductions? (Default value = False)
3936  :param needscons: should the constraint handler be skipped, if no constraints are available? (Default value = True)
3937  :param proptiming: positions in the node solving loop where propagation method of constraint handlers should be executed (Default value = SCIP_PROPTIMING.BEFORELP)
3938  :param presoltiming: timing mask of the constraint handler's presolving method (Default value = SCIP_PRESOLTIMING.MEDIUM)
3939 
3940  """
3941  n = str_conversion(name)
3942  d = str_conversion(desc)
3943  PY_SCIP_CALL(SCIPincludeConshdlr(self._scip, n, d, sepapriority, enfopriority, chckpriority, sepafreq, propfreq, eagerfreq,
3944  maxprerounds, delaysepa, delayprop, needscons, proptiming, presoltiming,
3945  PyConshdlrCopy, PyConsFree, PyConsInit, PyConsExit, PyConsInitpre, PyConsExitpre,
3946  PyConsInitsol, PyConsExitsol, PyConsDelete, PyConsTrans, PyConsInitlp, PyConsSepalp, PyConsSepasol,
3947  PyConsEnfolp, PyConsEnforelax, PyConsEnfops, PyConsCheck, PyConsProp, PyConsPresol, PyConsResprop, PyConsLock,
3948  PyConsActive, PyConsDeactive, PyConsEnable, PyConsDisable, PyConsDelvars, PyConsPrint, PyConsCopy,
3949  PyConsParse, PyConsGetvars, PyConsGetnvars, PyConsGetdivebdchgs, PyConsGetPermSymGraph, PyConsGetSignedPermSymGraph,
3950  <SCIP_CONSHDLRDATA*>conshdlr))
3951  conshdlr.model = <Model>weakref.proxy(self)
3952  conshdlr.name = name
3953  Py_INCREF(conshdlr)
3954 
3955  def createCons(self, Conshdlr conshdlr, name, initial=True, separate=True, enforce=True, check=True, propagate=True,
3956  local=False, modifiable=False, dynamic=False, removable=False, stickingatnode=False):
3957  """Create a constraint of a custom constraint handler
3958 
3959  :param Conshdlr conshdlr: constraint handler
3960  :param name: name of constraint
3961  :param initial: (Default value = True)
3962  :param separate: (Default value = True)
3963  :param enforce: (Default value = True)
3964  :param check: (Default value = True)
3965  :param propagate: (Default value = True)
3966  :param local: (Default value = False)
3967  :param modifiable: (Default value = False)
3968  :param dynamic: (Default value = False)
3969  :param removable: (Default value = False)
3970  :param stickingatnode: (Default value = False)
3971 
3972  """
3973 
3974  n = str_conversion(name)
3975  cdef SCIP_CONSHDLR* scip_conshdlr
3976  scip_conshdlr = SCIPfindConshdlr(self._scip, str_conversion(conshdlr.name))
3977  constraint = Constraint()
3978  PY_SCIP_CALL(SCIPcreateCons(self._scip, &(constraint.scip_cons), n, scip_conshdlr, <SCIP_CONSDATA*>constraint,
3979  initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode))
3980  return constraint
3981 
3982  def includePresol(self, Presol presol, name, desc, priority, maxrounds, timing=SCIP_PRESOLTIMING_FAST):
3983  """Include a presolver
3984 
3985  :param Presol presol: presolver
3986  :param name: name of presolver
3987  :param desc: description of presolver
3988  :param priority: priority of the presolver (>= 0: before, < 0: after constraint handlers)
3989  :param maxrounds: maximal number of presolving rounds the presolver participates in (-1: no limit)
3990  :param timing: timing mask of presolver (Default value = SCIP_PRESOLTIMING_FAST)
3991 
3992  """
3993  n = str_conversion(name)
3994  d = str_conversion(desc)
3995  PY_SCIP_CALL(SCIPincludePresol(self._scip, n, d, priority, maxrounds, timing, PyPresolCopy, PyPresolFree, PyPresolInit,
3996  PyPresolExit, PyPresolInitpre, PyPresolExitpre, PyPresolExec, <SCIP_PRESOLDATA*>presol))
3997  presol.model = <Model>weakref.proxy(self)
3998  Py_INCREF(presol)
3999 
4000  def includeSepa(self, Sepa sepa, name, desc, priority=0, freq=10, maxbounddist=1.0, usessubscip=False, delay=False):
4001  """Include a separator
4002 
4003  :param Sepa sepa: separator
4004  :param name: name of separator
4005  :param desc: description of separator
4006  :param priority: priority of separator (>= 0: before, < 0: after constraint handlers)
4007  :param freq: frequency for calling separator
4008  :param maxbounddist: maximal relative distance from current node's dual bound to primal bound compared to best node's dual bound for applying separation
4009  :param usessubscip: does the separator use a secondary SCIP instance? (Default value = False)
4010  :param delay: should separator be delayed, if other separators found cuts? (Default value = False)
4011 
4012  """
4013  n = str_conversion(name)
4014  d = str_conversion(desc)
4015  PY_SCIP_CALL(SCIPincludeSepa(self._scip, n, d, priority, freq, maxbounddist, usessubscip, delay, PySepaCopy, PySepaFree,
4016  PySepaInit, PySepaExit, PySepaInitsol, PySepaExitsol, PySepaExeclp, PySepaExecsol, <SCIP_SEPADATA*>sepa))
4017  sepa.model = <Model>weakref.proxy(self)
4018  sepa.name = name
4019  Py_INCREF(sepa)
4020 
4021  def includeReader(self, Reader reader, name, desc, ext):
4022  """Include a reader
4023 
4024  :param Reader reader: reader
4025  :param name: name of reader
4026  :param desc: description of reader
4027  :param ext: file extension of reader
4028 
4029  """
4030  n = str_conversion(name)
4031  d = str_conversion(desc)
4032  e = str_conversion(ext)
4033  PY_SCIP_CALL(SCIPincludeReader(self._scip, n, d, e, PyReaderCopy, PyReaderFree,
4034  PyReaderRead, PyReaderWrite, <SCIP_READERDATA*>reader))
4035  reader.model = <Model>weakref.proxy(self)
4036  reader.name = name
4037  Py_INCREF(reader)
4038 
4039  def includeProp(self, Prop prop, name, desc, presolpriority, presolmaxrounds,
4040  proptiming, presoltiming=SCIP_PRESOLTIMING_FAST, priority=1, freq=1, delay=True):
4041  """Include a propagator.
4042 
4043  :param Prop prop: propagator
4044  :param name: name of propagator
4045  :param desc: description of propagator
4046  :param presolpriority: presolving priority of the propgator (>= 0: before, < 0: after constraint handlers)
4047  :param presolmaxrounds: maximal number of presolving rounds the propagator participates in (-1: no limit)
4048  :param proptiming: positions in the node solving loop where propagation method of constraint handlers should be executed
4049  :param presoltiming: timing mask of the constraint handler's presolving method (Default value = SCIP_PRESOLTIMING_FAST)
4050  :param priority: priority of the propagator (Default value = 1)
4051  :param freq: frequency for calling propagator (Default value = 1)
4052  :param delay: should propagator be delayed if other propagators have found reductions? (Default value = True)
4053 
4054  """
4055  n = str_conversion(name)
4056  d = str_conversion(desc)
4057  PY_SCIP_CALL(SCIPincludeProp(self._scip, n, d,
4058  priority, freq, delay,
4059  proptiming, presolpriority, presolmaxrounds,
4060  presoltiming, PyPropCopy, PyPropFree, PyPropInit, PyPropExit,
4061  PyPropInitpre, PyPropExitpre, PyPropInitsol, PyPropExitsol,
4062  PyPropPresol, PyPropExec, PyPropResProp,
4063  <SCIP_PROPDATA*> prop))
4064  prop.model = <Model>weakref.proxy(self)
4065  Py_INCREF(prop)
4066 
4067  def includeHeur(self, Heur heur, name, desc, dispchar, priority=10000, freq=1, freqofs=0,
4068  maxdepth=-1, timingmask=SCIP_HEURTIMING_BEFORENODE, usessubscip=False):
4069  """Include a primal heuristic.
4070 
4071  :param Heur heur: heuristic
4072  :param name: name of heuristic
4073  :param desc: description of heuristic
4074  :param dispchar: display character of heuristic
4075  :param priority: priority of the heuristic (Default value = 10000)
4076  :param freq: frequency for calling heuristic (Default value = 1)
4077  :param freqofs: frequency offset for calling heuristic (Default value = 0)
4078  :param maxdepth: maximal depth level to call heuristic at (Default value = -1)
4079  :param timingmask: positions in the node solving loop where heuristic should be executed (Default value = SCIP_HEURTIMING_BEFORENODE)
4080  :param usessubscip: does the heuristic use a secondary SCIP instance? (Default value = False)
4081 
4082  """
4083  nam = str_conversion(name)
4084  des = str_conversion(desc)
4085  dis = ord(str_conversion(dispchar))
4086  PY_SCIP_CALL(SCIPincludeHeur(self._scip, nam, des, dis,
4087  priority, freq, freqofs,
4088  maxdepth, timingmask, usessubscip,
4089  PyHeurCopy, PyHeurFree, PyHeurInit, PyHeurExit,
4090  PyHeurInitsol, PyHeurExitsol, PyHeurExec,
4091  <SCIP_HEURDATA*> heur))
4092  heur.model = <Model>weakref.proxy(self)
4093  heur.name = name
4094  Py_INCREF(heur)
4095 
4096  def includeRelax(self, Relax relax, name, desc, priority=10000, freq=1):
4097  """Include a relaxation handler.
4098 
4099  :param Relax relax: relaxation handler
4100  :param name: name of relaxation handler
4101  :param desc: description of relaxation handler
4102  :param priority: priority of the relaxation handler (negative: after LP, non-negative: before LP, Default value = 10000)
4103  :param freq: frequency for calling relaxation handler
4104 
4105  """
4106  nam = str_conversion(name)
4107  des = str_conversion(desc)
4108  PY_SCIP_CALL(SCIPincludeRelax(self._scip, nam, des, priority, freq, PyRelaxCopy, PyRelaxFree, PyRelaxInit, PyRelaxExit,
4109  PyRelaxInitsol, PyRelaxExitsol, PyRelaxExec, <SCIP_RELAXDATA*> relax))
4110  relax.model = <Model>weakref.proxy(self)
4111  relax.name = name
4112 
4113  Py_INCREF(relax)
4114 
4115  def includeCutsel(self, Cutsel cutsel, name, desc, priority):
4116  """include a cut selector
4117 
4118  :param Cutsel cutsel: cut selector
4119  :param name: name of cut selector
4120  :param desc: description of cut selector
4121  :param priority: priority of the cut selector
4122  """
4123 
4124  nam = str_conversion(name)
4125  des = str_conversion(desc)
4126  PY_SCIP_CALL(SCIPincludeCutsel(self._scip, nam, des,
4127  priority, PyCutselCopy, PyCutselFree, PyCutselInit, PyCutselExit,
4128  PyCutselInitsol, PyCutselExitsol, PyCutselSelect,
4129  <SCIP_CUTSELDATA*> cutsel))
4130  cutsel.model = <Model>weakref.proxy(self)
4131  Py_INCREF(cutsel)
4132 
4133  def includeBranchrule(self, Branchrule branchrule, name, desc, priority, maxdepth, maxbounddist):
4134  """Include a branching rule.
4135 
4136  :param Branchrule branchrule: branching rule
4137  :param name: name of branching rule
4138  :param desc: description of branching rule
4139  :param priority: priority of branching rule
4140  :param maxdepth: maximal depth level up to which this branching rule should be used (or -1)
4141  :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)
4142 
4143  """
4144  nam = str_conversion(name)
4145  des = str_conversion(desc)
4146  PY_SCIP_CALL(SCIPincludeBranchrule(self._scip, nam, des,
4147  priority, maxdepth, maxbounddist,
4148  PyBranchruleCopy, PyBranchruleFree, PyBranchruleInit, PyBranchruleExit,
4149  PyBranchruleInitsol, PyBranchruleExitsol, PyBranchruleExeclp, PyBranchruleExecext,
4150  PyBranchruleExecps, <SCIP_BRANCHRULEDATA*> branchrule))
4151  branchrule.model = <Model>weakref.proxy(self)
4152  Py_INCREF(branchrule)
4153 
4154  def includeNodesel(self, Nodesel nodesel, name, desc, stdpriority, memsavepriority):
4155  """Include a node selector.
4156 
4157  :param Nodesel nodesel: node selector
4158  :param name: name of node selector
4159  :param desc: description of node selector
4160  :param stdpriority: priority of the node selector in standard mode
4161  :param memsavepriority: priority of the node selector in memory saving mode
4162 
4163  """
4164  nam = str_conversion(name)
4165  des = str_conversion(desc)
4166  PY_SCIP_CALL(SCIPincludeNodesel(self._scip, nam, des,
4167  stdpriority, memsavepriority,
4168  PyNodeselCopy, PyNodeselFree, PyNodeselInit, PyNodeselExit,
4169  PyNodeselInitsol, PyNodeselExitsol, PyNodeselSelect, PyNodeselComp,
4170  <SCIP_NODESELDATA*> nodesel))
4171  nodesel.model = <Model>weakref.proxy(self)
4172  Py_INCREF(nodesel)
4173 
4174  def includeBenders(self, Benders benders, name, desc, priority=1, cutlp=True, cutpseudo=True, cutrelax=True,
4175  shareaux=False):
4176  """Include a Benders' decomposition.
4177 
4178  Keyword arguments:
4179  benders -- the Benders decomposition
4180  name -- the name
4181  desc -- the description
4182  priority -- priority of the Benders' decomposition
4183  cutlp -- should Benders' cuts be generated from LP solutions
4184  cutpseudo -- should Benders' cuts be generated from pseudo solutions
4185  cutrelax -- should Benders' cuts be generated from relaxation solutions
4186  shareaux -- should the Benders' decomposition share the auxiliary variables of the highest priority Benders' decomposition
4187  """
4188  n = str_conversion(name)
4189  d = str_conversion(desc)
4190  PY_SCIP_CALL(SCIPincludeBenders(self._scip, n, d,
4191  priority, cutlp, cutrelax, cutpseudo, shareaux,
4192  PyBendersCopy, PyBendersFree, PyBendersInit, PyBendersExit, PyBendersInitpre,
4193  PyBendersExitpre, PyBendersInitsol, PyBendersExitsol, PyBendersGetvar,
4194  PyBendersCreatesub, PyBendersPresubsolve, PyBendersSolvesubconvex,
4195  PyBendersSolvesub, PyBendersPostsolve, PyBendersFreesub,
4196  <SCIP_BENDERSDATA*>benders))
4197  cdef SCIP_BENDERS* scip_benders
4198  scip_benders = SCIPfindBenders(self._scip, n)
4199  benders.model = <Model>weakref.proxy(self)
4200  benders.name = name
4201  benders._benders = scip_benders
4202  Py_INCREF(benders)
4203 
4204  def includeBenderscut(self, Benders benders, Benderscut benderscut, name, desc, priority=1, islpcut=True):
4205  """ Include a Benders' decomposition cutting method
4206 
4207  Keyword arguments:
4208  benders -- the Benders' decomposition that this cutting method is attached to
4209  benderscut --- the Benders' decomposition cutting method
4210  name -- the name
4211  desc -- the description
4212  priority -- priority of the Benders' decomposition
4213  islpcut -- is this cutting method suitable for generating cuts for convex relaxations?
4214  """
4215  cdef SCIP_BENDERS* _benders
4216 
4217  _benders = benders._benders
4218 
4219  n = str_conversion(name)
4220  d = str_conversion(desc)
4221  PY_SCIP_CALL(SCIPincludeBenderscut(self._scip, _benders, n, d, priority, islpcut,
4222  PyBenderscutCopy, PyBenderscutFree, PyBenderscutInit, PyBenderscutExit,
4223  PyBenderscutInitsol, PyBenderscutExitsol, PyBenderscutExec,
4224  <SCIP_BENDERSCUTDATA*>benderscut))
4225 
4226  cdef SCIP_BENDERSCUT* scip_benderscut
4227  scip_benderscut = SCIPfindBenderscut(_benders, n)
4228  benderscut.model = <Model>weakref.proxy(self)
4229  benderscut.benders = benders
4230  benderscut.name = name
4231  # TODO: It might be necessary in increment the reference to benders i.e Py_INCREF(benders)
4232  Py_INCREF(benderscut)
4233 
4234 
4235  def getLPBranchCands(self):
4236  """gets branching candidates for LP solution branching (fractional variables) along with solution values,
4237  fractionalities, and number of branching candidates; The number of branching candidates does NOT account
4238  for fractional implicit integer variables which should not be used for branching decisions. Fractional
4239  implicit integer variables are stored at the positions *nlpcands to *nlpcands + *nfracimplvars - 1
4240  branching rules should always select the branching candidate among the first npriolpcands of the candidate list
4241 
4242  :return tuple (lpcands, lpcandssol, lpcadsfrac, nlpcands, npriolpcands, nfracimplvars) where
4243 
4244  lpcands: list of variables of LP branching candidates
4245  lpcandssol: list of LP candidate solution values
4246  lpcandsfrac list of LP candidate fractionalities
4247  nlpcands: number of LP branching candidates
4248  npriolpcands: number of candidates with maximal priority
4249  nfracimplvars: number of fractional implicit integer variables
4250 
4251  """
4252  cdef int ncands
4253  cdef int nlpcands
4254  cdef int npriolpcands
4255  cdef int nfracimplvars
4256 
4257  cdef SCIP_VAR** lpcands
4258  cdef SCIP_Real* lpcandssol
4259  cdef SCIP_Real* lpcandsfrac
4260 
4261  PY_SCIP_CALL(SCIPgetLPBranchCands(self._scip, &lpcands, &lpcandssol, &lpcandsfrac,
4262  &nlpcands, &npriolpcands, &nfracimplvars))
4263 
4264  return ([Variable.create(lpcands[i]) for i in range(nlpcands)], [lpcandssol[i] for i in range(nlpcands)],
4265  [lpcandsfrac[i] for i in range(nlpcands)], nlpcands, npriolpcands, nfracimplvars)
4266 
4268  """gets branching candidates for pseudo solution branching (non-fixed variables)
4269  along with the number of candidates.
4270 
4271  :return tuple (pseudocands, npseudocands, npriopseudocands) where
4272 
4273  pseudocands: list of variables of pseudo branching candidates
4274  npseudocands: number of pseudo branching candidates
4275  npriopseudocands: number of candidates with maximal priority
4276 
4277  """
4278  cdef int npseudocands
4279  cdef int npriopseudocands
4280 
4281  cdef SCIP_VAR** pseudocands
4282 
4283  PY_SCIP_CALL(SCIPgetPseudoBranchCands(self._scip, &pseudocands, &npseudocands, &npriopseudocands))
4284 
4285  return ([Variable.create(pseudocands[i]) for i in range(npseudocands)], npseudocands, npriopseudocands)
4286 
4287  def branchVar(self, Variable variable):
4288  """Branch on a non-continuous variable.
4289 
4290  :param variable: Variable to branch on
4291  :return: tuple(downchild, eqchild, upchild) of Nodes of the left, middle and right child. Middle child only exists
4292  if branch variable is integer (it is None otherwise)
4293 
4294  """
4295  cdef SCIP_NODE* downchild
4296  cdef SCIP_NODE* eqchild
4297  cdef SCIP_NODE* upchild
4298 
4299  PY_SCIP_CALL(SCIPbranchVar(self._scip, (<Variable>variable).scip_var, &downchild, &eqchild, &upchild))
4300  return Node.create(downchild), Node.create(eqchild), Node.create(upchild)
4301 
4302 
4303  def branchVarVal(self, variable, value):
4304  """Branches on variable using a value which separates the domain of the variable.
4305 
4306  :param variable: Variable to branch on
4307  :param value: float, value to branch on
4308  :return: tuple(downchild, eqchild, upchild) of Nodes of the left, middle and right child. Middle child only exists
4309  if branch variable is integer (it is None otherwise)
4310 
4311  """
4312  cdef SCIP_NODE* downchild
4313  cdef SCIP_NODE* eqchild
4314  cdef SCIP_NODE* upchild
4315 
4316  PY_SCIP_CALL(SCIPbranchVarVal(self._scip, (<Variable>variable).scip_var, value, &downchild, &eqchild, &upchild))
4317 
4318  return Node.create(downchild), Node.create(eqchild), Node.create(upchild)
4319 
4320  def calcNodeselPriority(self, Variable variable, branchdir, targetvalue):
4321  """calculates the node selection priority for moving the given variable's LP value
4322  to the given target value;
4323  this node selection priority can be given to the SCIPcreateChild() call
4324 
4325  :param variable: variable on which the branching is applied
4326  :param branchdir: type of branching that was performed
4327  :param targetvalue: new value of the variable in the child node
4328  :return: node selection priority for moving the given variable's LP value to the given target value
4329 
4330  """
4331  return SCIPcalcNodeselPriority(self._scip, variable.scip_var, branchdir, targetvalue)
4332 
4333  def calcChildEstimate(self, Variable variable, targetvalue):
4334  """Calculates an estimate for the objective of the best feasible solution
4335  contained in the subtree after applying the given branching;
4336  this estimate can be given to the SCIPcreateChild() call
4337 
4338  :param variable: Variable to compute the estimate for
4339  :param targetvalue: new value of the variable in the child node
4340  :return: objective estimate of the best solution in the subtree after applying the given branching
4341 
4342  """
4343  return SCIPcalcChildEstimate(self._scip, variable.scip_var, targetvalue)
4344 
4345  def createChild(self, nodeselprio, estimate):
4346  """Create a child node of the focus node.
4347 
4348  :param nodeselprio: float, node selection priority of new node
4349  :param estimate: float, estimate for(transformed) objective value of best feasible solution in subtree
4350  :return: Node, the child which was created
4351 
4352  """
4353  cdef SCIP_NODE* child
4354  PY_SCIP_CALL(SCIPcreateChild(self._scip, &child, nodeselprio, estimate))
4355  return Node.create(child)
4356 
4357  # Diving methods (Diving is LP related)
4358  def startDive(self):
4359  """Initiates LP diving
4360  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,
4361  SCIP will undo all changes done and recover the LP it had before startDive
4362  """
4363  PY_SCIP_CALL(SCIPstartDive(self._scip))
4364 
4365  def endDive(self):
4366  """Quits probing and resets bounds and constraints to the focus node's environment"""
4367  PY_SCIP_CALL(SCIPendDive(self._scip))
4368 
4369  def chgVarObjDive(self, Variable var, newobj):
4370  """changes (column) variable's objective value in current dive"""
4371  PY_SCIP_CALL(SCIPchgVarObjDive(self._scip, var.scip_var, newobj))
4372 
4373  def chgVarLbDive(self, Variable var, newbound):
4374  """changes variable's current lb in current dive"""
4375  PY_SCIP_CALL(SCIPchgVarLbDive(self._scip, var.scip_var, newbound))
4376 
4377  def chgVarUbDive(self, Variable var, newbound):
4378  """changes variable's current ub in current dive"""
4379  PY_SCIP_CALL(SCIPchgVarUbDive(self._scip, var.scip_var, newbound))
4380 
4381  def getVarLbDive(self, Variable var):
4382  """returns variable's current lb in current dive"""
4383  return SCIPgetVarLbDive(self._scip, var.scip_var)
4384 
4385  def getVarUbDive(self, Variable var):
4386  """returns variable's current ub in current dive"""
4387  return SCIPgetVarUbDive(self._scip, var.scip_var)
4388 
4389  def chgRowLhsDive(self, Row row, newlhs):
4390  """changes row lhs in current dive, change will be undone after diving
4391  ends, for permanent changes use SCIPchgRowLhs()
4392  """
4393  PY_SCIP_CALL(SCIPchgRowLhsDive(self._scip, row.scip_row, newlhs))
4394 
4395  def chgRowRhsDive(self, Row row, newrhs):
4396  """changes row rhs in current dive, change will be undone after diving
4397  ends, for permanent changes use SCIPchgRowLhs()
4398  """
4399  PY_SCIP_CALL(SCIPchgRowRhsDive(self._scip, row.scip_row, newrhs))
4400 
4401  def addRowDive(self, Row row):
4402  """adds a row to the LP in current dive"""
4403  PY_SCIP_CALL(SCIPaddRowDive(self._scip, row.scip_row))
4404 
4405  def solveDiveLP(self, itlim = -1):
4406  """solves the LP of the current dive no separation or pricing is applied
4407  no separation or pricing is applied
4408  :param itlim: maximal number of LP iterations to perform (Default value = -1, that is, no limit)
4409  returns two booleans:
4410  lperror -- if an unresolved lp error occured
4411  cutoff -- whether the LP was infeasible or the objective limit was reached
4412  """
4413  cdef SCIP_Bool lperror
4414  cdef SCIP_Bool cutoff
4415 
4416  PY_SCIP_CALL(SCIPsolveDiveLP(self._scip, itlim, &lperror, &cutoff))
4417  return lperror, cutoff
4418 
4419  def inRepropagation(self):
4420  """returns if the current node is already solved and only propagated again."""
4421  return SCIPinRepropagation(self._scip)
4422 
4423  # Probing methods (Probing is tree based)
4424  def startProbing(self):
4425  """Initiates probing, making methods SCIPnewProbingNode(), SCIPbacktrackProbing(), SCIPchgVarLbProbing(),
4426  SCIPchgVarUbProbing(), SCIPfixVarProbing(), SCIPpropagateProbing(), SCIPsolveProbingLP(), etc available
4427  """
4428  PY_SCIP_CALL( SCIPstartProbing(self._scip) )
4429 
4430  def endProbing(self):
4431  """Quits probing and resets bounds and constraints to the focus node's environment"""
4432  PY_SCIP_CALL( SCIPendProbing(self._scip) )
4433 
4434  def newProbingNode(self):
4435  """creates a new probing sub node, whose changes can be undone by backtracking to a higher node in the
4436  probing path with a call to backtrackProbing()
4437  """
4438  PY_SCIP_CALL( SCIPnewProbingNode(self._scip) )
4439 
4440  def backtrackProbing(self, probingdepth):
4441  """undoes all changes to the problem applied in probing up to the given probing depth
4442  :param probingdepth: probing depth of the node in the probing path that should be reactivated
4443  """
4444  PY_SCIP_CALL( SCIPbacktrackProbing(self._scip, probingdepth) )
4445 
4446  def getProbingDepth(self):
4447  """returns the current probing depth"""
4448  return SCIPgetProbingDepth(self._scip)
4449 
4450  def chgVarObjProbing(self, Variable var, newobj):
4451  """changes (column) variable's objective value during probing mode"""
4452  PY_SCIP_CALL( SCIPchgVarObjProbing(self._scip, var.scip_var, newobj) )
4453 
4454  def chgVarLbProbing(self, Variable var, lb):
4455  """changes the variable lower bound during probing mode
4456 
4457  :param Variable var: variable to change bound of
4458  :param lb: new lower bound (set to None for -infinity)
4459  """
4460  if lb is None:
4461  lb = -SCIPinfinity(self._scip)
4462  PY_SCIP_CALL(SCIPchgVarLbProbing(self._scip, var.scip_var, lb))
4463 
4464  def chgVarUbProbing(self, Variable var, ub):
4465  """changes the variable upper bound during probing mode
4466 
4467  :param Variable var: variable to change bound of
4468  :param ub: new upper bound (set to None for +infinity)
4469  """
4470  if ub is None:
4471  ub = SCIPinfinity(self._scip)
4472  PY_SCIP_CALL(SCIPchgVarUbProbing(self._scip, var.scip_var, ub))
4473 
4474  def fixVarProbing(self, Variable var, fixedval):
4475  """Fixes a variable at the current probing node."""
4476  PY_SCIP_CALL( SCIPfixVarProbing(self._scip, var.scip_var, fixedval) )
4477 
4479  """returns whether the objective function has changed during probing mode"""
4480  return SCIPisObjChangedProbing(self._scip)
4481 
4482  def inProbing(self):
4483  """returns whether we are in probing mode; probing mode is activated via startProbing() and stopped via endProbing()"""
4484  return SCIPinProbing(self._scip)
4485 
4486  def solveProbingLP(self, itlim = -1):
4487  """solves the LP at the current probing node (cannot be applied at preprocessing stage)
4488  no separation or pricing is applied
4489  :param itlim: maximal number of LP iterations to perform (Default value = -1, that is, no limit)
4490  returns two booleans:
4491  lperror -- if an unresolved lp error occured
4492  cutoff -- whether the LP was infeasible or the objective limit was reached
4493  """
4494  cdef SCIP_Bool lperror
4495  cdef SCIP_Bool cutoff
4496 
4497  PY_SCIP_CALL( SCIPsolveProbingLP(self._scip, itlim, &lperror, &cutoff) )
4498  return lperror, cutoff
4499 
4500  def applyCutsProbing(self):
4501  """applies the cuts in the separation storage to the LP and clears the storage afterwards;
4502  this method can only be applied during probing; the user should resolve the probing LP afterwards
4503  in order to get a new solution
4504  returns:
4505  cutoff -- whether an empty domain was created
4506  """
4507  cdef SCIP_Bool cutoff
4508 
4509  PY_SCIP_CALL( SCIPapplyCutsProbing(self._scip, &cutoff) )
4510  return cutoff
4511 
4512  def propagateProbing(self, maxproprounds):
4513  """applies domain propagation on the probing sub problem, that was changed after SCIPstartProbing() was called;
4514  the propagated domains of the variables can be accessed with the usual bound accessing calls SCIPvarGetLbLocal()
4515  and SCIPvarGetUbLocal(); the propagation is only valid locally, i.e. the local bounds as well as the changed
4516  bounds due to SCIPchgVarLbProbing(), SCIPchgVarUbProbing(), and SCIPfixVarProbing() are used for propagation
4517  :param maxproprounds: maximal number of propagation rounds (Default value = -1, that is, no limit)
4518  returns:
4519  cutoff -- whether the probing node can be cutoff
4520  ndomredsfound -- number of domain reductions found
4521  """
4522  cdef SCIP_Bool cutoff
4523  cdef SCIP_Longint ndomredsfound
4524 
4525  PY_SCIP_CALL( SCIPpropagateProbing(self._scip, maxproprounds, &cutoff, &ndomredsfound) )
4526  return cutoff, ndomredsfound
4527 
4528  def interruptSolve(self):
4529  """Interrupt the solving process as soon as possible."""
4530  PY_SCIP_CALL(SCIPinterruptSolve(self._scip))
4531 
4532  def restartSolve(self):
4533  """Restarts the solving process as soon as possible."""
4534  PY_SCIP_CALL(SCIPrestartSolve(self._scip))
4535 
4536  # Solution functions
4537 
4538  def writeLP(self, filename="LP.lp"):
4539  """writes current LP to a file
4540  :param filename: file name (Default value = "LP.lp")
4541  """
4542  user_locale = locale.getlocale(category=locale.LC_NUMERIC)
4543  locale.setlocale(locale.LC_NUMERIC, "C")
4544 
4545  absfile = str_conversion(abspath(filename))
4546  PY_SCIP_CALL( SCIPwriteLP(self._scip, absfile) )
4547 
4548  locale.setlocale(locale.LC_NUMERIC,user_locale)
4549 
4550  def createSol(self, Heur heur = None):
4551  """Create a new primal solution in the transformed space.
4552 
4553  :param Heur heur: heuristic that found the solution (Default value = None)
4554 
4555  """
4556  cdef SCIP_HEUR* _heur
4557  cdef SCIP_SOL* _sol
4558 
4559  if isinstance(heur, Heur):
4560  n = str_conversion(heur.name)
4561  _heur = SCIPfindHeur(self._scip, n)
4562  else:
4563  _heur = NULL
4564  PY_SCIP_CALL(SCIPcreateSol(self._scip, &_sol, _heur))
4565  solution = Solution.create(self._scip, _sol)
4566  return solution
4567 
4568  def createPartialSol(self, Heur heur = None):
4569  """Create a partial primal solution, initialized to unknown values.
4570  :param Heur heur: heuristic that found the solution (Default value = None)
4571 
4572  """
4573  cdef SCIP_HEUR* _heur
4574  cdef SCIP_SOL* _sol
4575 
4576  if isinstance(heur, Heur):
4577  n = str_conversion(heur.name)
4578  _heur = SCIPfindHeur(self._scip, n)
4579  else:
4580  _heur = NULL
4581  PY_SCIP_CALL(SCIPcreatePartialSol(self._scip, &_sol, _heur))
4582  partialsolution = Solution.create(self._scip, _sol)
4583  return partialsolution
4584 
4585  def createOrigSol(self, Heur heur = None):
4586  """Create a new primal solution in the original space.
4587 
4588  :param Heur heur: heuristic that found the solution (Default value = None)
4589 
4590  """
4591  cdef SCIP_HEUR* _heur
4592  cdef SCIP_SOL* _sol
4593 
4594  if isinstance(heur, Heur):
4595  n = str_conversion(heur.name)
4596  _heur = SCIPfindHeur(self._scip, n)
4597  else:
4598  _heur = NULL
4599 
4600  PY_SCIP_CALL(SCIPcreateOrigSol(self._scip, &_sol, _heur))
4601  solution = Solution.create(self._scip, _sol)
4602  return solution
4603 
4604  def printBestSol(self, write_zeros=False):
4605  """Prints the best feasible primal solution."""
4606  user_locale = locale.getlocale(category=locale.LC_NUMERIC)
4607  locale.setlocale(locale.LC_NUMERIC, "C")
4608 
4609  PY_SCIP_CALL(SCIPprintBestSol(self._scip, NULL, write_zeros))
4610 
4611  locale.setlocale(locale.LC_NUMERIC,user_locale)
4612 
4613  def printSol(self, Solution solution=None, write_zeros=False):
4614  """Print the given primal solution.
4615 
4616  Keyword arguments:
4617  solution -- solution to print
4618  write_zeros -- include variables that are set to zero
4619  """
4620 
4621  user_locale = locale.getlocale(category=locale.LC_NUMERIC)
4622  locale.setlocale(locale.LC_NUMERIC, "C")
4623 
4624  if solution is None:
4625  PY_SCIP_CALL(SCIPprintSol(self._scip, NULL, NULL, write_zeros))
4626  else:
4627  PY_SCIP_CALL(SCIPprintSol(self._scip, solution.sol, NULL, write_zeros))
4628 
4629  locale.setlocale(locale.LC_NUMERIC,user_locale)
4630 
4631  def writeBestSol(self, filename="origprob.sol", write_zeros=False):
4632  """Write the best feasible primal solution to a file.
4633 
4634  Keyword arguments:
4635  filename -- name of the output file
4636  write_zeros -- include variables that are set to zero
4637  """
4638 
4639  user_locale = locale.getlocale(category=locale.LC_NUMERIC)
4640  locale.setlocale(locale.LC_NUMERIC, "C")
4641 
4642  # use this doubled opening pattern to ensure that IOErrors are
4643  # triggered early and in Python not in C,Cython or SCIP.
4644  with open(filename, "w") as f:
4645  cfile = fdopen(f.fileno(), "w")
4646  PY_SCIP_CALL(SCIPprintBestSol(self._scip, cfile, write_zeros))
4647 
4648  locale.setlocale(locale.LC_NUMERIC,user_locale)
4649 
4650  def writeBestTransSol(self, filename="transprob.sol", write_zeros=False):
4651  """Write the best feasible primal solution for the transformed problem to a file.
4652 
4653  Keyword arguments:
4654  filename -- name of the output file
4655  write_zeros -- include variables that are set to zero
4656  """
4657  user_locale = locale.getlocale(category=locale.LC_NUMERIC)
4658  locale.setlocale(locale.LC_NUMERIC, "C")
4659 
4660  # use this double opening pattern to ensure that IOErrors are
4661  # triggered early and in python not in C, Cython or SCIP.
4662  with open(filename, "w") as f:
4663  cfile = fdopen(f.fileno(), "w")
4664  PY_SCIP_CALL(SCIPprintBestTransSol(self._scip, cfile, write_zeros))
4665 
4666  locale.setlocale(locale.LC_NUMERIC,user_locale)
4667 
4668  def writeSol(self, Solution solution, filename="origprob.sol", write_zeros=False):
4669  """Write the given primal solution to a file.
4670 
4671  Keyword arguments:
4672  solution -- solution to write
4673  filename -- name of the output file
4674  write_zeros -- include variables that are set to zero
4675  """
4676  user_locale = locale.getlocale(category=locale.LC_NUMERIC)
4677  locale.setlocale(locale.LC_NUMERIC, "C")
4678 
4679  # use this doubled opening pattern to ensure that IOErrors are
4680  # triggered early and in Python not in C,Cython or SCIP.
4681  with open(filename, "w") as f:
4682  cfile = fdopen(f.fileno(), "w")
4683  PY_SCIP_CALL(SCIPprintSol(self._scip, solution.sol, cfile, write_zeros))
4684 
4685  locale.setlocale(locale.LC_NUMERIC,user_locale)
4686 
4687  def writeTransSol(self, Solution solution, filename="transprob.sol", write_zeros=False):
4688  """Write the given transformed primal solution to a file.
4689 
4690  Keyword arguments:
4691  solution -- transformed solution to write
4692  filename -- name of the output file
4693  write_zeros -- include variables that are set to zero
4694  """
4695  user_locale = locale.getlocale(category=locale.LC_NUMERIC)
4696  locale.setlocale(locale.LC_NUMERIC, "C")
4697 
4698  # use this doubled opening pattern to ensure that IOErrors are
4699  # triggered early and in Python not in C,Cython or SCIP.
4700  with open(filename, "w") as f:
4701  cfile = fdopen(f.fileno(), "w")
4702  PY_SCIP_CALL(SCIPprintTransSol(self._scip, solution.sol, cfile, write_zeros))
4703 
4704  locale.setlocale(locale.LC_NUMERIC,user_locale)
4705 
4706  # perhaps this should not be included as it implements duplicated functionality
4707  # (as does it's namesake in SCIP)
4708  def readSol(self, filename):
4709  """Reads a given solution file, problem has to be transformed in advance.
4710 
4711  Keyword arguments:
4712  filename -- name of the input file
4713  """
4714  user_locale = locale.getlocale(category=locale.LC_NUMERIC)
4715  locale.setlocale(locale.LC_NUMERIC, "C")
4716 
4717  absfile = str_conversion(abspath(filename))
4718  PY_SCIP_CALL(SCIPreadSol(self._scip, absfile))
4719 
4720  locale.setlocale(locale.LC_NUMERIC, user_locale)
4721 
4722  def readSolFile(self, filename):
4723  """Reads a given solution file.
4724 
4725  Solution is created but not added to storage/the model.
4726  Use 'addSol' OR 'trySol' to add it.
4727 
4728  Keyword arguments:
4729  filename -- name of the input file
4730  """
4731  cdef SCIP_Bool partial
4732  cdef SCIP_Bool error
4733  cdef SCIP_Bool stored
4734  cdef Solution solution
4735 
4736  str_absfile = abspath(filename)
4737  absfile = str_conversion(str_absfile)
4738  solution = self.createSol()
4739 
4740  user_locale = locale.getlocale(category=locale.LC_NUMERIC)
4741  locale.setlocale(locale.LC_NUMERIC, "C")
4742 
4743  PY_SCIP_CALL(SCIPreadSolFile(self._scip, absfile, solution.sol, False, &partial, &error))
4744 
4745  locale.setlocale(locale.LC_NUMERIC, user_locale)
4746 
4747  if error:
4748  raise Exception("SCIP: reading solution from file " + str_absfile + " failed!")
4749 
4750  return solution
4751 
4752  def setSolVal(self, Solution solution, Variable var, val):
4753  """Set a variable in a solution.
4754 
4755  :param Solution solution: solution to be modified
4756  :param Variable var: variable in the solution
4757  :param val: value of the specified variable
4758 
4759  """
4760  cdef SCIP_SOL* _sol
4761  _sol = <SCIP_SOL*>solution.sol
4762 
4763  assert _sol != NULL, "Cannot set value to a freed solution."
4764  PY_SCIP_CALL(SCIPsetSolVal(self._scip, _sol, var.scip_var, val))
4765 
4766  def trySol(self, Solution solution, printreason=True, completely=False, checkbounds=True, checkintegrality=True, checklprows=True, free=True):
4767  """Check given primal solution for feasibility and try to add it to the storage.
4768 
4769  :param Solution solution: solution to store
4770  :param printreason: should all reasons of violations be printed? (Default value = True)
4771  :param completely: should all violation be checked? (Default value = False)
4772  :param checkbounds: should the bounds of the variables be checked? (Default value = True)
4773  :param checkintegrality: has integrality to be checked? (Default value = True)
4774  :param checklprows: have current LP rows (both local and global) to be checked? (Default value = True)
4775  :param free: should solution be freed? (Default value = True)
4776 
4777  """
4778  cdef SCIP_Bool stored
4779  if free:
4780  PY_SCIP_CALL(SCIPtrySolFree(self._scip, &solution.sol, printreason, completely, checkbounds, checkintegrality, checklprows, &stored))
4781  else:
4782  PY_SCIP_CALL(SCIPtrySol(self._scip, solution.sol, printreason, completely, checkbounds, checkintegrality, checklprows, &stored))
4783  return stored
4784 
4785  def checkSol(self, Solution solution, printreason=True, completely=False, checkbounds=True, checkintegrality=True, checklprows=True, original=False):
4786  """Check given primal solution for feasibility without adding it to the storage.
4787 
4788  :param Solution solution: solution to store
4789  :param printreason: should all reasons of violations be printed? (Default value = True)
4790  :param completely: should all violation be checked? (Default value = False)
4791  :param checkbounds: should the bounds of the variables be checked? (Default value = True)
4792  :param checkintegrality: has integrality to be checked? (Default value = True)
4793  :param checklprows: have current LP rows (both local and global) to be checked? (Default value = True)
4794  :param original: must the solution be checked against the original problem (Default value = False)
4795 
4796  """
4797  cdef SCIP_Bool feasible
4798  if original:
4799  PY_SCIP_CALL(SCIPcheckSolOrig(self._scip, solution.sol, &feasible, printreason, completely))
4800  else:
4801  PY_SCIP_CALL(SCIPcheckSol(self._scip, solution.sol, printreason, completely, checkbounds, checkintegrality, checklprows, &feasible))
4802  return feasible
4803 
4804  def addSol(self, Solution solution, free=True):
4805  """Try to add a solution to the storage.
4806 
4807  :param Solution solution: solution to store
4808  :param free: should solution be freed afterwards? (Default value = True)
4809 
4810  """
4811  cdef SCIP_Bool stored
4812  if free:
4813  PY_SCIP_CALL(SCIPaddSolFree(self._scip, &solution.sol, &stored))
4814  else:
4815  PY_SCIP_CALL(SCIPaddSol(self._scip, solution.sol, &stored))
4816  return stored
4817 
4818  def freeSol(self, Solution solution):
4819  """Free given solution
4820 
4821  :param Solution solution: solution to be freed
4822 
4823  """
4824  PY_SCIP_CALL(SCIPfreeSol(self._scip, &solution.sol))
4825 
4826  def getNSols(self):
4827  """gets number of feasible primal solutions stored in the solution storage in case the problem is transformed;
4828  in case the problem stage is SCIP_STAGE_PROBLEM, the number of solution in the original solution candidate
4829  storage is returned
4830  """
4831  return SCIPgetNSols(self._scip)
4832 
4833  def getNSolsFound(self):
4834  """gets number of feasible primal solutions found so far"""
4835  return SCIPgetNSolsFound(self._scip)
4836 
4837  def getNLimSolsFound(self):
4838  """gets number of feasible primal solutions respecting the objective limit found so far"""
4839  return SCIPgetNLimSolsFound(self._scip)
4840 
4842  """gets number of feasible primal solutions found so far, that improved the primal bound at the time they were found"""
4843  return SCIPgetNBestSolsFound(self._scip)
4844 
4845  def getSols(self):
4846  """Retrieve list of all feasible primal solutions stored in the solution storage."""
4847  cdef SCIP_SOL** _sols
4848  cdef SCIP_SOL* _sol
4849  _sols = SCIPgetSols(self._scip)
4850  nsols = SCIPgetNSols(self._scip)
4851  sols = []
4852 
4853  for i in range(nsols):
4854  sols.append(Solution.create(self._scip, _sols[i]))
4855 
4856  return sols
4857 
4858  def getBestSol(self):
4859  """Retrieve currently best known feasible primal solution."""
4860  self._bestSol = Solution.create(self._scip, SCIPgetBestSol(self._scip))
4861  return self._bestSol
4862 
4863  def getSolObjVal(self, Solution sol, original=True):
4864  """Retrieve the objective value of the solution.
4865 
4866  :param Solution sol: solution
4867  :param original: objective value in original space (Default value = True)
4868 
4869  """
4870  if sol == None:
4871  sol = Solution.create(self._scip, NULL)
4872 
4873  sol._checkStage("getSolObjVal")
4874 
4875  if original:
4876  objval = SCIPgetSolOrigObj(self._scip, sol.sol)
4877  else:
4878  objval = SCIPgetSolTransObj(self._scip, sol.sol)
4879 
4880  return objval
4881 
4882  def getSolTime(self, Solution sol):
4883  """Get clock time, when this solution was found.
4884 
4885  :param Solution sol: solution
4886 
4887  """
4888  return SCIPgetSolTime(self._scip, sol.sol)
4889 
4890  def getObjVal(self, original=True):
4891  """Retrieve the objective value of value of best solution.
4892 
4893  :param original: objective value in original space (Default value = True)
4894  """
4895 
4896  if SCIPgetNSols(self._scip) == 0:
4897  if self.getStage() != SCIP_STAGE_SOLVING:
4898  raise Warning("Without a solution, method can only be called in stage SOLVING.")
4899  else:
4900  assert self._bestSol.sol != NULL
4901 
4902  if SCIPsolIsOriginal(self._bestSol.sol):
4903  min_stage_requirement = SCIP_STAGE_PROBLEM
4904  else:
4905  min_stage_requirement = SCIP_STAGE_TRANSFORMING
4906 
4907  if not self.getStage() >= min_stage_requirement:
4908  raise Warning("method cannot be called in stage %i." % self.getStage)
4909 
4910  return self.getSolObjVal(self._bestSol, original)
4911 
4912  def getSolVal(self, Solution sol, Expr expr):
4913  """Retrieve value of given variable or expression in the given solution or in
4914  the LP/pseudo solution if sol == None
4915 
4916  :param Solution sol: solution
4917  :param Expr expr: polynomial expression to query the value of
4918 
4919  Note: a variable is also an expression
4920  """
4921  # no need to create a NULL solution wrapper in case we have a variable
4922  if sol == None and isinstance(expr, Variable):
4923  var = <Variable> expr
4924  return SCIPgetSolVal(self._scip, NULL, var.scip_var)
4925  if sol == None:
4926  sol = Solution.create(self._scip, NULL)
4927  return sol[expr]
4928 
4929  def getVal(self, Expr expr):
4930  """Retrieve the value of the given variable or expression in the best known solution.
4931  Can only be called after solving is completed.
4932 
4933  :param Expr expr: polynomial expression to query the value of
4934 
4935  Note: a variable is also an expression
4936  """
4937  stage_check = SCIPgetStage(self._scip) not in [SCIP_STAGE_INIT, SCIP_STAGE_FREE]
4938 
4939  if not stage_check or self._bestSol.sol == NULL and SCIPgetStage(self._scip) != SCIP_STAGE_SOLVING:
4940  raise Warning("Method cannot be called in stage ", self.getStage())
4941 
4942  return self.getSolVal(self._bestSol, expr)
4943 
4944  def hasPrimalRay(self):
4945  """
4946  Returns whether a primal ray is stored that proves unboundedness of the LP relaxation
4947  """
4948  return SCIPhasPrimalRay(self._scip)
4949 
4950  def getPrimalRayVal(self, Variable var):
4951  """
4952  Gets value of given variable in primal ray causing unboundedness of the LP relaxation
4953  """
4954  assert SCIPhasPrimalRay(self._scip), "The problem does not have a primal ray."
4955 
4956  return SCIPgetPrimalRayVal(self._scip, var.scip_var)
4957 
4958  def getPrimalRay(self):
4959  """
4960  Gets primal ray causing unboundedness of the LP relaxation
4961  """
4962  assert SCIPhasPrimalRay(self._scip), "The problem does not have a primal ray."
4963 
4964  cdef int _nvars = SCIPgetNVars(self._scip)
4965  cdef SCIP_VAR ** _vars = SCIPgetVars(self._scip)
4966 
4967  ray = []
4968  for i in range(_nvars):
4969  ray.append(float(SCIPgetPrimalRayVal(self._scip, _vars[i])))
4970 
4971  return ray
4972 
4973  def getPrimalbound(self):
4974  """Retrieve the best primal bound."""
4975  return SCIPgetPrimalbound(self._scip)
4976 
4977  def getDualbound(self):
4978  """Retrieve the best dual bound."""
4979  return SCIPgetDualbound(self._scip)
4980 
4981  def getDualboundRoot(self):
4982  """Retrieve the best root dual bound."""
4983  return SCIPgetDualboundRoot(self._scip)
4984 
4985  def writeName(self, Variable var):
4986  """Write the name of the variable to the std out.
4987 
4988  :param Variable var: variable
4989 
4990  """
4991  user_locale = locale.getlocale(category=locale.LC_NUMERIC)
4992  locale.setlocale(locale.LC_NUMERIC, "C")
4993 
4994  PY_SCIP_CALL(SCIPwriteVarName(self._scip, NULL, var.scip_var, False))
4995 
4996  locale.setlocale(locale.LC_NUMERIC,user_locale)
4997 
4998  def getStage(self):
4999  """Retrieve current SCIP stage"""
5000  return SCIPgetStage(self._scip)
5001 
5002  def getStageName(self):
5003  """Returns name of current stage as string"""
5004  if not StageNames:
5005  self._getStageNames()
5006  return StageNames[self.getStage()]
5007 
5008  def _getStageNames(self):
5009  """Gets names of stages"""
5010  for name in dir(PY_SCIP_STAGE):
5011  attr = getattr(PY_SCIP_STAGE, name)
5012  if isinstance(attr, int):
5013  StageNames[attr] = name
5014 
5015  def getStatus(self):
5016  """Retrieve solution status."""
5017  cdef SCIP_STATUS stat = SCIPgetStatus(self._scip)
5018  if stat == SCIP_STATUS_OPTIMAL:
5019  return "optimal"
5020  elif stat == SCIP_STATUS_TIMELIMIT:
5021  return "timelimit"
5022  elif stat == SCIP_STATUS_INFEASIBLE:
5023  return "infeasible"
5024  elif stat == SCIP_STATUS_UNBOUNDED:
5025  return "unbounded"
5026  elif stat == SCIP_STATUS_USERINTERRUPT:
5027  return "userinterrupt"
5028  elif stat == SCIP_STATUS_INFORUNBD:
5029  return "inforunbd"
5030  elif stat == SCIP_STATUS_NODELIMIT:
5031  return "nodelimit"
5032  elif stat == SCIP_STATUS_TOTALNODELIMIT:
5033  return "totalnodelimit"
5034  elif stat == SCIP_STATUS_STALLNODELIMIT:
5035  return "stallnodelimit"
5036  elif stat == SCIP_STATUS_GAPLIMIT:
5037  return "gaplimit"
5038  elif stat == SCIP_STATUS_MEMLIMIT:
5039  return "memlimit"
5040  elif stat == SCIP_STATUS_SOLLIMIT:
5041  return "sollimit"
5042  elif stat == SCIP_STATUS_BESTSOLLIMIT:
5043  return "bestsollimit"
5044  elif stat == SCIP_STATUS_RESTARTLIMIT:
5045  return "restartlimit"
5046  elif stat == SCIP_STATUS_PRIMALLIMIT:
5047  return "primallimit"
5048  elif stat == SCIP_STATUS_DUALLIMIT:
5049  return "duallimit"
5050  else:
5051  return "unknown"
5052 
5054  """Retrieve objective sense."""
5055  cdef SCIP_OBJSENSE sense = SCIPgetObjsense(self._scip)
5056  if sense == SCIP_OBJSENSE_MAXIMIZE:
5057  return "maximize"
5058  elif sense == SCIP_OBJSENSE_MINIMIZE:
5059  return "minimize"
5060  else:
5061  return "unknown"
5062 
5063  def catchEvent(self, eventtype, Eventhdlr eventhdlr):
5064  """catches a global (not variable or row dependent) event"""
5065  cdef SCIP_EVENTHDLR* _eventhdlr
5066  if isinstance(eventhdlr, Eventhdlr):
5067  n = str_conversion(eventhdlr.name)
5068  _eventhdlr = SCIPfindEventhdlr(self._scip, n)
5069  else:
5070  raise Warning("event handler not found")
5071 
5072  Py_INCREF(self)
5073  PY_SCIP_CALL(SCIPcatchEvent(self._scip, eventtype, _eventhdlr, NULL, NULL))
5074 
5075  def dropEvent(self, eventtype, Eventhdlr eventhdlr):
5076  """drops a global event (stops to track event)"""
5077  cdef SCIP_EVENTHDLR* _eventhdlr
5078  if isinstance(eventhdlr, Eventhdlr):
5079  n = str_conversion(eventhdlr.name)
5080  _eventhdlr = SCIPfindEventhdlr(self._scip, n)
5081  else:
5082  raise Warning("event handler not found")
5083 
5084  Py_DECREF(self)
5085  PY_SCIP_CALL(SCIPdropEvent(self._scip, eventtype, _eventhdlr, NULL, -1))
5086 
5087  def catchVarEvent(self, Variable var, eventtype, Eventhdlr eventhdlr):
5088  """catches an objective value or domain change event on the given transformed variable"""
5089  cdef SCIP_EVENTHDLR* _eventhdlr
5090  if isinstance(eventhdlr, Eventhdlr):
5091  n = str_conversion(eventhdlr.name)
5092  _eventhdlr = SCIPfindEventhdlr(self._scip, n)
5093  else:
5094  raise Warning("event handler not found")
5095  PY_SCIP_CALL(SCIPcatchVarEvent(self._scip, var.scip_var, eventtype, _eventhdlr, NULL, NULL))
5096 
5097  def dropVarEvent(self, Variable var, eventtype, Eventhdlr eventhdlr):
5098  """drops an objective value or domain change event (stops to track event) on the given transformed variable"""
5099  cdef SCIP_EVENTHDLR* _eventhdlr
5100  if isinstance(eventhdlr, Eventhdlr):
5101  n = str_conversion(eventhdlr.name)
5102  _eventhdlr = SCIPfindEventhdlr(self._scip, n)
5103  else:
5104  raise Warning("event handler not found")
5105  PY_SCIP_CALL(SCIPdropVarEvent(self._scip, var.scip_var, eventtype, _eventhdlr, NULL, -1))
5106 
5107  def catchRowEvent(self, Row row, eventtype, Eventhdlr eventhdlr):
5108  """catches a row coefficient, constant, or side change event on the given row"""
5109  cdef SCIP_EVENTHDLR* _eventhdlr
5110  if isinstance(eventhdlr, Eventhdlr):
5111  n = str_conversion(eventhdlr.name)
5112  _eventhdlr = SCIPfindEventhdlr(self._scip, n)
5113  else:
5114  raise Warning("event handler not found")
5115  PY_SCIP_CALL(SCIPcatchRowEvent(self._scip, row.scip_row, eventtype, _eventhdlr, NULL, NULL))
5116 
5117  def dropRowEvent(self, Row row, eventtype, Eventhdlr eventhdlr):
5118  """drops a row coefficient, constant, or side change event (stops to track event) on the given row"""
5119  cdef SCIP_EVENTHDLR* _eventhdlr
5120  if isinstance(eventhdlr, Eventhdlr):
5121  n = str_conversion(eventhdlr.name)
5122  _eventhdlr = SCIPfindEventhdlr(self._scip, n)
5123  else:
5124  raise Warning("event handler not found")
5125  PY_SCIP_CALL(SCIPdropRowEvent(self._scip, row.scip_row, eventtype, _eventhdlr, NULL, -1))
5126 
5127  # Statistic Methods
5128 
5129  def printStatistics(self):
5130  """Print statistics."""
5131  user_locale = locale.getlocale(category=locale.LC_NUMERIC)
5132  locale.setlocale(locale.LC_NUMERIC, "C")
5133 
5134  PY_SCIP_CALL(SCIPprintStatistics(self._scip, NULL))
5135 
5136  locale.setlocale(locale.LC_NUMERIC,user_locale)
5137 
5138  def writeStatistics(self, filename="origprob.stats"):
5139  """Write statistics to a file.
5140 
5141  Keyword arguments:
5142  filename -- name of the output file
5143  """
5144  user_locale = locale.getlocale(category=locale.LC_NUMERIC)
5145  locale.setlocale(locale.LC_NUMERIC, "C")
5146 
5147  # use this doubled opening pattern to ensure that IOErrors are
5148  # triggered early and in Python not in C,Cython or SCIP.
5149  with open(filename, "w") as f:
5150  cfile = fdopen(f.fileno(), "w")
5151  PY_SCIP_CALL(SCIPprintStatistics(self._scip, cfile))
5152 
5153  locale.setlocale(locale.LC_NUMERIC,user_locale)
5154 
5155  def readStatistics(self, filename):
5156  """
5157  Given a .stats file of a solved model, reads it and returns an instance of the Statistics class
5158  holding some statistics.
5159 
5160  Keyword arguments:
5161  filename -- name of the input file
5162  """
5163  result = {}
5164  file = open(filename)
5165  data = file.readlines()
5166 
5167  assert "problem is solved" in data[0], "readStatistics can only be called if the problem was solved"
5168  available_stats = ["Total Time", "solving", "presolving", "reading", "copying",
5169  "Problem name", "Variables", "Constraints", "number of runs",
5170  "nodes", "Solutions found", "First Solution", "Primal Bound",
5171  "Dual Bound", "Gap", "primal-dual"]
5172 
5173  seen_cons = 0
5174  for i, line in enumerate(data):
5175  split_line = line.split(":")
5176  split_line[1] = split_line[1][:-1] # removing \n
5177  stat_name = split_line[0].strip()
5178 
5179  if seen_cons == 2 and stat_name == "Constraints":
5180  continue
5181 
5182  if stat_name in available_stats:
5183  cur_stat = split_line[0].strip()
5184  relevant_value = split_line[1].strip()
5185 
5186  if stat_name == "Variables":
5187  relevant_value = relevant_value[:-1] # removing ")"
5188  var_stats = {}
5189  split_var = relevant_value.split("(")
5190  var_stats["total"] = int(split_var[0])
5191  split_var = split_var[1].split(",")
5192 
5193  for var_type in split_var:
5194  split_result = var_type.strip().split(" ")
5195  var_stats[split_result[1]] = int(split_result[0])
5196 
5197  if "Original" in data[i-2]:
5198  result["Variables"] = var_stats
5199  else:
5200  result["Presolved Variables"] = var_stats
5201 
5202  continue
5203 
5204  if stat_name == "Constraints":
5205  seen_cons += 1
5206  con_stats = {}
5207  split_con = relevant_value.split(",")
5208  for con_type in split_con:
5209  split_result = con_type.strip().split(" ")
5210  con_stats[split_result[1]] = int(split_result[0])
5211 
5212  if "Original" in data[i-3]:
5213  result["Constraints"] = con_stats
5214  else:
5215  result["Presolved Constraints"] = con_stats
5216  continue
5217 
5218  relevant_value = relevant_value.split(" ")[0]
5219  if stat_name == "Problem name":
5220  if "Original" in data[i-1]:
5221  result["Problem name"] = relevant_value
5222  else:
5223  result["Presolved Problem name"] = relevant_value
5224  continue
5225 
5226  if stat_name == "Gap":
5227  result["Gap (%)"] = float(relevant_value[:-1])
5228  continue
5229 
5230  if _is_number(relevant_value):
5231  result[cur_stat] = float(relevant_value)
5232  else: # it's a string
5233  result[cur_stat] = relevant_value
5234 
5235  # changing keys to pythonic variable names
5236  treated_keys = {"Total Time": "total_time", "solving":"solving_time", "presolving":"presolving_time", "reading":"reading_time", "copying":"copying_time",
5237  "Problem name": "problem_name", "Presolved Problem name": "presolved_problem_name", "Variables":"_variables",
5238  "Presolved Variables":"_presolved_variables", "Constraints": "_constraints", "Presolved Constraints":"_presolved_constraints",
5239  "number of runs": "n_runs", "nodes":"n_nodes", "Solutions found": "n_solutions_found", "First Solution": "first_solution",
5240  "Primal Bound":"primal_bound", "Dual Bound":"dual_bound", "Gap (%)":"gap", "primal-dual":"primal_dual_integral"}
5241  treated_result = dict((treated_keys[key], value) for (key, value) in result.items())
5242 
5243  stats = Statistics(**treated_result)
5244  return stats
5245 
5246  def getNLPs(self):
5247  """gets total number of LPs solved so far"""
5248  return SCIPgetNLPs(self._scip)
5249 
5250  # Verbosity Methods
5251 
5252  def hideOutput(self, quiet = True):
5253  """Hide the output.
5254 
5255  :param quiet: hide output? (Default value = True)
5256 
5257  """
5258  SCIPsetMessagehdlrQuiet(self._scip, quiet)
5259 
5260  # Output Methods
5261 
5262  def redirectOutput(self):
5263  """Send output to python instead of terminal."""
5264 
5265  cdef SCIP_MESSAGEHDLR *myMessageHandler
5266 
5267  PY_SCIP_CALL(SCIPmessagehdlrCreate(&myMessageHandler, False, NULL, False, relayMessage, relayMessage, relayMessage, NULL, NULL))
5268  PY_SCIP_CALL(SCIPsetMessagehdlr(self._scip, myMessageHandler))
5269  SCIPmessageSetErrorPrinting(relayErrorMessage, NULL)
5270 
5271  def setLogfile(self, path):
5272  """sets the log file name for the currently installed message handler
5273  :param path: name of log file, or None (no log)
5274  """
5275  if path:
5276  c_path = str_conversion(path)
5277  SCIPsetMessagehdlrLogfile(self._scip, c_path)
5278  else:
5279  SCIPsetMessagehdlrLogfile(self._scip, NULL)
5280 
5281  # Parameter Methods
5282 
5283  def setBoolParam(self, name, value):
5284  """Set a boolean-valued parameter.
5285 
5286  :param name: name of parameter
5287  :param value: value of parameter
5288 
5289  """
5290  n = str_conversion(name)
5291  PY_SCIP_CALL(SCIPsetBoolParam(self._scip, n, value))
5292 
5293  def setIntParam(self, name, value):
5294  """Set an int-valued parameter.
5295 
5296  :param name: name of parameter
5297  :param value: value of parameter
5298 
5299  """
5300  n = str_conversion(name)
5301  PY_SCIP_CALL(SCIPsetIntParam(self._scip, n, value))
5302 
5303  def setLongintParam(self, name, value):
5304  """Set a long-valued parameter.
5305 
5306  :param name: name of parameter
5307  :param value: value of parameter
5308 
5309  """
5310  n = str_conversion(name)
5311  PY_SCIP_CALL(SCIPsetLongintParam(self._scip, n, value))
5312 
5313  def setRealParam(self, name, value):
5314  """Set a real-valued parameter.
5315 
5316  :param name: name of parameter
5317  :param value: value of parameter
5318 
5319  """
5320  n = str_conversion(name)
5321  PY_SCIP_CALL(SCIPsetRealParam(self._scip, n, value))
5322 
5323  def setCharParam(self, name, value):
5324  """Set a char-valued parameter.
5325 
5326  :param name: name of parameter
5327  :param value: value of parameter
5328 
5329  """
5330  n = str_conversion(name)
5331  PY_SCIP_CALL(SCIPsetCharParam(self._scip, n, ord(value)))
5332 
5333  def setStringParam(self, name, value):
5334  """Set a string-valued parameter.
5335 
5336  :param name: name of parameter
5337  :param value: value of parameter
5338 
5339  """
5340  n = str_conversion(name)
5341  v = str_conversion(value)
5342  PY_SCIP_CALL(SCIPsetStringParam(self._scip, n, v))
5343 
5344  def setParam(self, name, value):
5345  """Set a parameter with value in int, bool, real, long, char or str.
5346 
5347  :param name: name of parameter
5348  :param value: value of parameter
5349  """
5350  cdef SCIP_PARAM* param
5351 
5352  n = str_conversion(name)
5353  param = SCIPgetParam(self._scip, n)
5354 
5355  if param == NULL:
5356  raise KeyError("Not a valid parameter name")
5357 
5358  paramtype = SCIPparamGetType(param)
5359 
5360  if paramtype == SCIP_PARAMTYPE_BOOL:
5361  PY_SCIP_CALL(SCIPsetBoolParam(self._scip, n, bool(int(value))))
5362  elif paramtype == SCIP_PARAMTYPE_INT:
5363  PY_SCIP_CALL(SCIPsetIntParam(self._scip, n, int(value)))
5364  elif paramtype == SCIP_PARAMTYPE_LONGINT:
5365  PY_SCIP_CALL(SCIPsetLongintParam(self._scip, n, int(value)))
5366  elif paramtype == SCIP_PARAMTYPE_REAL:
5367  PY_SCIP_CALL(SCIPsetRealParam(self._scip, n, float(value)))
5368  elif paramtype == SCIP_PARAMTYPE_CHAR:
5369  PY_SCIP_CALL(SCIPsetCharParam(self._scip, n, ord(value)))
5370  elif paramtype == SCIP_PARAMTYPE_STRING:
5371  v = str_conversion(value)
5372  PY_SCIP_CALL(SCIPsetStringParam(self._scip, n, v))
5373 
5374 
5375  def getParam(self, name):
5376  """Get the value of a parameter of type
5377  int, bool, real, long, char or str.
5378 
5379  :param name: name of parameter
5380  """
5381  cdef SCIP_PARAM* param
5382 
5383  n = str_conversion(name)
5384  param = SCIPgetParam(self._scip, n)
5385 
5386  if param == NULL:
5387  raise KeyError("Not a valid parameter name")
5388 
5389  paramtype = SCIPparamGetType(param)
5390 
5391  if paramtype == SCIP_PARAMTYPE_BOOL:
5392  return SCIPparamGetBool(param)
5393  elif paramtype == SCIP_PARAMTYPE_INT:
5394  return SCIPparamGetInt(param)
5395  elif paramtype == SCIP_PARAMTYPE_LONGINT:
5396  return SCIPparamGetLongint(param)
5397  elif paramtype == SCIP_PARAMTYPE_REAL:
5398  return SCIPparamGetReal(param)
5399  elif paramtype == SCIP_PARAMTYPE_CHAR:
5400  return chr(SCIPparamGetChar(param))
5401  elif paramtype == SCIP_PARAMTYPE_STRING:
5402  return SCIPparamGetString(param).decode('utf-8')
5403 
5404  def getParams(self):
5405  """Gets the values of all parameters as a dict mapping parameter names
5406  to their values."""
5407  cdef SCIP_PARAM** params
5408 
5409  params = SCIPgetParams(self._scip)
5410  result = {}
5411  for i in range(SCIPgetNParams(self._scip)):
5412  name = SCIPparamGetName(params[i]).decode('utf-8')
5413  result[name] = self.getParam(name)
5414  return result
5415 
5416  def setParams(self, params):
5417  """Sets multiple parameters at once.
5418 
5419  :param params: dict mapping parameter names to their values.
5420  """
5421  for name, value in params.items():
5422  self.setParam(name, value)
5423 
5424  def readParams(self, file):
5425  """Read an external parameter file.
5426 
5427  :param file: file to be read
5428 
5429  """
5430  absfile = str_conversion(abspath(file))
5431 
5432  user_locale = locale.getlocale(category=locale.LC_NUMERIC)
5433  locale.setlocale(locale.LC_NUMERIC, "C")
5434 
5435  PY_SCIP_CALL(SCIPreadParams(self._scip, absfile))
5436 
5437  locale.setlocale(locale.LC_NUMERIC, user_locale)
5438 
5439  def writeParams(self, filename='param.set', comments=True, onlychanged=True, verbose=True):
5440  """Write parameter settings to an external file.
5441 
5442  :param filename: file to be written (Default value = 'param.set')
5443  :param comments: write parameter descriptions as comments? (Default value = True)
5444  :param onlychanged: write only modified parameters (Default value = True)
5445  :param verbose: indicates whether a success message should be printed
5446  """
5447  user_locale = locale.getlocale(category=locale.LC_NUMERIC)
5448  locale.setlocale(locale.LC_NUMERIC, "C")
5449 
5450  str_absfile = abspath(filename)
5451  absfile = str_conversion(str_absfile)
5452  PY_SCIP_CALL(SCIPwriteParams(self._scip, absfile, comments, onlychanged))
5453 
5454  if verbose:
5455  print('wrote parameter settings to file ' + str_absfile)
5456 
5457  locale.setlocale(locale.LC_NUMERIC,user_locale)
5458 
5459  def resetParam(self, name):
5460  """Reset parameter setting to its default value
5461 
5462  :param name: parameter to reset
5463 
5464  """
5465  n = str_conversion(name)
5466  PY_SCIP_CALL(SCIPresetParam(self._scip, n))
5467 
5468  def resetParams(self):
5469  """Reset parameter settings to their default values"""
5470  PY_SCIP_CALL(SCIPresetParams(self._scip))
5471 
5472  def setEmphasis(self, paraemphasis, quiet = True):
5473  """Set emphasis settings
5474 
5475  :param paraemphasis: emphasis to set
5476  :param quiet: hide output? (Default value = True)
5477 
5478  """
5479  PY_SCIP_CALL(SCIPsetEmphasis(self._scip, paraemphasis, quiet))
5480 
5481  def readProblem(self, filename, extension = None):
5482  """Read a problem instance from an external file.
5483 
5484  :param filename: problem file name
5485  :param extension: specify file extension/type (Default value = None)
5486 
5487  """
5488  user_locale = locale.getlocale(category=locale.LC_NUMERIC)
5489  locale.setlocale(locale.LC_NUMERIC, "C")
5490 
5491  absfile = str_conversion(abspath(filename))
5492  if extension is None:
5493  PY_SCIP_CALL(SCIPreadProb(self._scip, absfile, NULL))
5494  else:
5495  extension = str_conversion(extension)
5496  PY_SCIP_CALL(SCIPreadProb(self._scip, absfile, extension))
5497 
5498  locale.setlocale(locale.LC_NUMERIC, user_locale)
5499 
5500  # Counting functions
5501 
5502  def count(self):
5503  """Counts the number of feasible points of problem."""
5504  PY_SCIP_CALL(SCIPcount(self._scip))
5505 
5506  def getNReaders(self):
5507  """Get number of currently available readers."""
5508  return SCIPgetNReaders(self._scip)
5509 
5510  def getNCountedSols(self):
5511  """Get number of feasible solution."""
5512  cdef SCIP_Bool valid
5513  cdef SCIP_Longint nsols
5514 
5515  nsols = SCIPgetNCountedSols(self._scip, &valid)
5516  if not valid:
5517  print('total number of solutions found is not valid!')
5518  return nsols
5519 
5521  """Sets SCIP parameters such that a valid counting process is possible."""
5522  PY_SCIP_CALL(SCIPsetParamsCountsols(self._scip))
5523 
5524  def freeReoptSolve(self):
5525  """Frees all solution process data and prepares for reoptimization"""
5526  PY_SCIP_CALL(SCIPfreeReoptSolve(self._scip))
5527 
5528  def chgReoptObjective(self, coeffs, sense = 'minimize'):
5529  """Establish the objective function as a linear expression.
5530 
5531  :param coeffs: the coefficients
5532  :param sense: the objective sense (Default value = 'minimize')
5533 
5534  """
5535 
5536  cdef SCIP_OBJSENSE objsense
5537 
5538  if sense == "minimize":
5539  objsense = SCIP_OBJSENSE_MINIMIZE
5540  elif sense == "maximize":
5541  objsense = SCIP_OBJSENSE_MAXIMIZE
5542  else:
5543  raise Warning("unrecognized optimization sense: %s" % sense)
5544 
5545  assert isinstance(coeffs, Expr), "given coefficients are not Expr but %s" % coeffs.__class__.__name__
5546 
5547  if coeffs.degree() > 1:
5548  raise ValueError("Nonlinear objective functions are not supported!")
5549  if coeffs[CONST] != 0.0:
5550  raise ValueError("Constant offsets in objective are not supported!")
5551 
5552  cdef SCIP_VAR** _vars
5553  cdef int _nvars
5554  _vars = SCIPgetOrigVars(self._scip)
5555  _nvars = SCIPgetNOrigVars(self._scip)
5556  _coeffs = <SCIP_Real*> malloc(_nvars * sizeof(SCIP_Real))
5557 
5558  for i in range(_nvars):
5559  _coeffs[i] = 0.0
5560 
5561  for term, coef in coeffs.terms.items():
5562  # avoid CONST term of Expr
5563  if term != CONST:
5564  assert len(term) == 1
5565  var = <Variable>term[0]
5566  for i in range(_nvars):
5567  if _vars[i] == var.scip_var:
5568  _coeffs[i] = coef
5569 
5570  PY_SCIP_CALL(SCIPchgReoptObjective(self._scip, objsense, _vars, &_coeffs[0], _nvars))
5571 
5572  free(_coeffs)
5573 
5574  def chgVarBranchPriority(self, Variable var, priority):
5575  """Sets the branch priority of the variable.
5576  Variables with higher branch priority are always preferred to variables with lower priority in selection of branching variable.
5577 
5578  :param Variable var: variable to change priority of
5579  :param priority: the new priority of the variable (the default branching priority is 0)
5580  """
5581  assert isinstance(var, Variable), "The given variable is not a pyvar, but %s" % var.__class__.__name__
5582  PY_SCIP_CALL(SCIPchgVarBranchPriority(self._scip, var.scip_var, priority))
5583 
5585  """Start strong branching. Needs to be called before any strong branching. Must also later end strong branching.
5586  TODO: Propagation option has currently been disabled via Python.
5587  If propagation is enabled then strong branching is not done on the LP, but on additionally created nodes (has some overhead)"""
5588 
5589  PY_SCIP_CALL(SCIPstartStrongbranch(self._scip, False))
5590 
5591  def endStrongbranch(self):
5592  """End strong branching. Needs to be called if startStrongBranching was called previously.
5593  Between these calls the user can access all strong branching functionality. """
5594 
5595  PY_SCIP_CALL(SCIPendStrongbranch(self._scip))
5596 
5597  def getVarStrongbranchLast(self, Variable var):
5598  """Get the results of the last strong branching call on this variable (potentially was called
5599  at another node).
5600 
5601  down - The dual bound of the LP after branching down on the variable
5602  up - The dual bound of the LP after branchign up on the variable
5603  downvalid - Whether down stores a valid dual bound or is NULL
5604  upvalid - Whether up stores a valid dual bound or is NULL
5605  solval - The solution value of the variable at the last strong branching call
5606  lpobjval - The LP objective value at the time of the last strong branching call
5607 
5608  :param Variable var: variable to get the previous strong branching information from
5609  """
5610 
5611  cdef SCIP_Real down
5612  cdef SCIP_Real up
5613  cdef SCIP_Real solval
5614  cdef SCIP_Real lpobjval
5615  cdef SCIP_Bool downvalid
5616  cdef SCIP_Bool upvalid
5617 
5618  PY_SCIP_CALL(SCIPgetVarStrongbranchLast(self._scip, var.scip_var, &down, &up, &downvalid, &upvalid, &solval, &lpobjval))
5619 
5620  return down, up, downvalid, upvalid, solval, lpobjval
5621 
5622  def getVarStrongbranchNode(self, Variable var):
5623  """Get the node number from the last time strong branching was called on the variable
5624 
5625  :param Variable var: variable to get the previous strong branching node from
5626  """
5627 
5628  cdef SCIP_Longint node_num
5629  node_num = SCIPgetVarStrongbranchNode(self._scip, var.scip_var)
5630 
5631  return node_num
5632 
5633  def getVarStrongbranch(self, Variable var, itlim, idempotent=False, integral=False):
5634  """ Strong branches and gets information on column variable.
5635 
5636  :param Variable var: Variable to get strong branching information on
5637  :param itlim: LP iteration limit for total strong branching calls
5638  :param idempotent: Should SCIP's state remain the same after the call?
5639  :param integral: Boolean on whether the variable is currently integer.
5640  """
5641 
5642  cdef SCIP_Real down
5643  cdef SCIP_Real up
5644  cdef SCIP_Bool downvalid
5645  cdef SCIP_Bool upvalid
5646  cdef SCIP_Bool downinf
5647  cdef SCIP_Bool upinf
5648  cdef SCIP_Bool downconflict
5649  cdef SCIP_Bool upconflict
5650  cdef SCIP_Bool lperror
5651 
5652  if integral:
5653  PY_SCIP_CALL(SCIPgetVarStrongbranchInt(self._scip, var.scip_var, itlim, idempotent, &down, &up, &downvalid,
5654  &upvalid, &downinf, &upinf, &downconflict, &upconflict, &lperror))
5655  else:
5656  PY_SCIP_CALL(SCIPgetVarStrongbranchFrac(self._scip, var.scip_var, itlim, idempotent, &down, &up, &downvalid,
5657  &upvalid, &downinf, &upinf, &downconflict, &upconflict, &lperror))
5658 
5659  return down, up, downvalid, upvalid, downinf, upinf, downconflict, upconflict, lperror
5660 
5661  def updateVarPseudocost(self, Variable var, valdelta, objdelta, weight):
5662  """Updates the pseudo costs of the given variable and the global pseudo costs after a change of valdelta
5663  in the variable's solution value and resulting change of objdelta in the LP's objective value.
5664  Update is ignored if objdelts is infinite. Weight is in range (0, 1], and affects how it updates
5665  the global weighted sum.
5666 
5667  :param Variable var: Variable whos pseudo cost will be updated
5668  :param valdelta: The change in variable value (e.g. the fractional amount removed or added by branching)
5669  :param objdelta: The change in objective value of the LP after valdelta change of the variable
5670  :param weight: the weight in range (0,1] of how the update affects the stored weighted sum.
5671  """
5672 
5673  PY_SCIP_CALL(SCIPupdateVarPseudocost(self._scip, var.scip_var, valdelta, objdelta, weight))
5674 
5675  def getBranchScoreMultiple(self, Variable var, gains):
5676  """Calculates the branching score out of the gain predictions for a branching with
5677  arbitrary many children.
5678 
5679  :param Variable var: variable to calculate the score for
5680  :param gains: list of gains for each child.
5681  """
5682 
5683  assert isinstance(gains, list)
5684  nchildren = len(gains)
5685 
5686  cdef int _nchildren = nchildren
5687  _gains = <SCIP_Real*> malloc(_nchildren * sizeof(SCIP_Real))
5688  for i in range(_nchildren):
5689  _gains[i] = gains[i]
5690 
5691  score = SCIPgetBranchScoreMultiple(self._scip, var.scip_var, _nchildren, _gains)
5692 
5693  free(_gains)
5694 
5695  return score
5696 
5698  """Get an estimation of the final tree size """
5699  return SCIPgetTreesizeEstimation(self._scip)
5700 
5701 
5702  def getBipartiteGraphRepresentation(self, prev_col_features=None, prev_edge_features=None, prev_row_features=None,
5703  static_only=False, suppress_warnings=False):
5704  """This function generates the bipartite graph representation of an LP, which was first used in
5705  the following paper:
5706  @inproceedings{conf/nips/GasseCFCL19,
5707  title={Exact Combinatorial Optimization with Graph Convolutional Neural Networks},
5708  author={Gasse, Maxime and Chételat, Didier and Ferroni, Nicola and Charlin, Laurent and Lodi, Andrea},
5709  booktitle={Advances in Neural Information Processing Systems 32},
5710  year={2019}
5711  }
5712  The exact features have been modified compared to the original implementation.
5713  This function is used mainly in the machine learning community for MIP.
5714  A user can only call it during the solving process, when there is an LP object. This means calling it
5715  from some user defined plugin on the Python side.
5716  An example plugin is a branching rule or an event handler, which is exclusively created to call this function.
5717  The user must then make certain to return the appropriate SCIP_RESULT (e.g. DIDNOTRUN)
5718 
5719  :param prev_col_features: The list of column features previously returned by this function
5720  :param prev_edge_features: The list of edge features previously returned by this function
5721  :param prev_row_features: The list of row features previously returned by this function
5722  :param static_only: Whether exclusively static features should be generated
5723  :param suppress_warnings: Whether warnings should be suppressed
5724  """
5725 
5726  cdef SCIP* scip = self._scip
5727  cdef int i, j, k, col_i
5728  cdef SCIP_VARTYPE vtype
5729  cdef SCIP_Real sim, prod
5730 
5731  # Check if SCIP is in the correct stage
5732  if SCIPgetStage(scip) != SCIP_STAGE_SOLVING:
5733  raise Warning("This functionality can only been called in SCIP_STAGE SOLVING. The row and column"
5734  "information is then accessible")
5735 
5736  # Generate column features
5737  cdef SCIP_COL** cols = SCIPgetLPCols(scip)
5738  cdef int ncols = SCIPgetNLPCols(scip)
5739 
5740  if static_only:
5741  n_col_features = 5
5742  col_feature_map = {"continuous": 0, "binary": 1, "integer": 2, "implicit_integer": 3, "obj_coef": 4}
5743  else:
5744  n_col_features = 19
5745  col_feature_map = {"continuous": 0, "binary": 1, "integer": 2, "implicit_integer": 3, "obj_coef": 4,
5746  "has_lb": 5, "has_ub": 6, "sol_at_lb": 7, "sol_at_ub": 8, "sol_val": 9, "sol_frac": 10,
5747  "red_cost": 11, "basis_lower": 12, "basis_basic": 13, "basis_upper": 14,
5748  "basis_zero": 15, "best_incumbent_val": 16, "avg_incumbent_val": 17, "age": 18}
5749 
5750  if prev_col_features is None:
5751  col_features = [[0 for _ in range(n_col_features)] for _ in range(ncols)]
5752  else:
5753  assert len(prev_col_features) > 0, "Previous column features is empty"
5754  col_features = prev_col_features
5755  if len(prev_col_features) != ncols:
5756  if not suppress_warnings:
5757  raise Warning(f"The number of columns has changed. Previous column data being ignored")
5758  else:
5759  col_features = [[0 for _ in range(n_col_features)] for _ in range(ncols)]
5760  prev_col_features = None
5761  if len(prev_col_features[0]) != n_col_features:
5762  raise Warning(f"Dimension mismatch in provided previous features and new features:"
5763  f"{len(prev_col_features[0])} != {n_col_features}")
5764 
5765  cdef SCIP_SOL* sol = SCIPgetBestSol(scip)
5766  cdef SCIP_VAR* var
5767  cdef SCIP_Real lb, ub, solval
5768  cdef SCIP_BASESTAT basis_status
5769  for i in range(ncols):
5770  col_i = SCIPcolGetLPPos(cols[i])
5771  var = SCIPcolGetVar(cols[i])
5772 
5773  lb = SCIPcolGetLb(cols[i])
5774  ub = SCIPcolGetUb(cols[i])
5775  solval = SCIPcolGetPrimsol(cols[i])
5776 
5777  # Collect the static features first (don't need to changed if previous features are passed)
5778  if prev_col_features is None:
5779  # Variable types
5780  vtype = SCIPvarGetType(var)
5781  if vtype == SCIP_VARTYPE_BINARY:
5782  col_features[col_i][col_feature_map["binary"]] = 1
5783  elif vtype == SCIP_VARTYPE_INTEGER:
5784  col_features[col_i][col_feature_map["integer"]] = 1
5785  elif vtype == SCIP_VARTYPE_CONTINUOUS:
5786  col_features[col_i][col_feature_map["continuous"]] = 1
5787  elif vtype == SCIP_VARTYPE_IMPLINT:
5788  col_features[col_i][col_feature_map["implicit_integer"]] = 1
5789  # Objective coefficient
5790  col_features[col_i][col_feature_map["obj_coef"]] = SCIPcolGetObj(cols[i])
5791 
5792  # Collect the dynamic features
5793  if not static_only:
5794  # Lower bound
5795  if not SCIPisInfinity(scip, abs(lb)):
5796  col_features[col_i][col_feature_map["has_lb"]] = 1
5797 
5798  # Upper bound
5799  if not SCIPisInfinity(scip, abs(ub)):
5800  col_features[col_i][col_feature_map["has_ub"]] = 1
5801 
5802  # Basis status
5803  basis_status = SCIPcolGetBasisStatus(cols[i])
5804  if basis_status == SCIP_BASESTAT_LOWER:
5805  col_features[col_i][col_feature_map["basis_lower"]] = 1
5806  elif basis_status == SCIP_BASESTAT_BASIC:
5807  col_features[col_i][col_feature_map["basis_basic"]] = 1
5808  elif basis_status == SCIP_BASESTAT_UPPER:
5809  col_features[col_i][col_feature_map["basis_upper"]] = 1
5810  elif basis_status == SCIP_BASESTAT_ZERO:
5811  col_features[col_i][col_feature_map["basis_zero"]] = 1
5812 
5813  # Reduced cost
5814  col_features[col_i][col_feature_map["red_cost"]] = SCIPgetColRedcost(scip, cols[i])
5815 
5816  # Age
5817  col_features[col_i][col_feature_map["age"]] = SCIPcolGetAge(cols[i])
5818 
5819  # LP solution value
5820  col_features[col_i][col_feature_map["sol_val"]] = solval
5821  col_features[col_i][col_feature_map["sol_frac"]] = SCIPfeasFrac(scip, solval)
5822  col_features[col_i][col_feature_map["sol_at_lb"]] = int(SCIPisEQ(scip, solval, lb))
5823  col_features[col_i][col_feature_map["sol_at_ub"]] = int(SCIPisEQ(scip, solval, ub))
5824 
5825  # Incumbent solution value
5826  if sol is NULL:
5827  col_features[col_i][col_feature_map["best_incumbent_val"]] = None
5828  col_features[col_i][col_feature_map["avg_incumbent_val"]] = None
5829  else:
5830  col_features[col_i][col_feature_map["best_incumbent_val"]] = SCIPgetSolVal(scip, sol, var)
5831  col_features[col_i][col_feature_map["avg_incumbent_val"]] = SCIPvarGetAvgSol(var)
5832 
5833  # Generate row features
5834  cdef int nrows = SCIPgetNLPRows(scip)
5835  cdef SCIP_ROW** rows = SCIPgetLPRows(scip)
5836 
5837  if static_only:
5838  n_row_features = 6
5839  row_feature_map = {"has_lhs": 0, "has_rhs": 1, "n_non_zeros": 2, "obj_cosine": 3, "bias": 4, "norm": 5}
5840  else:
5841  n_row_features = 14
5842  row_feature_map = {"has_lhs": 0, "has_rhs": 1, "n_non_zeros": 2, "obj_cosine": 3, "bias": 4, "norm": 5,
5843  "sol_at_lhs": 6, "sol_at_rhs": 7, "dual_sol": 8, "age": 9,
5844  "basis_lower": 10, "basis_basic": 11, "basis_upper": 12, "basis_zero": 13}
5845 
5846  if prev_row_features is None:
5847  row_features = [[0 for _ in range(n_row_features)] for _ in range(nrows)]
5848  else:
5849  assert len(prev_row_features) > 0, "Previous row features is empty"
5850  row_features = prev_row_features
5851  if len(prev_row_features) != nrows:
5852  if not suppress_warnings:
5853  raise Warning(f"The number of rows has changed. Previous row data being ignored")
5854  else:
5855  row_features = [[0 for _ in range(n_row_features)] for _ in range(nrows)]
5856  prev_row_features = None
5857  if len(prev_row_features[0]) != n_row_features:
5858  raise Warning(f"Dimension mismatch in provided previous features and new features:"
5859  f"{len(prev_row_features[0])} != {n_row_features}")
5860 
5861  cdef int nnzrs = 0
5862  cdef SCIP_Real lhs, rhs, cst
5863  for i in range(nrows):
5864 
5865  # lhs <= activity + cst <= rhs
5866  lhs = SCIProwGetLhs(rows[i])
5867  rhs = SCIProwGetRhs(rows[i])
5868  cst = SCIProwGetConstant(rows[i])
5869  activity = SCIPgetRowLPActivity(scip, rows[i])
5870 
5871  if prev_row_features is None:
5872  # number of coefficients
5873  row_features[i][row_feature_map["n_non_zeros"]] = SCIProwGetNLPNonz(rows[i])
5874  nnzrs += row_features[i][row_feature_map["n_non_zeros"]]
5875 
5876  # left-hand-side
5877  if not SCIPisInfinity(scip, abs(lhs)):
5878  row_features[i][row_feature_map["has_lhs"]] = 1
5879 
5880  # right-hand-side
5881  if not SCIPisInfinity(scip, abs(rhs)):
5882  row_features[i][row_feature_map["has_rhs"]] = 1
5883 
5884  # bias
5885  row_features[i][row_feature_map["bias"]] = cst
5886 
5887  # Objective cosine similarity
5888  row_features[i][row_feature_map["obj_cosine"]] = SCIPgetRowObjParallelism(scip, rows[i])
5889 
5890  # L2 norm
5891  row_features[i][row_feature_map["norm"]] = SCIProwGetNorm(rows[i])
5892 
5893  if not static_only:
5894 
5895  # Dual solution
5896  row_features[i][row_feature_map["dual_sol"]] = SCIProwGetDualsol(rows[i])
5897 
5898  # Basis status
5899  basis_status = SCIProwGetBasisStatus(rows[i])
5900  if basis_status == SCIP_BASESTAT_LOWER:
5901  row_features[i][row_feature_map["basis_lower"]] = 1
5902  elif basis_status == SCIP_BASESTAT_BASIC:
5903  row_features[i][row_feature_map["basis_basic"]] = 1
5904  elif basis_status == SCIP_BASESTAT_UPPER:
5905  row_features[i][row_feature_map["basis_upper"]] = 1
5906  elif basis_status == SCIP_BASESTAT_ZERO:
5907  row_features[i][row_feature_map["basis_zero"]] = 1
5908 
5909  # Age
5910  row_features[i][row_feature_map["age"]] = SCIProwGetAge(rows[i])
5911 
5912  # Is tight
5913  row_features[i][row_feature_map["sol_at_lhs"]] = int(SCIPisEQ(scip, activity, lhs))
5914  row_features[i][row_feature_map["sol_at_rhs"]] = int(SCIPisEQ(scip, activity, rhs))
5915 
5916  # Generate edge (coefficient) features
5917  cdef SCIP_COL** row_cols
5918  cdef SCIP_Real * row_vals
5919  n_edge_features = 3
5920  edge_feature_map = {"col_idx": 0, "row_idx": 1, "coef": 2}
5921  if prev_edge_features is None:
5922  edge_features = [[0 for _ in range(n_edge_features)] for _ in range(nnzrs)]
5923  j = 0
5924  for i in range(nrows):
5925  # coefficient indexes and values
5926  row_cols = SCIProwGetCols(rows[i])
5927  row_vals = SCIProwGetVals(rows[i])
5928  for k in range(row_features[i][row_feature_map["n_non_zeros"]]):
5929  edge_features[j][edge_feature_map["col_idx"]] = SCIPcolGetLPPos(row_cols[k])
5930  edge_features[j][edge_feature_map["row_idx"]] = i
5931  edge_features[j][edge_feature_map["coef"]] = row_vals[k]
5932  j += 1
5933  else:
5934  assert len(prev_edge_features) > 0, "Previous edge features is empty"
5935  edge_features = prev_edge_features
5936  if len(prev_edge_features) != nnzrs:
5937  if not suppress_warnings:
5938  raise Warning(f"The number of coefficients in the LP has changed. Previous edge data being ignored")
5939  else:
5940  edge_features = [[0 for _ in range(3)] for _ in range(nnzrs)]
5941  prev_edge_features = None
5942  if len(prev_edge_features[0]) != 3:
5943  raise Warning(f"Dimension mismatch in provided previous features and new features:"
5944  f"{len(prev_edge_features[0])} != 3")
5945 
5946 
5947  return (col_features, edge_features, row_features,
5948  {"col": col_feature_map, "edge": edge_feature_map, "row": row_feature_map})
5949 
5950 @dataclass
5952  """
5953  Attributes
5954  ----------
5955  total_time : float
5956  Total time since model was created
5957  solving_time: float
5958  Time spent solving the problem
5959  presolving_time: float
5960  Time spent on presolving
5961  reading_time: float
5962  Time spent on reading
5963  copying_time: float
5964  Time spent on copying
5965  problem_name: str
5966  Name of problem
5967  presolved_problem_name: str
5968  Name of presolved problem
5969  n_nodes: int
5970  The number of nodes explored in the branch-and-bound tree
5971  n_solutions_found: int
5972  number of found solutions
5973  first_solution: float
5974  objective value of first found solution
5975  primal_bound: float
5976  The best primal bound found
5977  dual_bound: float
5978  The best dual bound found
5979  gap: float
5980  The gap between the primal and dual bounds
5981  primal_dual_integral: float
5982  The primal-dual integral
5983  n_vars: int
5984  number of variables in the model
5985  n_binary_vars: int
5986  number of binary variables in the model
5987  n_integer_vars: int
5988  number of integer variables in the model
5989  n_implicit_integer_vars: int
5990  number of implicit integer variables in the model
5991  n_continuous_vars: int
5992  number of continuous variables in the model
5993  n_presolved_vars: int
5994  number of variables in the presolved model
5995  n_presolved_continuous_vars: int
5996  number of continuous variables in the presolved model
5997  n_presolved_binary_vars: int
5998  number of binary variables in the presolved model
5999  n_presolved_integer_vars: int
6000  number of integer variables in the presolved model
6001  n_presolved_implicit_integer_vars: int
6002  number of implicit integer variables in the presolved model
6003  n_maximal_cons: int
6004  number of maximal constraints in the model
6005  n_initial_cons: int
6006  number of initial constraints in the presolved model
6007  n_presolved_maximal_cons: int
6008  number of maximal constraints in the presolved model
6009  n_presolved_conss: int
6010  number of initial constraints in the model
6011  """
6012 
6013  total_time: float
6014  solving_time: float
6015  presolving_time: float
6016  reading_time: float
6017  copying_time: float
6018  problem_name: str
6019  presolved_problem_name: str
6020  _variables: dict # Dictionary with number of variables by type
6021  _presolved_variables: dict # Dictionary with number of presolved variables by type
6022  _constraints: dict # Dictionary with number of constraints by type
6023  _presolved_constraints: dict # Dictionary with number of presolved constraints by type
6024  n_runs: int
6025  n_nodes: int
6026  n_solutions_found: int
6027  first_solution: float
6028  primal_bound: float
6029  dual_bound: float
6030  gap: float
6031  primal_dual_integral: float
6032 
6033  # unpacking the _variables, _presolved_variables, _constraints
6034  # _presolved_constraints dictionaries
6035  @property
6036  def n_vars(self):
6037  return self._variables["total"]
6038 
6039  @property
6040  def n_binary_vars(self):
6041  return self._variables["binary"]
6042 
6043  @property
6044  def n_integer_vars(self):
6045  return self._variables["integer"]
6046 
6047  @property
6049  return self._variables["implicit"]
6050 
6051  @property
6053  return self._variables["continuous"]
6054 
6055  @property
6056  def n_presolved_vars(self):
6057  return self._presolved_variables["total"]
6058 
6059  @property
6061  return self._presolved_variables["binary"]
6062 
6063  @property
6065  return self._presolved_variables["integer"]
6066 
6067  @property
6069  return self._presolved_variables["implicit"]
6070 
6071  @property
6073  return self._presolved_variables["continuous"]
6074 
6075  @property
6076  def n_conss(self):
6077  return self._constraints["initial"]
6078 
6079  @property
6080  def n_maximal_cons(self):
6081  return self._constraints["maximal"]
6082 
6083  @property
6085  return self._presolved_constraints["initial"]
6086 
6087  @property
6089  return self._presolved_constraints["maximal"]
6090 
6091 # debugging memory management
6093  return BMSgetMemoryUsed() == 0
6094 
6096  BMScheckEmptyMemory()
pyscipopt.scip.Model.addConss
def addConss(self, conss, name='', initial=True, separate=True, enforce=True, check=True, propagate=True, local=False, modifiable=False, dynamic=False, removable=False, stickingatnode=False)
Definition: scip.pxi:2472
pyscipopt.scip.Statistics
Definition: scip.pxi:5951
SCIPnlrowGetConstant
SCIP_Real SCIPnlrowGetConstant(SCIP_NLROW *nlrow)
SCIPgetProbName
const char * SCIPgetProbName(SCIP *scip)
SCIPnodeGetDomchg
SCIP_DOMCHG * SCIPnodeGetDomchg(SCIP_NODE *node)
pyscipopt.scip.Model.freeBendersSubproblems
def freeBendersSubproblems(self)
Definition: scip.pxi:3642
SCIPincludeBenderscut
SCIP_RETCODE SCIPincludeBenderscut(SCIP *scip, SCIP_BENDERS *benders, const char *name, const char *desc, int priority, SCIP_Bool islpcut, SCIP_DECL_BENDERSCUTCOPY((*benderscutcopy)), SCIP_DECL_BENDERSCUTFREE((*benderscutfree)), SCIP_DECL_BENDERSCUTINIT((*benderscutinit)), SCIP_DECL_BENDERSCUTEXIT((*benderscutexit)), SCIP_DECL_BENDERSCUTINITSOL((*benderscutinitsol)), SCIP_DECL_BENDERSCUTEXITSOL((*benderscutexitsol)), SCIP_DECL_BENDERSCUTEXEC((*benderscutexec)), SCIP_BENDERSCUTDATA *benderscutdata)
pyscipopt.scip.Model.tightenVarUb
def tightenVarUb(self, Variable, var, ub, force=False)
Definition: scip.pxi:1637
pyscipopt.scip.Model.propagateProbing
def propagateProbing(self, maxproprounds)
Definition: scip.pxi:4512
SCIPgetReadingTime
SCIP_Real SCIPgetReadingTime(SCIP *scip)
SCIPconsIsPropagated
SCIP_Bool SCIPconsIsPropagated(SCIP_CONS *cons)
pyscipopt.scip.Model.setObjIntegral
def setObjIntegral(self)
Definition: scip.pxi:1424
pyscipopt.scip.Model.includeSepa
def includeSepa(self, Sepa, sepa, name, desc, priority=0, freq=10, maxbounddist=1.0, usessubscip=False, delay=False)
Definition: scip.pxi:4000
pyscipopt.scip.Column.__class__
__class__
Definition: scip.pxi:429
SCIPexprGetQuadraticBilinTerm
void SCIPexprGetQuadraticBilinTerm(SCIP_EXPR *expr, int termidx, SCIP_EXPR **expr1, SCIP_EXPR **expr2, SCIP_Real *coef, int *pos2, SCIP_EXPR **prodexpr)
pyscipopt.scip.Model.getRowLinear
def getRowLinear(self, Constraint, cons)
Definition: scip.pxi:3475
pyscipopt.scip.Model.getPseudoBranchCands
def getPseudoBranchCands(self)
Definition: scip.pxi:4267
pyscipopt.scip.Row.getVals
def getVals(self)
Definition: scip.pxi:521
SCIPisEQ
SCIP_Bool SCIPisEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
pyscipopt.scip.Node.scip_node
scip_node
Definition: scip.pxi:706
pyscipopt.scip.Event.getOldBound
def getOldBound(self)
Definition: scip.pxi:340
SCIPdropVarEvent
SCIP_RETCODE SCIPdropVarEvent(SCIP *scip, SCIP_VAR *var, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int filterpos)
SCIPaddConsNode
SCIP_RETCODE SCIPaddConsNode(SCIP *scip, SCIP_NODE *node, SCIP_CONS *cons, SCIP_NODE *validnode)
SCIPisFeasIntegral
SCIP_Bool SCIPisFeasIntegral(SCIP *scip, SCIP_Real val)
SCIPchgVarLbNode
SCIP_RETCODE SCIPchgVarLbNode(SCIP *scip, SCIP_NODE *node, SCIP_VAR *var, SCIP_Real newbound)
pyscipopt.scip.Model.fixVar
def fixVar(self, Variable, var, val)
Definition: scip.pxi:1595
pyscipopt.scip.Model.getDualfarkasLinear
def getDualfarkasLinear(self, Constraint, cons)
Definition: scip.pxi:3513
SCIPgetConsNVars
SCIP_RETCODE SCIPgetConsNVars(SCIP *scip, SCIP_CONS *cons, int *nvars, SCIP_Bool *success)
SCIPsetMessagehdlrQuiet
void SCIPsetMessagehdlrQuiet(SCIP *scip, SCIP_Bool quiet)
pyscipopt.scip.Row.isModifiable
def isModifiable(self)
Definition: scip.pxi:487
pyscipopt.scip.Variable.getLPSol
def getLPSol(self)
Definition: scip.pxi:899
SCIPnlrowGetLhs
SCIP_Real SCIPnlrowGetLhs(SCIP_NLROW *nlrow)
pyscipopt.scip.Model.setProbName
def setProbName(self, name)
Definition: scip.pxi:1453
SCIPincludeReader
SCIP_RETCODE SCIPincludeReader(SCIP *scip, const char *name, const char *desc, const char *extension, SCIP_DECL_READERCOPY((*readercopy)), SCIP_DECL_READERFREE((*readerfree)), SCIP_DECL_READERREAD((*readerread)), SCIP_DECL_READERWRITE((*readerwrite)), SCIP_READERDATA *readerdata)
SCIPgetVarsLinear
SCIP_VAR ** SCIPgetVarsLinear(SCIP *scip, SCIP_CONS *cons)
pyscipopt.scip.Model.getSlack
def getSlack(self, Constraint, cons, Solution, sol=None, side=None)
Definition: scip.pxi:3234
pyscipopt.scip.Model.getBranchScoreMultiple
def getBranchScoreMultiple(self, Variable, var, gains)
Definition: scip.pxi:5675
SCIPaddCons
SCIP_RETCODE SCIPaddCons(SCIP *scip, SCIP_CONS *cons)
SCIPgetDualbound
SCIP_Real SCIPgetDualbound(SCIP *scip)
pyscipopt.scip.NLRow.__class__
__class__
Definition: scip.pxi:584
pyscipopt.scip.BoundChange
Definition: scip.pxi:645
SCIPgetStatus
SCIP_STATUS SCIPgetStatus(SCIP *scip)
SCIPchgRhsNonlinear
SCIP_RETCODE SCIPchgRhsNonlinear(SCIP *scip, SCIP_CONS *cons, SCIP_Real rhs)
SCIPgetTransformedCons
SCIP_RETCODE SCIPgetTransformedCons(SCIP *scip, SCIP_CONS *cons, SCIP_CONS **transcons)
SCIPgetGap
SCIP_Real SCIPgetGap(SCIP *scip)
SCIPcreatePartialSol
SCIP_RETCODE SCIPcreatePartialSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
pyscipopt.scip.Model.delVar
def delVar(self, Variable, var)
Definition: scip.pxi:1608
SCIPgetDualboundRoot
SCIP_Real SCIPgetDualboundRoot(SCIP *scip)
SCIPsetIntParam
SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value)
pyscipopt.scip.Model.__init__
def __init__(self, problemName='model', defaultPlugins=True, Model, sourceModel=None, origcopy=False, globalcopy=True, enablepricing=False, createscip=True, threadsafe=False)
Definition: scip.pxi:1012
pyscipopt.scip.Model.getBestNode
def getBestNode(self)
Definition: scip.pxi:1861
SCIPcreateExprValue
SCIP_RETCODE SCIPcreateExprValue(SCIP *scip, SCIP_EXPR **expr, SCIP_Real value, SCIP_DECL_EXPR_OWNERCREATE((*ownercreate)), void *ownercreatedata)
SCIPchgVarUb
SCIP_RETCODE SCIPchgVarUb(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
pyscipopt.scip.Model.addVarToRow
def addVarToRow(self, Row, row, not, None, Variable, var, not, None, value)
Definition: scip.pxi:2052
pyscipopt.scip.Constraint.isSeparated
def isSeparated(self)
Definition: scip.pxi:934
SCIPaddPricedVar
SCIP_RETCODE SCIPaddPricedVar(SCIP *scip, SCIP_VAR *var, SCIP_Real score)
SCIPconsIsLocal
SCIP_Bool SCIPconsIsLocal(SCIP_CONS *cons)
pyscipopt.scip.Model.catchEvent
def catchEvent(self, eventtype, Eventhdlr, eventhdlr)
Definition: scip.pxi:5063
pyscipopt.scip.Statistics.n_presolved_continuous_vars
def n_presolved_continuous_vars(self)
Definition: scip.pxi:6072
pyscipopt.scip.Model.getDepth
def getDepth(self)
Definition: scip.pxi:1226
pyscipopt.scip.Model._scip
_scip
Definition: scip.pxi:1071
pyscipopt.scip.Statistics.n_continuous_vars
def n_continuous_vars(self)
Definition: scip.pxi:6052
SCIPcreateExprPow
SCIP_RETCODE SCIPcreateExprPow(SCIP *scip, SCIP_EXPR **expr, SCIP_EXPR *child, SCIP_Real exponent, SCIP_DECL_EXPR_OWNERCREATE((*ownercreate)), void *ownercreatedata)
pyscipopt.scip.Model.setHeuristics
def setHeuristics(self, setting)
Definition: scip.pxi:1466
pyscipopt.scip.Model.__hash__
def __hash__(self)
Definition: scip.pxi:1057
SCIPeventGetNewbound
SCIP_Real SCIPeventGetNewbound(SCIP_EVENT *event)
SCIPgetBranchScoreMultiple
SCIP_Real SCIPgetBranchScoreMultiple(SCIP *scip, SCIP_VAR *var, int nchildren, SCIP_Real *gains)
pyscipopt.scip.Model.redirectOutput
def redirectOutput(self)
Definition: scip.pxi:5262
pyscipopt.scip.Model.setRelaxSolVal
def setRelaxSolVal(self, Variable, var, val)
Definition: scip.pxi:3410
SCIPgetVarStrongbranchNode
SCIP_Longint SCIPgetVarStrongbranchNode(SCIP *scip, SCIP_VAR *var)
pyscipopt.scip.Model.isInfinity
def isInfinity(self, value)
Definition: scip.pxi:1258
SCIPgetVars
SCIP_VAR ** SCIPgetVars(SCIP *scip)
pyscipopt.scip.Column.getLb
def getLb(self)
Definition: scip.pxi:408
SCIPaddVar
SCIP_RETCODE SCIPaddVar(SCIP *scip, SCIP_VAR *var)
SCIProwGetParallelism
SCIP_Real SCIProwGetParallelism(SCIP_ROW *row1, SCIP_ROW *row2, char orthofunc)
SCIPgetNActiveBenders
int SCIPgetNActiveBenders(SCIP *scip)
pyscipopt.scip.Model.dropEvent
def dropEvent(self, eventtype, Eventhdlr, eventhdlr)
Definition: scip.pxi:5075
SCIPsetSeparating
SCIP_RETCODE SCIPsetSeparating(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
pyscipopt.scip.Model.checkQuadraticNonlinear
def checkQuadraticNonlinear(self, Constraint, cons)
Definition: scip.pxi:3337
SCIPfreeTransform
SCIP_RETCODE SCIPfreeTransform(SCIP *scip)
SCIPallColsInLP
SCIP_Bool SCIPallColsInLP(SCIP *scip)
pyscipopt.scip.Model.branchVarVal
def branchVarVal(self, variable, value)
Definition: scip.pxi:4303
pyscipopt.scip.Model.getLPBInvRow
def getLPBInvRow(self, row)
Definition: scip.pxi:1950
SCIPcreateExprAbs
SCIP_RETCODE SCIPcreateExprAbs(SCIP *scip, SCIP_EXPR **expr, SCIP_EXPR *child, SCIP_DECL_EXPR_OWNERCREATE((*ownercreate)), void *ownercreatedata)
SCIPboundchgGetBoundchgtype
SCIP_BOUNDCHGTYPE SCIPboundchgGetBoundchgtype(SCIP_BOUNDCHG *boundchg)
SCIPaddSolFree
SCIP_RETCODE SCIPaddSolFree(SCIP *scip, SCIP_SOL **sol, SCIP_Bool *stored)
pyscipopt.scip.Model.chgRowRhsDive
def chgRowRhsDive(self, Row, row, newrhs)
Definition: scip.pxi:4395
SCIPchgVarObj
SCIP_RETCODE SCIPchgVarObj(SCIP *scip, SCIP_VAR *var, SCIP_Real newobj)
pyscipopt.scip.Model.getObjVal
def getObjVal(self, original=True)
Definition: scip.pxi:4890
pyscipopt.scip.NLRow.getRhs
def getRhs(self)
Definition: scip.pxi:572
SCIPgetNLPRows
int SCIPgetNLPRows(SCIP *scip)
pyscipopt.scip.Model.addConsDisjunction
def addConsDisjunction(self, conss, name='', initial=True, relaxcons=None, enforce=True, check=True, local=False, modifiable=False, dynamic=False)
Definition: scip.pxi:2537
SCIPchgVarUbGlobal
SCIP_RETCODE SCIPchgVarUbGlobal(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
SCIPreleaseVar
SCIP_RETCODE SCIPreleaseVar(SCIP *scip, SCIP_VAR **var)
SCIPdelCoefLinear
SCIP_RETCODE SCIPdelCoefLinear(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var)
SCIPcreateConsSOS1
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)
pyscipopt.scip.Model.includeRelax
def includeRelax(self, Relax, relax, name, desc, priority=10000, freq=1)
Definition: scip.pxi:4096
SCIPgetNlRowSolActivity
SCIP_RETCODE SCIPgetNlRowSolActivity(SCIP *scip, SCIP_NLROW *nlrow, SCIP_SOL *sol, SCIP_Real *activity)
pyscipopt.scip.Row.getNLPNonz
def getNLPNonz(self)
Definition: scip.pxi:512
pyscipopt.scip.Model.setLongintParam
def setLongintParam(self, name, value)
Definition: scip.pxi:5303
SCIPeventGetNode
SCIP_NODE * SCIPeventGetNode(SCIP_EVENT *event)
SCIPwriteTransProblem
SCIP_RETCODE SCIPwriteTransProblem(SCIP *scip, const char *filename, const char *extension, SCIP_Bool genericnames)
pyscipopt.scip.Model.to_ptr
def to_ptr(self, give_ownership)
Definition: scip.pxi:1105
SCIPvarGetLPSol
SCIP_Real SCIPvarGetLPSol(SCIP_VAR *var)
pyscipopt.scip.Node.getAddedConss
def getAddedConss(self)
Definition: scip.pxi:733
SCIPvarGetAvgSol
SCIP_Real SCIPvarGetAvgSol(SCIP_VAR *var)
pyscipopt.scip.Model.getDualboundRoot
def getDualboundRoot(self)
Definition: scip.pxi:4981
SCIPrepropagateNode
SCIP_RETCODE SCIPrepropagateNode(SCIP *scip, SCIP_NODE *node)
pyscipopt.scip.Model.getLPColsData
def getLPColsData(self)
Definition: scip.pxi:1916
SCIPcreateVarBasic
SCIP_RETCODE SCIPcreateVarBasic(SCIP *scip, SCIP_VAR **var, const char *name, SCIP_Real lb, SCIP_Real ub, SCIP_Real obj, SCIP_VARTYPE vartype)
pyscipopt.scip.Model.cacheRowExtensions
def cacheRowExtensions(self, Row, row, not, None)
Definition: scip.pxi:2041
pyscipopt.scip.Model.createConsFromExpr
def createConsFromExpr(self, cons, name='', initial=True, separate=True, enforce=True, check=True, propagate=True, local=False, modifiable=False, dynamic=False, removable=False, stickingatnode=False)
Definition: scip.pxi:2382
pyscipopt.scip.Model.startStrongbranch
def startStrongbranch(self)
Definition: scip.pxi:5584
pyscipopt.scip.Model.setSolVal
def setSolVal(self, Solution, solution, Variable, var, val)
Definition: scip.pxi:4752
SCIPcolGetLPPos
int SCIPcolGetLPPos(SCIP_COL *col)
pyscipopt.scip.Model.getObjectiveSense
def getObjectiveSense(self)
Definition: scip.pxi:5053
pyscipopt.scip.Model.separateSol
def separateSol(self, Solution, sol=None, pretendroot=False, allowlocal=True, onlydelayed=False)
Definition: scip.pxi:2114
pyscipopt.scip.Column.getPrimsol
def getPrimsol(self)
Definition: scip.pxi:404
SCIPconsGetHdlr
SCIP_CONSHDLR * SCIPconsGetHdlr(SCIP_CONS *cons)
SCIPdropEvent
SCIP_RETCODE SCIPdropEvent(SCIP *scip, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int filterpos)
pyscipopt.scip.Model.getActivity
def getActivity(self, Constraint, cons, Solution, sol=None)
Definition: scip.pxi:3206
pyscipopt.scip.Model.chgVarUbDive
def chgVarUbDive(self, Variable, var, newbound)
Definition: scip.pxi:4377
SCIPnlrowGetRhs
SCIP_Real SCIPnlrowGetRhs(SCIP_NLROW *nlrow)
pyscipopt.scip.Event.getName
def getName(self)
Definition: scip.pxi:317
pyscipopt.scip.Model.disablePropagation
def disablePropagation(self, onlyroot=False)
Definition: scip.pxi:1474
SCIPconsIsModifiable
SCIP_Bool SCIPconsIsModifiable(SCIP_CONS *cons)
pyscipopt.scip.Event.getNode
def getNode(self)
Definition: scip.pxi:349
SCIPconshdlrGetName
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
SCIPfreeSol
SCIP_RETCODE SCIPfreeSol(SCIP *scip, SCIP_SOL **sol)
pyscipopt.scip.Variable.getUbLocal
def getUbLocal(self)
Definition: scip.pxi:891
SCIPgetTransformedVar
SCIP_RETCODE SCIPgetTransformedVar(SCIP *scip, SCIP_VAR *var, SCIP_VAR **transvar)
SCIPgetVarLbDive
SCIP_Real SCIPgetVarLbDive(SCIP *scip, SCIP_VAR *var)
SCIPsolveConcurrent
SCIP_RETCODE SCIPsolveConcurrent(SCIP *scip)
pyscipopt.scip.Model.setPresolve
def setPresolve(self, setting)
Definition: scip.pxi:1445
SCIPconsGetName
const char * SCIPconsGetName(SCIP_CONS *cons)
pyscipopt.scip.Model.__dealloc__
def __dealloc__(self)
Definition: scip.pxi:1051
SCIPnodeIsActive
SCIP_Bool SCIPnodeIsActive(SCIP_NODE *node)
pyscipopt.scip.Model.getConsNVars
def getConsNVars(self, Constraint, constraint)
Definition: scip.pxi:2599
SCIPnlrowGetLinearCoefs
SCIP_Real * SCIPnlrowGetLinearCoefs(SCIP_NLROW *nlrow)
SCIPgetLhsLinear
SCIP_Real SCIPgetLhsLinear(SCIP *scip, SCIP_CONS *cons)
pyscipopt.scip.Model.chgVarLbProbing
def chgVarLbProbing(self, Variable, var, lb)
Definition: scip.pxi:4454
pyscipopt.scip.Model.addConsSOS2
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)
Definition: scip.pxi:2742
SCIPgetBestSol
SCIP_SOL * SCIPgetBestSol(SCIP *scip)
pyscipopt.scip.Model.setBendersSubproblemIsConvex
def setBendersSubproblemIsConvex(self, Benders, benders, probnumber, isconvex=True)
Definition: scip.pxi:3697
pyscipopt.scip.Model.checkSol
def checkSol(self, Solution, solution, printreason=True, completely=False, checkbounds=True, checkintegrality=True, checklprows=True, original=False)
Definition: scip.pxi:4785
SCIPgetCutEfficacy
SCIP_Real SCIPgetCutEfficacy(SCIP *scip, SCIP_SOL *sol, SCIP_ROW *cut)
pyscipopt.scip.Model.addConsCardinality
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)
Definition: scip.pxi:2898
SCIPaddObjoffset
SCIP_RETCODE SCIPaddObjoffset(SCIP *scip, SCIP_Real addval)
pyscipopt.scip.Model.getDualsolLinear
def getDualsolLinear(self, Constraint, cons)
Definition: scip.pxi:3489
pyscipopt.scip.Model.writeProblem
def writeProblem(self, filename='model.cip', trans=False, genericnames=False, verbose=True)
Definition: scip.pxi:1484
pyscipopt.scip.Model.isFeasEQ
def isFeasEQ(self, val1, val2)
Definition: scip.pxi:1274
SCIPcreateExprCos
SCIP_RETCODE SCIPcreateExprCos(SCIP *scip, SCIP_EXPR **expr, SCIP_EXPR *child, SCIP_DECL_EXPR_OWNERCREATE((*ownercreate)), void *ownercreatedata)
pyscipopt.scip.Variable.getIndex
def getIndex(self)
Definition: scip.pxi:861
pyscipopt.scip.Model.solveBendersSubproblem
def solveBendersSubproblem(self, probnumber, solvecip, Benders, benders=None, Solution, solution=None)
Definition: scip.pxi:3734
SCIPendStrongbranch
SCIP_RETCODE SCIPendStrongbranch(SCIP *scip)
SCIPfeastol
SCIP_Real SCIPfeastol(SCIP *scip)
pyscipopt.scip.Constraint
Definition: scip.pxi:907
SCIPexprGetQuadraticData
void SCIPexprGetQuadraticData(SCIP_EXPR *expr, SCIP_Real *constant, int *nlinexprs, SCIP_EXPR ***linexprs, SCIP_Real **lincoefs, int *nquadexprs, int *nbilinexprs, SCIP_Real **eigenvalues, SCIP_Real **eigenvectors)
SCIPrestartSolve
SCIP_RETCODE SCIPrestartSolve(SCIP *scip)
pyscipopt.scip.Model.dropRowEvent
def dropRowEvent(self, Row, row, eventtype, Eventhdlr, eventhdlr)
Definition: scip.pxi:5117
pyscipopt.scip.Model.getLPBranchCands
def getLPBranchCands(self)
Definition: scip.pxi:4235
SCIPreadSol
SCIP_RETCODE SCIPreadSol(SCIP *scip, const char *filename)
pyscipopt.scip.Model.getNSolsFound
def getNSolsFound(self)
Definition: scip.pxi:4833
SCIPgetCurrentNode
SCIP_NODE * SCIPgetCurrentNode(SCIP *scip)
SCIPfeasFrac
SCIP_Real SCIPfeasFrac(SCIP *scip, SCIP_Real val)
pyscipopt.scip.Model.getNNlRows
def getNNlRows(self)
Definition: scip.pxi:3288
pyscipopt.scip.Statistics.n_presolved_vars
def n_presolved_vars(self)
Definition: scip.pxi:6056
SCIPnodeGetDepth
int SCIPnodeGetDepth(SCIP_NODE *node)
SCIPaddConsElemDisjunction
SCIP_RETCODE SCIPaddConsElemDisjunction(SCIP *scip, SCIP_CONS *cons, SCIP_CONS *addcons)
pyscipopt.scip.Solution._evaluate
def _evaluate(self, term)
Definition: scip.pxi:612
pyscipopt.scip.Model.createChild
def createChild(self, nodeselprio, estimate)
Definition: scip.pxi:4345
pyscipopt.scip.Statistics.n_integer_vars
def n_integer_vars(self)
Definition: scip.pxi:6044
SCIPgetBendersMasterVar
SCIP_RETCODE SCIPgetBendersMasterVar(SCIP *scip, SCIP_BENDERS *benders, SCIP_VAR *var, SCIP_VAR **mappedvar)
SCIPcreateConsCardinality
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)
pyscipopt.scip.Model.includeNodesel
def includeNodesel(self, Nodesel, nodesel, name, desc, stdpriority, memsavepriority)
Definition: scip.pxi:4154
SCIPchgVarLb
SCIP_RETCODE SCIPchgVarLb(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
SCIPfreeProb
SCIP_RETCODE SCIPfreeProb(SCIP *scip)
pyscipopt.scip.Model.writeBestSol
def writeBestSol(self, filename="origprob.sol", write_zeros=False)
Definition: scip.pxi:4631
SCIPaddVarSOS1
SCIP_RETCODE SCIPaddVarSOS1(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real weight)
pyscipopt.scip.Model.getNCountedSols
def getNCountedSols(self)
Definition: scip.pxi:5510
pyscipopt.scip.Model.readStatistics
def readStatistics(self, filename)
Definition: scip.pxi:5155
pyscipopt.scip.Model.startDive
def startDive(self)
Definition: scip.pxi:4358
pyscipopt.scip.Model.includeBenderscut
def includeBenderscut(self, Benders, benders, Benderscut, benderscut, name, desc, priority=1, islpcut=True)
Definition: scip.pxi:4204
pyscipopt.scip.Model.getObjoffset
def getObjoffset(self, original=True)
Definition: scip.pxi:1413
pyscipopt.scip.Model.addConsCoeff
def addConsCoeff(self, Constraint, cons, Variable, var, coeff)
Definition: scip.pxi:2666
SCIPcreateOrigSol
SCIP_RETCODE SCIPcreateOrigSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
pyscipopt.scip.Model.checkBendersSubproblemOptimality
def checkBendersSubproblemOptimality(self, Solution, solution, probnumber, Benders, benders=None)
Definition: scip.pxi:3834
pyscipopt.scip.is_memory_freed
def is_memory_freed()
Definition: scip.pxi:6092
SCIPisLE
SCIP_Bool SCIPisLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
pyscipopt.scip.Row.isIntegral
def isIntegral(self)
Definition: scip.pxi:479
pyscipopt.scip.Model.createCons
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)
Definition: scip.pxi:3955
SCIPgetVarUbDive
SCIP_Real SCIPgetVarUbDive(SCIP *scip, SCIP_VAR *var)
pyscipopt.scip.Node.__eq__
def __eq__(self, other)
Definition: scip.pxi:812
SCIPaddOrigObjoffset
SCIP_RETCODE SCIPaddOrigObjoffset(SCIP *scip, SCIP_Real addval)
SCIPwriteLP
SCIP_RETCODE SCIPwriteLP(SCIP *scip, const char *filename)
SCIPappendVarCardinality
SCIP_RETCODE SCIPappendVarCardinality(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_VAR *indvar)
pyscipopt.scip.Model.optimize
def optimize(self)
Definition: scip.pxi:3558
SCIPgetPrimalRayVal
SCIP_Real SCIPgetPrimalRayVal(SCIP *scip, SCIP_VAR *var)
SCIPnodeGetNAddedConss
int SCIPnodeGetNAddedConss(SCIP_NODE *node)
pyscipopt.scip.Model.chgVarObjDive
def chgVarObjDive(self, Variable, var, newobj)
Definition: scip.pxi:4369
pyscipopt.scip.DomainChanges.scip_domchg
scip_domchg
Definition: scip.pxi:689
pyscipopt.scip.Model.epsilon
def epsilon(self)
Definition: scip.pxi:1234
pyscipopt.scip.Model.infinity
def infinity(self)
Definition: scip.pxi:1230
SCIPincludeSepa
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)
SCIPdelCons
SCIP_RETCODE SCIPdelCons(SCIP *scip, SCIP_CONS *cons)
pyscipopt.scip.Row.getOrigintype
def getOrigintype(self)
Definition: scip.pxi:499
pyscipopt.scip.Model.getNChildren
def getNChildren(self)
Definition: scip.pxi:1210
SCIPchgVarObjProbing
SCIP_RETCODE SCIPchgVarObjProbing(SCIP *scip, SCIP_VAR *var, SCIP_Real newobj)
pyscipopt.scip.Model.getVars
def getVars(self, transformed=False)
Definition: scip.pxi:1772
pyscipopt.scip.Model.updateBendersLowerbounds
def updateBendersLowerbounds(self, lowerbounds, Benders, benders=None)
Definition: scip.pxi:3660
SCIPcheckSol
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)
pyscipopt.scip.Model.readParams
def readParams(self, file)
Definition: scip.pxi:5424
pyscipopt.scip.Model.getVarLbDive
def getVarLbDive(self, Variable, var)
Definition: scip.pxi:4381
SCIPgetLocalOrigEstimate
SCIP_Real SCIPgetLocalOrigEstimate(SCIP *scip)
pyscipopt.scip.Row.getNorm
def getNorm(self)
Definition: scip.pxi:530
SCIPgetDualSolVal
SCIP_RETCODE SCIPgetDualSolVal(SCIP *scip, SCIP_CONS *cons, SCIP_Real *dualsolval, SCIP_Bool *boundconstraint)
pyscipopt.scip.Model.getCutLPSolCutoffDistance
def getCutLPSolCutoffDistance(self, Row, cut, not, None, Solution, sol, not, None)
Definition: scip.pxi:2091
SCIPbranchVarVal
SCIP_RETCODE SCIPbranchVarVal(SCIP *scip, SCIP_VAR *var, SCIP_Real val, SCIP_NODE **downchild, SCIP_NODE **eqchild, SCIP_NODE **upchild)
pyscipopt.scip.Constraint.isEnforced
def isEnforced(self)
Definition: scip.pxi:938
pyscipopt.scip.Model.printNlRow
def printNlRow(self, NLRow, nlrow)
Definition: scip.pxi:3333
pyscipopt.scip.Event.__repr__
def __repr__(self)
Definition: scip.pxi:330
pyscipopt.scip.Model.catchRowEvent
def catchRowEvent(self, Row, row, eventtype, Eventhdlr, eventhdlr)
Definition: scip.pxi:5107
pyscipopt.scip.Node.getEstimate
def getEstimate(self)
Definition: scip.pxi:729
pyscipopt.scip.Event.event
event
Definition: scip.pxi:309
SCIPsetMessagehdlrLogfile
void SCIPsetMessagehdlrLogfile(SCIP *scip, const char *filename)
pyscipopt.scip.Model.getNLPIterations
def getNLPIterations(self)
Definition: scip.pxi:1186
SCIPeventGetVar
SCIP_VAR * SCIPeventGetVar(SCIP_EVENT *event)
pyscipopt.scip.Model.getLPRowsData
def getLPRowsData(self)
Definition: scip.pxi:1924
SCIPincludeEventhdlr
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)
pyscipopt.scip.Model.getSols
def getSols(self)
Definition: scip.pxi:4845
pyscipopt.scip.Model.setStringParam
def setStringParam(self, name, value)
Definition: scip.pxi:5333
pyscipopt.scip.Node.getParent
def getParent(self)
Definition: scip.pxi:709
pyscipopt.scip.Row.isRemovable
def isRemovable(self)
Definition: scip.pxi:491
pyscipopt.scip.Variable.getLbOriginal
def getLbOriginal(self)
Definition: scip.pxi:871
pyscipopt.scip.Column.scip_col
scip_col
Definition: scip.pxi:374
pyscipopt.scip.Model.appendVarSOS2
def appendVarSOS2(self, Constraint, cons, Variable, var)
Definition: scip.pxi:3059
SCIPgetActivityLinear
SCIP_Real SCIPgetActivityLinear(SCIP *scip, SCIP_CONS *cons, SCIP_SOL *sol)
pyscipopt.scip.Node.__hash__
def __hash__(self)
Definition: scip.pxi:809
SCIPprintRow
SCIP_RETCODE SCIPprintRow(SCIP *scip, SCIP_ROW *row, FILE *file)
pyscipopt.scip.Row.getAge
def getAge(self)
Definition: scip.pxi:526
SCIPboundchgIsRedundant
SCIP_Bool SCIPboundchgIsRedundant(SCIP_BOUNDCHG *boundchg)
SCIPinfinity
SCIP_Real SCIPinfinity(SCIP *scip)
pyscipopt.scip.Model.addConsXor
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)
Definition: scip.pxi:2859
pyscipopt.scip.Model.from_ptr
def from_ptr(capsule, take_ownership)
Definition: scip.pxi:1091
pyscipopt.scip.Model.includeDefaultPlugins
def includeDefaultPlugins(self)
Definition: scip.pxi:1118
SCIPgetLPObjval
SCIP_Real SCIPgetLPObjval(SCIP *scip)
SCIPsetEmphasis
SCIP_RETCODE SCIPsetEmphasis(SCIP *scip, SCIP_PARAMEMPHASIS paramemphasis, SCIP_Bool quiet)
SCIPgetNOrigVars
int SCIPgetNOrigVars(SCIP *scip)
pyscipopt.scip.Column.getObjCoeff
def getObjCoeff(self)
Definition: scip.pxi:416
pyscipopt.scip.Model.freeTransform
def freeTransform(self)
Definition: scip.pxi:1135
SCIPprintVersion
void SCIPprintVersion(SCIP *scip, FILE *file)
SCIPcolGetAge
int SCIPcolGetAge(SCIP_COL *col)
pyscipopt.scip.Model.freeSol
def freeSol(self, Solution, solution)
Definition: scip.pxi:4818
SCIPaddPoolCut
SCIP_RETCODE SCIPaddPoolCut(SCIP *scip, SCIP_ROW *row)
SCIPgetParams
SCIP_PARAM ** SCIPgetParams(SCIP *scip)
SCIPendDive
SCIP_RETCODE SCIPendDive(SCIP *scip)
pyscipopt.scip.Column.__eq__
def __eq__(self, other)
Definition: scip.pxi:428
SCIPsetObjIntegral
SCIP_RETCODE SCIPsetObjIntegral(SCIP *scip)
pyscipopt.scip.Variable.__get__
def __get__(self)
Definition: scip.pxi:829
pyscipopt.scip.Model.getPrimalRayVal
def getPrimalRayVal(self, Variable, var)
Definition: scip.pxi:4950
pyscipopt.scip.Model.getObjlimit
def getObjlimit(self)
Definition: scip.pxi:1341
pyscipopt.scip.DomainChanges.getBoundchgs
def getBoundchgs(self)
Definition: scip.pxi:692
pyscipopt.scip.Model.getParam
def getParam(self, name)
Definition: scip.pxi:5375
pyscipopt.scip.Variable.getAvgSol
def getAvgSol(self)
Definition: scip.pxi:903
SCIPgetNTotalNodes
SCIP_Longint SCIPgetNTotalNodes(SCIP *scip)
SCIPvarGetLbOriginal
SCIP_Real SCIPvarGetLbOriginal(SCIP_VAR *var)
SCIPcreateConsAnd
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)
pyscipopt.scip.Model.setCheck
def setCheck(self, Constraint, cons, newCheck)
Definition: scip.pxi:3095
pyscipopt.scip.Model.getNIntVars
def getNIntVars(self)
Definition: scip.pxi:1815
pyscipopt.scip.Model.setRemovable
def setRemovable(self, Constraint, cons, newRem)
Definition: scip.pxi:3077
pyscipopt.scip.Model.getStageName
def getStageName(self)
Definition: scip.pxi:5002
pyscipopt.scip.str_conversion
str_conversion
Definition: scip.pxi:48
SCIPprintBestTransSol
SCIP_RETCODE SCIPprintBestTransSol(SCIP *scip, FILE *file, SCIP_Bool printzeros)
SCIPcount
SCIP_RETCODE SCIPcount(SCIP *scip)
SCIPboundchgGetVar
SCIP_VAR * SCIPboundchgGetVar(SCIP_BOUNDCHG *boundchg)
SCIPresetParams
SCIP_RETCODE SCIPresetParams(SCIP *scip)
SCIPconsIsRemovable
SCIP_Bool SCIPconsIsRemovable(SCIP_CONS *cons)
pyscipopt.scip.Model.getTransformedCons
def getTransformedCons(self, Constraint, cons)
Definition: scip.pxi:3274
pyscipopt.scip.Model.getPresolvingTime
def getPresolvingTime(self)
Definition: scip.pxi:1182
SCIPpresolve
SCIP_RETCODE SCIPpresolve(SCIP *scip)
SCIPgetNConss
int SCIPgetNConss(SCIP *scip)
pyscipopt.scip.Model.getNlRows
def getNlRows(self)
Definition: scip.pxi:3292
pyscipopt.scip.Model.writeName
def writeName(self, Variable, var)
Definition: scip.pxi:4985
SCIPgetRowLinear
SCIP_ROW * SCIPgetRowLinear(SCIP *scip, SCIP_CONS *cons)
SCIPcreateCons
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)
SCIProwGetBasisStatus
SCIP_BASESTAT SCIProwGetBasisStatus(SCIP_ROW *row)
SCIProwGetNLPNonz
int SCIProwGetNLPNonz(SCIP_ROW *row)
SCIProwGetOriginCons
SCIP_CONS * SCIProwGetOriginCons(SCIP_ROW *row)
SCIPprintTransSol
SCIP_RETCODE SCIPprintTransSol(SCIP *scip, SCIP_SOL *sol, FILE *file, SCIP_Bool printzeros)
pyscipopt.scip.Model.addConsAnd
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)
Definition: scip.pxi:2781
SCIProwGetRhs
SCIP_Real SCIProwGetRhs(SCIP_ROW *row)
pyscipopt.scip.Node.getDepth
def getDepth(self)
Definition: scip.pxi:717
pyscipopt.scip.Statistics.n_maximal_cons
def n_maximal_cons(self)
Definition: scip.pxi:6080
pyscipopt.scip.Model.includeProp
def includeProp(self, Prop, prop, name, desc, presolpriority, presolmaxrounds, proptiming, presoltiming=SCIP_PRESOLTIMING_FAST, priority=1, freq=1, delay=True)
Definition: scip.pxi:4039
pyscipopt.scip.Model.presolve
def presolve(self)
Definition: scip.pxi:3573
SCIPvarSetData
void SCIPvarSetData(SCIP_VAR *var, SCIP_VARDATA *vardata)
SCIPfreeBendersSubproblem
SCIP_RETCODE SCIPfreeBendersSubproblem(SCIP *scip, SCIP_BENDERS *benders, int probnumber)
SCIPsetObjsense
SCIP_RETCODE SCIPsetObjsense(SCIP *scip, SCIP_OBJSENSE objsense)
SCIPcreateConsIndicator
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)
SCIPcreateBendersDefault
SCIP_RETCODE SCIPcreateBendersDefault(SCIP *scip, SCIP **subproblems, int nsubproblems)
SCIPcreateEmptyRowSepa
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)
SCIPgetNLPCols
int SCIPgetNLPCols(SCIP *scip)
SCIPboundchgGetBoundtype
SCIP_BOUNDTYPE SCIPboundchgGetBoundtype(SCIP_BOUNDCHG *boundchg)
pyscipopt.scip.Model.getBestLeaf
def getBestLeaf(self)
Definition: scip.pxi:1857
SCIPcatchVarEvent
SCIP_RETCODE SCIPcatchVarEvent(SCIP *scip, SCIP_VAR *var, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int *filterpos)
pyscipopt.scip.Model.addSol
def addSol(self, Solution, solution, free=True)
Definition: scip.pxi:4804
SCIPaddVarSOS2
SCIP_RETCODE SCIPaddVarSOS2(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real weight)
pyscipopt.scip.Model.isNLPConstructed
def isNLPConstructed(self)
Definition: scip.pxi:3284
pyscipopt.scip.Model.getNlRowSolActivity
def getNlRowSolActivity(self, NLRow, nlrow, Solution, sol=None)
Definition: scip.pxi:3299
SCIPvarGetLbGlobal
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
SCIPincludeNodesel
SCIP_RETCODE SCIPincludeNodesel(SCIP *scip, const char *name, const char *desc, int stdpriority, int memsavepriority, SCIP_DECL_NODESELCOPY((*nodeselcopy)), SCIP_DECL_NODESELFREE((*nodeselfree)), SCIP_DECL_NODESELINIT((*nodeselinit)), SCIP_DECL_NODESELEXIT((*nodeselexit)), SCIP_DECL_NODESELINITSOL((*nodeselinitsol)), SCIP_DECL_NODESELEXITSOL((*nodeselexitsol)), SCIP_DECL_NODESELSELECT((*nodeselselect)), SCIP_DECL_NODESELCOMP((*nodeselcomp)), SCIP_NODESELDATA *nodeseldata)
SCIPgetNlRowSolFeasibility
SCIP_RETCODE SCIPgetNlRowSolFeasibility(SCIP *scip, SCIP_NLROW *nlrow, SCIP_SOL *sol, SCIP_Real *feasibility)
pyscipopt.scip.Node.__class__
__class__
Definition: scip.pxi:813
pyscipopt.scip.Model.getTotalTime
def getTotalTime(self)
Definition: scip.pxi:1170
pyscipopt.scip.Column.getLPPos
def getLPPos(self)
Definition: scip.pxi:377
pyscipopt.scip.Model.getOpenNodes
def getOpenNodes(self)
Definition: scip.pxi:1869
pyscipopt.scip.Model.getNConss
def getNConss(self, transformed=True)
Definition: scip.pxi:3431
SCIPgetNChildren
int SCIPgetNChildren(SCIP *scip)
SCIPgetNParams
int SCIPgetNParams(SCIP *scip)
SCIPgetSolOrigObj
SCIP_Real SCIPgetSolOrigObj(SCIP *scip, SCIP_SOL *sol)
pyscipopt.scip.Model.setEnforced
def setEnforced(self, Constraint, cons, newEnf)
Definition: scip.pxi:3086
pyscipopt.scip.Model.getCutEfficacy
def getCutEfficacy(self, Row, cut, not, None, Solution, sol=None)
Definition: scip.pxi:2083
pyscipopt.scip.Event.__eq__
def __eq__(self, other)
Definition: scip.pxi:362
pyscipopt.scip.Model.includeBenders
def includeBenders(self, Benders, benders, name, desc, priority=1, cutlp=True, cutpseudo=True, cutrelax=True, shareaux=False)
Definition: scip.pxi:4174
pyscipopt.scip.Model.printRow
def printRow(self, Row, row, not, None)
Definition: scip.pxi:2056
SCIPvarGetName
const char * SCIPvarGetName(SCIP_VAR *var)
pyscipopt.scip.Model.setLogfile
def setLogfile(self, path)
Definition: scip.pxi:5271
pyscipopt.scip.Model.allColsInLP
def allColsInLP(self)
Definition: scip.pxi:1976
pyscipopt.scip.Constraint.__repr__
def __repr__(self)
Definition: scip.pxi:923
pyscipopt.scip.Variable.getCol
def getCol(self)
Definition: scip.pxi:865
pyscipopt.scip.Solution.__init__
def __init__(self, raise_error=False)
Definition: scip.pxi:591
SCIPchgRhsLinear
SCIP_RETCODE SCIPchgRhsLinear(SCIP *scip, SCIP_CONS *cons, SCIP_Real rhs)
pyscipopt.scip.Model.frac
def frac(self, value)
Definition: scip.pxi:1246
pyscipopt.scip.Event.__str__
def __str__(self)
Definition: scip.pxi:333
SCIPbendersSubproblem
SCIP * SCIPbendersSubproblem(SCIP_BENDERS *benders, int probnumber)
pyscipopt.scip.Constraint.isActive
def isActive(self)
Definition: scip.pxi:970
pyscipopt.scip.Model.getBendersSubproblem
def getBendersSubproblem(self, probnumber, Benders, benders=None)
Definition: scip.pxi:3765
SCIPwriteVarName
SCIP_RETCODE SCIPwriteVarName(SCIP *scip, FILE *file, SCIP_VAR *var, SCIP_Bool type)
SCIPdelConsLocal
SCIP_RETCODE SCIPdelConsLocal(SCIP *scip, SCIP_CONS *cons)
SCIPcreate
SCIP_RETCODE SCIPcreate(SCIP **scip)
pyscipopt.scip.Row.scip_row
scip_row
Definition: scip.pxi:440
pyscipopt.scip.Model.createOrigSol
def createOrigSol(self, Heur, heur=None)
Definition: scip.pxi:4585
pyscipopt.scip.Constraint.isLinear
def isLinear(self)
Definition: scip.pxi:974
SCIProwIsInGlobalCutpool
SCIP_Bool SCIProwIsInGlobalCutpool(SCIP_ROW *row)
pyscipopt.scip.NLRow.__eq__
def __eq__(self, other)
Definition: scip.pxi:583
SCIProwIsLocal
SCIP_Bool SCIProwIsLocal(SCIP_ROW *row)
pyscipopt.scip.Model.createSol
def createSol(self, Heur, heur=None)
Definition: scip.pxi:4550
pyscipopt.scip.Statistics.n_binary_vars
def n_binary_vars(self)
Definition: scip.pxi:6040
pyscipopt.scip.Model.getBestSol
def getBestSol(self)
Definition: scip.pxi:4858
pyscipopt.scip.Model.addVarSOS1
def addVarSOS1(self, Constraint, cons, Variable, var, weight)
Definition: scip.pxi:3030
pyscipopt.scip.Model.getNBestSolsFound
def getNBestSolsFound(self)
Definition: scip.pxi:4841
pyscipopt.scip.Variable.getLbGlobal
def getLbGlobal(self)
Definition: scip.pxi:879
pyscipopt.scip.Model.setRealParam
def setRealParam(self, name, value)
Definition: scip.pxi:5313
pyscipopt.scip.Variable.ptr
def ptr(self)
Definition: scip.pxi:833
pyscipopt.scip.Model.setupBendersSubproblem
def setupBendersSubproblem(self, probnumber, Benders, benders=None, Solution, solution=None, checktype=PY_SCIP_BENDERSENFOTYPE.LP)
Definition: scip.pxi:3707
SCIPapplyCutsProbing
SCIP_RETCODE SCIPapplyCutsProbing(SCIP *scip, SCIP_Bool *cutoff)
pyscipopt.scip.Model.addVar
def addVar(self, name='', vtype='C', lb=0.0, ub=None, obj=0.0, pricedVar=False, pricedVarScore=1.0)
Definition: scip.pxi:1516
pyscipopt.scip.Variable.isOriginal
def isOriginal(self)
Definition: scip.pxi:852
SCIPgetLPCols
SCIP_COL ** SCIPgetLPCols(SCIP *scip)
pyscipopt.scip.Model._getStageNames
def _getStageNames(self)
Definition: scip.pxi:5008
SCIPgetLPColsData
SCIP_RETCODE SCIPgetLPColsData(SCIP *scip, SCIP_COL ***cols, int *ncols)
pyscipopt.scip.Model.getTreesizeEstimation
def getTreesizeEstimation(self)
Definition: scip.pxi:5697
pyscipopt.scip.Model.trySol
def trySol(self, Solution, solution, printreason=True, completely=False, checkbounds=True, checkintegrality=True, checklprows=True, free=True)
Definition: scip.pxi:4766
SCIPsetMessagehdlr
SCIP_RETCODE SCIPsetMessagehdlr(SCIP *scip, SCIP_MESSAGEHDLR *messagehdlr)
pyscipopt.scip.Model.getDualSolVal
def getDualSolVal(self, Constraint, cons, boundconstraint=False)
Definition: scip.pxi:3541
SCIPfindPricer
SCIP_PRICER * SCIPfindPricer(SCIP *scip, const char *name)
SCIPstartStrongbranch
SCIP_RETCODE SCIPstartStrongbranch(SCIP *scip, SCIP_Bool enablepropagation)
SCIPgetVarRedcost
SCIP_Real SCIPgetVarRedcost(SCIP *scip, SCIP_VAR *var)
pyscipopt.scip.Model.catchVarEvent
def catchVarEvent(self, Variable, var, eventtype, Eventhdlr, eventhdlr)
Definition: scip.pxi:5087
SCIPeventGetOldbound
SCIP_Real SCIPeventGetOldbound(SCIP_EVENT *event)
SCIPcreateExprLog
SCIP_RETCODE SCIPcreateExprLog(SCIP *scip, SCIP_EXPR **expr, SCIP_EXPR *child, SCIP_DECL_EXPR_OWNERCREATE((*ownercreate)), void *ownercreatedata)
pyscipopt.scip.Variable.scip_var
scip_var
Definition: scip.pxi:824
pyscipopt.scip.NLRow.getLhs
def getLhs(self)
Definition: scip.pxi:568
pyscipopt.scip.Model.addConsElemDisjunction
def addConsElemDisjunction(self, Constraint, disj_cons, Constraint, cons)
Definition: scip.pxi:2588
pyscipopt.scip.Model.enableReoptimization
def enableReoptimization(self, enable=True)
Definition: scip.pxi:1310
SCIPcreateExprMonomial
SCIP_RETCODE SCIPcreateExprMonomial(SCIP *scip, SCIP_EXPR **expr, int nfactors, SCIP_VAR **vars, SCIP_Real *exponents, SCIP_DECL_EXPR_OWNERCREATE((*ownercreate)), void *ownercreatedata)
SCIPcacheRowExtensions
SCIP_RETCODE SCIPcacheRowExtensions(SCIP *scip, SCIP_ROW *row)
pyscipopt.scip.Model.createEmptyRowUnspec
def createEmptyRowUnspec(self, name="row", lhs=0.0, rhs=None, local=True, modifiable=False, removable=True)
Definition: scip.pxi:2011
SCIPgetRowLPActivity
SCIP_Real SCIPgetRowLPActivity(SCIP *scip, SCIP_ROW *row)
pyscipopt.scip.Constraint.__hash__
def __hash__(self)
Definition: scip.pxi:989
SCIPgetRhsNonlinear
SCIP_Real SCIPgetRhsNonlinear(SCIP_CONS *cons)
pyscipopt.scip.Constraint.isOriginal
def isOriginal(self)
Definition: scip.pxi:926
pyscipopt.scip.Model.getObjective
def getObjective(self)
Definition: scip.pxi:1390
SCIPbendersGetNSubproblems
int SCIPbendersGetNSubproblems(SCIP_BENDERS *benders)
SCIPcreateSol
SCIP_RETCODE SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
pyscipopt.scip.Constraint.isInitial
def isInitial(self)
Definition: scip.pxi:930
SCIPgetBestboundNode
SCIP_NODE * SCIPgetBestboundNode(SCIP *scip)
pyscipopt.scip.Model.getReadingTime
def getReadingTime(self)
Definition: scip.pxi:1178
pyscipopt.scip.Model.endDive
def endDive(self)
Definition: scip.pxi:4365
pyscipopt.scip.Model.addPyCons
def addPyCons(self, Constraint, cons)
Definition: scip.pxi:3021
SCIPgetNSiblings
int SCIPgetNSiblings(SCIP *scip)
SCIPgetNOrigConss
int SCIPgetNOrigConss(SCIP *scip)
pyscipopt.scip.Model.calcChildEstimate
def calcChildEstimate(self, Variable, variable, targetvalue)
Definition: scip.pxi:4333
pyscipopt.scip.Row.isInGlobalCutpool
def isInGlobalCutpool(self)
Definition: scip.pxi:495
SCIPchgVarBranchPriority
SCIP_RETCODE SCIPchgVarBranchPriority(SCIP *scip, SCIP_VAR *var, int branchpriority)
pyscipopt.scip.BoundChange.getBoundtype
def getBoundtype(self)
Definition: scip.pxi:668
SCIPgetLPBasisInd
SCIP_RETCODE SCIPgetLPBasisInd(SCIP *scip, int *basisind)
pyscipopt.scip.Model.endProbing
def endProbing(self)
Definition: scip.pxi:4430
SCIPvarGetObj
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
SCIPactivatePricer
SCIP_RETCODE SCIPactivatePricer(SCIP *scip, SCIP_PRICER *pricer)
SCIPgetBestSibling
SCIP_NODE * SCIPgetBestSibling(SCIP *scip)
pyscipopt.scip.Model.setInitial
def setInitial(self, Constraint, cons, newInit)
Definition: scip.pxi:3068
pyscipopt.scip.Model.resetParam
def resetParam(self, name)
Definition: scip.pxi:5459
pyscipopt.scip.Column
Definition: scip.pxi:366
pyscipopt.scip.Model.getNVars
def getNVars(self, transformed=True)
Definition: scip.pxi:1805
pyscipopt.scip.Node.getNAddedConss
def getNAddedConss(self)
Definition: scip.pxi:746
SCIPgetNSepaRounds
int SCIPgetNSepaRounds(SCIP *scip)
pyscipopt.scip.Model.chgVarLb
def chgVarLb(self, Variable, var, lb)
Definition: scip.pxi:1685
pyscipopt.scip.Variable.__repr__
def __repr__(self)
Definition: scip.pxi:837
pyscipopt.scip.Model._modelvars
_modelvars
Definition: scip.pxi:1029
pyscipopt.scip.Model.getNSepaRounds
def getNSepaRounds(self)
Definition: scip.pxi:2109
pyscipopt.scip.Node.getDomchg
def getDomchg(self)
Definition: scip.pxi:802
pyscipopt.scip.Model.delCoefLinear
def delCoefLinear(self, Constraint, cons, Variable, var)
Definition: scip.pxi:3183
pyscipopt.scip.Model.resetParams
def resetParams(self)
Definition: scip.pxi:5468
SCIPgetRhsLinear
SCIP_Real SCIPgetRhsLinear(SCIP *scip, SCIP_CONS *cons)
pyscipopt.scip.Node
Definition: scip.pxi:698
pyscipopt.scip.Model.updateVarPseudocost
def updateVarPseudocost(self, Variable, var, valdelta, objdelta, weight)
Definition: scip.pxi:5661
pyscipopt.scip.Node.getNParentBranchings
def getNParentBranchings(self)
Definition: scip.pxi:758
pyscipopt.scip.Model.chgVarObjProbing
def chgVarObjProbing(self, Variable, var, newobj)
Definition: scip.pxi:4450
SCIProwGetName
const char * SCIProwGetName(SCIP_ROW *row)
pyscipopt.scip.Model.getRowObjParallelism
def getRowObjParallelism(self, Row, row)
Definition: scip.pxi:2064
SCIPfindConshdlr
SCIP_CONSHDLR * SCIPfindConshdlr(SCIP *scip, const char *name)
pyscipopt.scip.Constraint.__class__
__class__
Definition: scip.pxi:993
SCIPlpiGetRealSolQuality
SCIP_RETCODE SCIPlpiGetRealSolQuality(SCIP_LPI *lpi, SCIP_LPSOLQUALITY qualityindicator, SCIP_Real *quality)
SCIPstartProbing
SCIP_RETCODE SCIPstartProbing(SCIP *scip)
pyscipopt.scip.Model.includeCutsel
def includeCutsel(self, Cutsel, cutsel, name, desc, priority)
Definition: scip.pxi:4115
pyscipopt.scip.DomainChanges
Definition: scip.pxi:681
pyscipopt.scip.Model.tightenVarLb
def tightenVarLb(self, Variable, var, lb, force=False)
Definition: scip.pxi:1621
pyscipopt.scip.Model.isFeasNegative
def isFeasNegative(self, value)
Definition: scip.pxi:1262
SCIPgetParam
SCIP_PARAM * SCIPgetParam(SCIP *scip, const char *name)
pyscipopt.scip.Model.calcNodeselPriority
def calcNodeselPriority(self, Variable, variable, branchdir, targetvalue)
Definition: scip.pxi:4320
SCIPgetSolTransObj
SCIP_Real SCIPgetSolTransObj(SCIP *scip, SCIP_SOL *sol)
SCIPcatchRowEvent
SCIP_RETCODE SCIPcatchRowEvent(SCIP *scip, SCIP_ROW *row, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int *filterpos)
SCIPisCutEfficacious
SCIP_Bool SCIPisCutEfficacious(SCIP *scip, SCIP_SOL *sol, SCIP_ROW *cut)
SCIPgetVarStrongbranchFrac
SCIP_RETCODE SCIPgetVarStrongbranchFrac(SCIP *scip, SCIP_VAR *var, int itlim, SCIP_Bool idempotent, SCIP_Real *down, SCIP_Real *up, SCIP_Bool *downvalid, SCIP_Bool *upvalid, SCIP_Bool *downinf, SCIP_Bool *upinf, SCIP_Bool *downconflict, SCIP_Bool *upconflict, SCIP_Bool *lperror)
SCIPincludeBenders
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)
pyscipopt.scip.Model.getSolTime
def getSolTime(self, Solution, sol)
Definition: scip.pxi:4882
pyscipopt.scip.Row.getNNonz
def getNNonz(self)
Definition: scip.pxi:508
SCIPsetPresolving
SCIP_RETCODE SCIPsetPresolving(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
SCIPsetBoolParam
SCIP_RETCODE SCIPsetBoolParam(SCIP *scip, const char *name, SCIP_Bool value)
SCIPtrySolFree
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)
SCIPconsIsDynamic
SCIP_Bool SCIPconsIsDynamic(SCIP_CONS *cons)
pyscipopt.scip.Model.flushRowExtensions
def flushRowExtensions(self, Row, row, not, None)
Definition: scip.pxi:2048
SCIPsolIsOriginal
SCIP_Bool SCIPsolIsOriginal(SCIP_SOL *sol)
SCIPvarGetLbLocal
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
SCIPnodeGetEstimate
SCIP_Real SCIPnodeGetEstimate(SCIP_NODE *node)
pyscipopt.scip.Model.setParam
def setParam(self, name, value)
Definition: scip.pxi:5344
SCIPgetRowNumIntCols
int SCIPgetRowNumIntCols(SCIP *scip, SCIP_ROW *row)
pyscipopt.scip.BoundChange.getBoundchgtype
def getBoundchgtype(self)
Definition: scip.pxi:664
pyscipopt.scip.Model.chgVarUbGlobal
def chgVarUbGlobal(self, Variable, var, ub)
Definition: scip.pxi:1718
pyscipopt.scip.BoundChange.scip_boundchg
scip_boundchg
Definition: scip.pxi:653
SCIPisLPSolBasic
SCIP_Bool SCIPisLPSolBasic(SCIP *scip)
SCIPgetNCutsApplied
int SCIPgetNCutsApplied(SCIP *scip)
SCIPcheckQuadraticNonlinear
SCIP_RETCODE SCIPcheckQuadraticNonlinear(SCIP *scip, SCIP_CONS *cons, SCIP_Bool *isquadratic)
SCIPbendersGetAuxiliaryVar
SCIP_VAR * SCIPbendersGetAuxiliaryVar(SCIP_BENDERS *benders, int probnumber)
pyscipopt.scip.Model.feasFrac
def feasFrac(self, value)
Definition: scip.pxi:1242
SCIPbendersSetSubproblemIsConvex
void SCIPbendersSetSubproblemIsConvex(SCIP_BENDERS *benders, int probnumber, SCIP_Bool isconvex)
SCIPconsIsInitial
SCIP_Bool SCIPconsIsInitial(SCIP_CONS *cons)
SCIPtightenVarLb
SCIP_RETCODE SCIPtightenVarLb(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound, SCIP_Bool force, SCIP_Bool *infeasible, SCIP_Bool *tightened)
SCIPgetLPBInvARow
SCIP_RETCODE SCIPgetLPBInvARow(SCIP *scip, int r, SCIP_Real *binvrow, SCIP_Real *coefs, int *inds, int *ninds)
pyscipopt.scip.Constraint.isChecked
def isChecked(self)
Definition: scip.pxi:942
SCIPnodeGetNumber
SCIP_Longint SCIPnodeGetNumber(SCIP_NODE *node)
pyscipopt.scip.Model.getBendersVar
def getBendersVar(self, Variable, var, Benders, benders=None, probnumber=-1)
Definition: scip.pxi:3785
pyscipopt.scip.Solution.sol
sol
Definition: scip.pxi:599
pyscipopt.scip.Model.getBestboundNode
def getBestboundNode(self)
Definition: scip.pxi:1865
pyscipopt.scip.Row.getConsOriginConshdlrtype
def getConsOriginConshdlrtype(self)
Definition: scip.pxi:503
SCIPgetNBestSolsFound
SCIP_Longint SCIPgetNBestSolsFound(SCIP *scip)
pyscipopt.scip.Model.getNLPRows
def getNLPRows(self)
Definition: scip.pxi:1932
pyscipopt.scip.Model.interruptSolve
def interruptSolve(self)
Definition: scip.pxi:4528
pyscipopt.scip.Model.setBoolParam
def setBoolParam(self, name, value)
Definition: scip.pxi:5283
SCIPstartDive
SCIP_RETCODE SCIPstartDive(SCIP *scip)
SCIPtightenVarUb
SCIP_RETCODE SCIPtightenVarUb(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound, SCIP_Bool force, SCIP_Bool *infeasible, SCIP_Bool *tightened)
SCIPnodeGetLowerbound
SCIP_Real SCIPnodeGetLowerbound(SCIP_NODE *node)
pyscipopt.scip.Model.getNLimSolsFound
def getNLimSolsFound(self)
Definition: scip.pxi:4837
pyscipopt.scip.Model.chgRowLhsDive
def chgRowLhsDive(self, Row, row, newlhs)
Definition: scip.pxi:4389
pyscipopt.scip.Model.hideOutput
def hideOutput(self, quiet=True)
Definition: scip.pxi:5252
pyscipopt.scip.Statistics.n_presolved_integer_vars
def n_presolved_integer_vars(self)
Definition: scip.pxi:6064
SCIPaddVarToRow
SCIP_RETCODE SCIPaddVarToRow(SCIP *scip, SCIP_ROW *row, SCIP_VAR *var, SCIP_Real val)
pyscipopt.scip.Model.addCoefLinear
def addCoefLinear(self, Constraint, cons, Variable, var, value)
Definition: scip.pxi:3195
SCIPisInfinity
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
pyscipopt.scip.Model.getStage
def getStage(self)
Definition: scip.pxi:4998
SCIPcolGetUb
SCIP_Real SCIPcolGetUb(SCIP_COL *col)
SCIPgetProbingDepth
int SCIPgetProbingDepth(SCIP *scip)
SCIPisZero
SCIP_Bool SCIPisZero(SCIP *scip, SCIP_Real val)
pyscipopt.scip.Model.constructLP
def constructLP(self)
Definition: scip.pxi:1900
SCIPgetColRedcost
SCIP_Real SCIPgetColRedcost(SCIP *scip, SCIP_COL *col)
pyscipopt.scip.Model.createEmptyRowSepa
def createEmptyRowSepa(self, Sepa, sepa, name="row", lhs=0.0, rhs=None, local=True, modifiable=False, removable=True)
Definition: scip.pxi:1992
SCIPexprGetQuadraticQuadTerm
void SCIPexprGetQuadraticQuadTerm(SCIP_EXPR *quadexpr, int termidx, SCIP_EXPR **expr, SCIP_Real *lincoef, SCIP_Real *sqrcoef, int *nadjbilin, int **adjbilin, SCIP_EXPR **sqrexpr)
SCIPgetLPRowsData
SCIP_RETCODE SCIPgetLPRowsData(SCIP *scip, SCIP_ROW ***rows, int *nrows)
SCIProwGetCols
SCIP_COL ** SCIProwGetCols(SCIP_ROW *row)
pyscipopt.scip.NLRow.scip_nlrow
scip_nlrow
Definition: scip.pxi:549
pyscipopt.scip.Model.getNBinVars
def getNBinVars(self)
Definition: scip.pxi:1819
pyscipopt.scip.Model.getPrimalbound
def getPrimalbound(self)
Definition: scip.pxi:4973
SCIPgetTotalTime
SCIP_Real SCIPgetTotalTime(SCIP *scip)
SCIPsetConsEnforced
SCIP_RETCODE SCIPsetConsEnforced(SCIP *scip, SCIP_CONS *cons, SCIP_Bool enforce)
pyscipopt.scip.Model.restartSolve
def restartSolve(self)
Definition: scip.pxi:4532
pyscipopt.scip.BoundChange.getVar
def getVar(self)
Definition: scip.pxi:660
SCIPgetNCountedSols
SCIP_Longint SCIPgetNCountedSols(SCIP *scip, SCIP_Bool *valid)
SCIPgetObjlimit
SCIP_Real SCIPgetObjlimit(SCIP *scip)
SCIPincludeConshdlr
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_DECL_CONSGETPERMSYMGRAPH((*consgetpermsymgraph)), SCIP_DECL_CONSGETSIGNEDPERMSYMGRAPH((*consgetsignedpermsymgraph)), SCIP_CONSHDLRDATA *conshdlrdata)
SCIPbranchVar
SCIP_RETCODE SCIPbranchVar(SCIP *scip, SCIP_VAR *var, SCIP_NODE **downchild, SCIP_NODE **eqchild, SCIP_NODE **upchild)
SCIPboundchgGetNewbound
SCIP_Real SCIPboundchgGetNewbound(SCIP_BOUNDCHG *boundchg)
SCIPpropagateProbing
SCIP_RETCODE SCIPpropagateProbing(SCIP *scip, int maxproprounds, SCIP_Bool *cutoff, SCIP_Longint *ndomredsfound)
SCIPcreateChild
SCIP_RETCODE SCIPcreateChild(SCIP *scip, SCIP_NODE **node, SCIP_Real nodeselprio, SCIP_Real estimate)
pyscipopt.scip.Model.freeProb
def freeProb(self)
Definition: scip.pxi:1131
SCIPgetSolTime
SCIP_Real SCIPgetSolTime(SCIP *scip, SCIP_SOL *sol)
SCIPgetConsVars
SCIP_RETCODE SCIPgetConsVars(SCIP *scip, SCIP_CONS *cons, SCIP_VAR **vars, int varssize, SCIP_Bool *success)
SCIPcreateProbBasic
SCIP_RETCODE SCIPcreateProbBasic(SCIP *scip, const char *name)
SCIPisGT
SCIP_Bool SCIPisGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIPincludeBranchrule
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)
pyscipopt.scip.Model.branchVar
def branchVar(self, Variable, variable)
Definition: scip.pxi:4287
SCIPprintNlRow
SCIP_RETCODE SCIPprintNlRow(SCIP *scip, SCIP_NLROW *nlrow, FILE *file)
pyscipopt.scip.Model.getValsLinear
def getValsLinear(self, Constraint, cons)
Definition: scip.pxi:3454
pyscipopt.scip.Variable.isInLP
def isInLP(self)
Definition: scip.pxi:856
SCIPisObjChangedProbing
SCIP_Bool SCIPisObjChangedProbing(SCIP *scip)
SCIPcopy
SCIP_RETCODE SCIPcopy(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, const char *suffix, SCIP_Bool global, SCIP_Bool enablepricing, SCIP_Bool threadsafe, SCIP_Bool passmessagehdlr, SCIP_Bool *valid)
SCIPdomchgGetBoundchg
SCIP_BOUNDCHG * SCIPdomchgGetBoundchg(SCIP_DOMCHG *domchg, int pos)
pyscipopt.scip.Row.getLhs
def getLhs(self)
Definition: scip.pxi:448
SCIPaddVarIndicator
SCIP_RETCODE SCIPaddVarIndicator(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real val)
SCIPtightenVarUbGlobal
SCIP_RETCODE SCIPtightenVarUbGlobal(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound, SCIP_Bool force, SCIP_Bool *infeasible, SCIP_Bool *tightened)
SCIPendProbing
SCIP_RETCODE SCIPendProbing(SCIP *scip)
pyscipopt.scip.Node.getType
def getType(self)
Definition: scip.pxi:721
SCIPcreateConsQuadraticNonlinear
SCIP_RETCODE SCIPcreateConsQuadraticNonlinear(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 *quadcoefs, 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)
pyscipopt.scip.Model.addVarSOS2
def addVarSOS2(self, Constraint, cons, Variable, var, weight)
Definition: scip.pxi:3049
SCIPupdateNodeLowerbound
SCIP_RETCODE SCIPupdateNodeLowerbound(SCIP *scip, SCIP_NODE *node, SCIP_Real newbound)
pyscipopt.scip.Model.getVarUbDive
def getVarUbDive(self, Variable, var)
Definition: scip.pxi:4385
SCIPtrySol
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)
pyscipopt.scip.Model.addConsIndicator
def addConsIndicator(self, cons, binvar=None, activeone=True, name="IndicatorCons", initial=True, separate=True, enforce=True, check=True, propagate=True, local=False, dynamic=False, removable=False, stickingatnode=False)
Definition: scip.pxi:2948
SCIPcatchEvent
SCIP_RETCODE SCIPcatchEvent(SCIP *scip, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int *filterpos)
SCIPbendersUpdateSubproblemLowerbound
void SCIPbendersUpdateSubproblemLowerbound(SCIP_BENDERS *benders, int probnumber, SCIP_Real lowerbound)
SCIPgetLhsNonlinear
SCIP_Real SCIPgetLhsNonlinear(SCIP_CONS *cons)
SCIPcreateConsOr
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)
SCIPnlrowGetDualsol
SCIP_Real SCIPnlrowGetDualsol(SCIP_NLROW *nlrow)
SCIPchgVarLbGlobal
SCIP_RETCODE SCIPchgVarLbGlobal(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
SCIPgetBestLeaf
SCIP_NODE * SCIPgetBestLeaf(SCIP *scip)
SCIPnlrowGetLinearVars
SCIP_VAR ** SCIPnlrowGetLinearVars(SCIP_NLROW *nlrow)
pyscipopt.scip.Model.getLPBInvARow
def getLPBInvARow(self, row)
Definition: scip.pxi:1961
pyscipopt.scip.Model.feastol
def feastol(self)
Definition: scip.pxi:1238
SCIPgetStage
SCIP_STAGE SCIPgetStage(SCIP *scip)
pyscipopt.scip.Statistics.n_presolved_maximal_cons
def n_presolved_maximal_cons(self)
Definition: scip.pxi:6088
SCIPnodeGetParent
SCIP_NODE * SCIPnodeGetParent(SCIP_NODE *node)
SCIPdomchgGetNBoundchgs
int SCIPdomchgGetNBoundchgs(SCIP_DOMCHG *domchg)
SCIPcreateConsDisjunction
SCIP_RETCODE SCIPcreateConsDisjunction(SCIP *scip, SCIP_CONS **cons, const char *name, int nconss, SCIP_CONS **conss, SCIP_CONS *relaxcons, SCIP_Bool initial, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic)
SCIPsolve
SCIP_RETCODE SCIPsolve(SCIP *scip)
pyscipopt.scip.Model.addCons
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)
Definition: scip.pxi:2428
pyscipopt.scip.Model.setParams
def setParams(self, params)
Definition: scip.pxi:5416
pyscipopt.scip.Model
Definition: scip.pxi:1009
SCIPfindBenders
SCIP_BENDERS * SCIPfindBenders(SCIP *scip, const char *name)
pyscipopt.scip.Model.getLPSolstat
def getLPSolstat(self)
Definition: scip.pxi:1895
SCIPinterruptSolve
SCIP_RETCODE SCIPinterruptSolve(SCIP *scip)
pyscipopt.scip.Variable.vtype
def vtype(self)
Definition: scip.pxi:840
pyscipopt.scip.Model.writeBestTransSol
def writeBestTransSol(self, filename="transprob.sol", write_zeros=False)
Definition: scip.pxi:4650
SCIPchgRowRhsDive
SCIP_RETCODE SCIPchgRowRhsDive(SCIP *scip, SCIP_ROW *row, SCIP_Real newrhs)
pyscipopt.scip.Statistics.n_presolved_binary_vars
def n_presolved_binary_vars(self)
Definition: scip.pxi:6060
SCIPaddVarCardinality
SCIP_RETCODE SCIPaddVarCardinality(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_VAR *indvar, SCIP_Real weight)
pyscipopt.scip.Column.getBasisStatus
def getBasisStatus(self)
Definition: scip.pxi:381
SCIPconsIsChecked
SCIP_Bool SCIPconsIsChecked(SCIP_CONS *cons)
SCIPgetVarStrongbranchLast
SCIP_RETCODE SCIPgetVarStrongbranchLast(SCIP *scip, SCIP_VAR *var, SCIP_Real *down, SCIP_Real *up, SCIP_Bool *downvalid, SCIP_Bool *upvalid, SCIP_Real *solval, SCIP_Real *lpobjval)
SCIPgetLPBranchCands
SCIP_RETCODE SCIPgetLPBranchCands(SCIP *scip, SCIP_VAR ***lpcands, SCIP_Real **lpcandssol, SCIP_Real **lpcandsfrac, int *nlpcands, int *npriolpcands, int *nfracimplvars)
pyscipopt.scip.Model.isLE
def isLE(self, val1, val2)
Definition: scip.pxi:1278
SCIPaddBendersSubproblem
SCIP_RETCODE SCIPaddBendersSubproblem(SCIP *scip, SCIP_BENDERS *benders, SCIP *subproblem)
pyscipopt.scip.Event.getRow
def getRow(self)
Definition: scip.pxi:354
pyscipopt.scip.Model.getNInfeasibleLeaves
def getNInfeasibleLeaves(self)
Definition: scip.pxi:1202
SCIPcheckBendersSubproblemOptimality
SCIP_RETCODE SCIPcheckBendersSubproblemOptimality(SCIP *scip, SCIP_BENDERS *benders, SCIP_SOL *sol, int probnumber, SCIP_Bool *optimal)
pyscipopt.scip.Model.addConsSOS1
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)
Definition: scip.pxi:2703
SCIPgetBestNode
SCIP_NODE * SCIPgetBestNode(SCIP *scip)
pyscipopt.scip.Model.inRepropagation
def inRepropagation(self)
Definition: scip.pxi:4419
SCIPgetNCuts
int SCIPgetNCuts(SCIP *scip)
SCIPreadSolFile
SCIP_RETCODE SCIPreadSolFile(SCIP *scip, const char *filename, SCIP_SOL *sol, SCIP_Bool xml, SCIP_Bool *partial, SCIP_Bool *error)
pyscipopt.scip.Event.getNewBound
def getNewBound(self)
Definition: scip.pxi:336
pyscipopt.scip.Model.getNSols
def getNSols(self)
Definition: scip.pxi:4826
pyscipopt.scip.Node.isActive
def isActive(self)
Definition: scip.pxi:750
SCIPcreateConsNonlinear
SCIP_RETCODE SCIPcreateConsNonlinear(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_EXPR *expr, 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)
pyscipopt.scip.Model.endStrongbranch
def endStrongbranch(self)
Definition: scip.pxi:5591
SCIPgetOrigConss
SCIP_CONS ** SCIPgetOrigConss(SCIP *scip)
SCIPsetConsChecked
SCIP_RETCODE SCIPsetConsChecked(SCIP *scip, SCIP_CONS *cons, SCIP_Bool check)
pyscipopt.scip.Model.getNNodes
def getNNodes(self)
Definition: scip.pxi:1190
SCIPprintExternalCodes
void SCIPprintExternalCodes(SCIP *scip, FILE *file)
pyscipopt.scip.Constraint.__get__
def __get__(self)
Definition: scip.pxi:919
pyscipopt.scip.Model.getLPBasisInd
def getLPBasisInd(self)
Definition: scip.pxi:1940
SCIPreadParams
SCIP_RETCODE SCIPreadParams(SCIP *scip, const char *filename)
pyscipopt.scip.Model.getNlRowActivityBounds
def getNlRowActivityBounds(self, NLRow, nlrow)
Definition: scip.pxi:3325
pyscipopt.scip.Variable.getUbOriginal
def getUbOriginal(self)
Definition: scip.pxi:875
pyscipopt.scip.Model.getRowLPActivity
def getRowLPActivity(self, Row, row)
Definition: scip.pxi:2032
SCIPsetSolVal
SCIP_RETCODE SCIPsetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real val)
SCIPnodeGetNDomchg
void SCIPnodeGetNDomchg(SCIP_NODE *node, int *nbranchings, int *nconsprop, int *nprop)
SCIPgetNLPNlRows
SCIP_NLROW ** SCIPgetNLPNlRows(SCIP *scip)
SCIPchgVarUbProbing
SCIP_RETCODE SCIPchgVarUbProbing(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
SCIPgetOpenNodesData
SCIP_RETCODE SCIPgetOpenNodesData(SCIP *scip, SCIP_NODE ***leaves, SCIP_NODE ***children, SCIP_NODE ***siblings, int *nleaves, int *nchildren, int *nsiblings)
SCIPcalcNodeselPriority
SCIP_Real SCIPcalcNodeselPriority(SCIP *scip, SCIP_VAR *var, SCIP_BRANCHDIR branchdir, SCIP_Real targetvalue)
SCIPfrac
SCIP_Real SCIPfrac(SCIP *scip, SCIP_Real val)
SCIPflushRowExtensions
SCIP_RETCODE SCIPflushRowExtensions(SCIP *scip, SCIP_ROW *row)
SCIPcreateConsLinear
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)
pyscipopt.scip.Model.addExprNonlinear
def addExprNonlinear(self, Constraint, cons, Union[Expr, GenExpr] expr, float, coef)
Definition: scip.pxi:2650
pyscipopt.scip.Model.getGap
def getGap(self)
Definition: scip.pxi:1222
pyscipopt.scip.Row.getBasisStatus
def getBasisStatus(self)
Definition: scip.pxi:464
pyscipopt.scip.Model.isObjChangedProbing
def isObjChangedProbing(self)
Definition: scip.pxi:4478
pyscipopt.scip.Model.includeBranchrule
def includeBranchrule(self, Branchrule, branchrule, name, desc, priority, maxdepth, maxbounddist)
Definition: scip.pxi:4133
pyscipopt.scip.Model.isGT
def isGT(self, val1, val2)
Definition: scip.pxi:1290
SCIPcolGetPrimsol
SCIP_Real SCIPcolGetPrimsol(SCIP_COL *col)
SCIPgetNLeaves
int SCIPgetNLeaves(SCIP *scip)
pyscipopt.scip.Event.__hash__
def __hash__(self)
Definition: scip.pxi:359
pyscipopt.scip.Model.setCharParam
def setCharParam(self, name, value)
Definition: scip.pxi:5323
SCIPchgLhsNonlinear
SCIP_RETCODE SCIPchgLhsNonlinear(SCIP *scip, SCIP_CONS *cons, SCIP_Real lhs)
SCIPcreateConsSOS2
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)
pyscipopt.scip.Model.includeHeur
def includeHeur(self, Heur, heur, name, desc, dispchar, priority=10000, freq=1, freqofs=0, maxdepth=-1, timingmask=SCIP_HEURTIMING_BEFORENODE, usessubscip=False)
Definition: scip.pxi:4067
pyscipopt.scip.Model.includeBendersDefaultCuts
def includeBendersDefaultCuts(self, Benders, benders)
Definition: scip.pxi:3861
SCIPvarGetType
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
SCIPepsilon
SCIP_Real SCIPepsilon(SCIP *scip)
SCIProwIsIntegral
SCIP_Bool SCIProwIsIntegral(SCIP_ROW *row)
pyscipopt.scip.BoundChange.getNewBound
def getNewBound(self)
Definition: scip.pxi:656
pyscipopt.scip.Model._createConsGenNonlinear
def _createConsGenNonlinear(self, cons, **kwargs)
Definition: scip.pxi:2261
pyscipopt.scip.Solution.scip
scip
Definition: scip.pxi:601
pyscipopt.scip.Model.getLhs
def getLhs(self, Constraint, cons)
Definition: scip.pxi:3156
pyscipopt.scip.Model._createConsNonlinear
def _createConsNonlinear(self, cons, **kwargs)
Definition: scip.pxi:2206
SCIPenableReoptimization
SCIP_RETCODE SCIPenableReoptimization(SCIP *scip, SCIP_Bool enable)
pyscipopt.scip.NLRow.getDualsol
def getDualsol(self)
Definition: scip.pxi:576
pyscipopt.scip.Model.getNFeasibleLeaves
def getNFeasibleLeaves(self)
Definition: scip.pxi:1198
pyscipopt.scip.Model.getNSiblings
def getNSiblings(self)
Definition: scip.pxi:1214
pyscipopt.scip.Model.fixVarProbing
def fixVarProbing(self, Variable, var, fixedval)
Definition: scip.pxi:4474
SCIPnlrowGetName
const char * SCIPnlrowGetName(SCIP_NLROW *nlrow)
SCIPprintSol
SCIP_RETCODE SCIPprintSol(SCIP *scip, SCIP_SOL *sol, FILE *file, SCIP_Bool printzeros)
SCIPconsIsActive
SCIP_Bool SCIPconsIsActive(SCIP_CONS *cons)
pyscipopt.scip.Model.getRhs
def getRhs(self, Constraint, cons)
Definition: scip.pxi:3142
SCIPgetPrimalbound
SCIP_Real SCIPgetPrimalbound(SCIP *scip)
SCIPcreateConsXor
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)
pyscipopt.scip.Model.chgVarUbNode
def chgVarUbNode(self, Node, node, Variable, var, ub)
Definition: scip.pxi:1740
pyscipopt.scip.NLRow.__get__
def __get__(self)
Definition: scip.pxi:553
pyscipopt.scip.Statistics.n_presolved_implicit_integer_vars
def n_presolved_implicit_integer_vars(self)
Definition: scip.pxi:6068
SCIPnodeGetType
SCIP_NODETYPE SCIPnodeGetType(SCIP_NODE *node)
pyscipopt.scip.Model.getLocalEstimate
def getLocalEstimate(self, original=False)
Definition: scip.pxi:1434
pyscipopt.scip.Node.isPropagatedAgain
def isPropagatedAgain(self)
Definition: scip.pxi:754
pyscipopt.scip.Node.getLowerbound
def getLowerbound(self)
Definition: scip.pxi:725
pyscipopt.scip.Row.getConstant
def getConstant(self)
Definition: scip.pxi:456
pyscipopt.scip.Row
Definition: scip.pxi:432
pyscipopt.scip.Event.getVar
def getVar(self)
Definition: scip.pxi:344
SCIPgetVarStrongbranchInt
SCIP_RETCODE SCIPgetVarStrongbranchInt(SCIP *scip, SCIP_VAR *var, int itlim, SCIP_Bool idempotent, SCIP_Real *down, SCIP_Real *up, SCIP_Bool *downvalid, SCIP_Bool *upvalid, SCIP_Bool *downinf, SCIP_Bool *upinf, SCIP_Bool *downconflict, SCIP_Bool *upconflict, SCIP_Bool *lperror)
SCIPincludeProp
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)
pyscipopt.scip.Statistics.n_presolved_conss
def n_presolved_conss(self)
Definition: scip.pxi:6084
SCIPdropRowEvent
SCIP_RETCODE SCIPdropRowEvent(SCIP *scip, SCIP_ROW *row, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int filterpos)
SCIPreadProb
SCIP_RETCODE SCIPreadProb(SCIP *scip, const char *filename, const char *extension)
pyscipopt.scip.print_memory_in_use
def print_memory_in_use()
Definition: scip.pxi:6095
pyscipopt.scip.Model.computeBestSolSubproblems
def computeBestSolSubproblems(self)
Definition: scip.pxi:3615
SCIPlpiGetIterations
SCIP_RETCODE SCIPlpiGetIterations(SCIP_LPI *lpi, int *iterations)
SCIPchgVarLbProbing
SCIP_RETCODE SCIPchgVarLbProbing(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
pyscipopt.scip.Event.__class__
__class__
Definition: scip.pxi:363
pyscipopt.scip.Model.getConsVars
def getConsVars(self, Constraint, constraint)
Definition: scip.pxi:2617
pyscipopt.scip.Constraint.isDynamic
def isDynamic(self)
Definition: scip.pxi:958
SCIPgetNlRowActivityBounds
SCIP_RETCODE SCIPgetNlRowActivityBounds(SCIP *scip, SCIP_NLROW *nlrow, SCIP_Real *minactivity, SCIP_Real *maxactivity)
pyscipopt.scip.Model.lpiGetIterations
def lpiGetIterations(self)
Definition: scip.pxi:1314
pyscipopt.scip.Model.chgLhs
def chgLhs(self, Constraint, cons, lhs)
Definition: scip.pxi:3123
pyscipopt.scip.Model.getRowActivity
def getRowActivity(self, Row, row)
Definition: scip.pxi:2028
pyscipopt.scip.Model.getVarDict
def getVarDict(self)
Definition: scip.pxi:1823
pyscipopt.scip.Model.setObjlimit
def setObjlimit(self, objlimit)
Definition: scip.pxi:1332
SCIPcalcChildEstimate
SCIP_Real SCIPcalcChildEstimate(SCIP *scip, SCIP_VAR *var, SCIP_Real targetvalue)
pyscipopt.scip.Model.createProbBasic
def createProbBasic(self, problemName='model')
Definition: scip.pxi:1122
SCIProwGetLPPos
int SCIProwGetLPPos(SCIP_ROW *row)
SCIProwGetConstant
SCIP_Real SCIProwGetConstant(SCIP_ROW *row)
pyscipopt.scip.Model.solveConcurrent
def solveConcurrent(self)
Definition: scip.pxi:3563
pyscipopt.scip.Constraint.isNonlinear
def isNonlinear(self)
Definition: scip.pxi:979
pyscipopt.scip.Model.getNlRowSolFeasibility
def getNlRowSolFeasibility(self, NLRow, nlrow, Solution, sol=None)
Definition: scip.pxi:3312
pyscipopt.scip.Model.includePricer
def includePricer(self, Pricer, pricer, name, desc, priority=1, delay=True)
Definition: scip.pxi:3894
SCIPaddSol
SCIP_RETCODE SCIPaddSol(SCIP *scip, SCIP_SOL *sol, SCIP_Bool *stored)
pyscipopt.scip.Model.readSol
def readSol(self, filename)
Definition: scip.pxi:4708
SCIPbacktrackProbing
SCIP_RETCODE SCIPbacktrackProbing(SCIP *scip, int probingdepth)
pyscipopt.scip.Model.getTransformedVar
def getTransformedVar(self, Variable, var)
Definition: scip.pxi:1574
SCIPchgRowLhsDive
SCIP_RETCODE SCIPchgRowLhsDive(SCIP *scip, SCIP_ROW *row, SCIP_Real newlhs)
pyscipopt.scip.Model.getProbName
def getProbName(self)
Definition: scip.pxi:1166
SCIPcreateExprProduct
SCIP_RETCODE SCIPcreateExprProduct(SCIP *scip, SCIP_EXPR **expr, int nchildren, SCIP_EXPR **children, SCIP_Real coefficient, SCIP_DECL_EXPR_OWNERCREATE((*ownercreate)), void *ownercreatedata)
SCIProwGetOrigintype
SCIP_ROWORIGINTYPE SCIProwGetOrigintype(SCIP_ROW *row)
pyscipopt.scip.Model.isCutEfficacious
def isCutEfficacious(self, Row, cut, not, None, Solution, sol=None)
Definition: scip.pxi:2087
pyscipopt.scip.Model.writeParams
def writeParams(self, filename='param.set', comments=True, onlychanged=True, verbose=True)
Definition: scip.pxi:5439
SCIPprintCons
SCIP_RETCODE SCIPprintCons(SCIP *scip, SCIP_CONS *cons, FILE *file)
SCIPactivateBenders
SCIP_RETCODE SCIPactivateBenders(SCIP *scip, SCIP_BENDERS *benders, int nsubproblems)
pyscipopt.scip.Row.__eq__
def __eq__(self, other)
Definition: scip.pxi:537
pyscipopt.scip.Model.freeReoptSolve
def freeReoptSolve(self)
Definition: scip.pxi:5524
SCIProwGetDualsol
SCIP_Real SCIProwGetDualsol(SCIP_ROW *row)
SCIPaddLinearVarNonlinear
SCIP_RETCODE SCIPaddLinearVarNonlinear(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real coef)
pyscipopt.scip.Model.includeReader
def includeReader(self, Reader, reader, name, desc, ext)
Definition: scip.pxi:4021
pyscipopt.scip.Row.getLPPos
def getLPPos(self)
Definition: scip.pxi:460
SCIPincludeRelax
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)
SCIPgetSolvingTime
SCIP_Real SCIPgetSolvingTime(SCIP *scip)
SCIPisLT
SCIP_Bool SCIPisLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIPfixVarProbing
SCIP_RETCODE SCIPfixVarProbing(SCIP *scip, SCIP_VAR *var, SCIP_Real fixedval)
pyscipopt.scip.Constraint.scip_cons
scip_cons
Definition: scip.pxi:915
SCIPincludeCutsel
SCIP_RETCODE SCIPincludeCutsel(SCIP *scip, const char *name, const char *desc, int priority, SCIP_DECL_CUTSELCOPY((*cutselcopy)), SCIP_DECL_CUTSELFREE((*cutselfree)), SCIP_DECL_CUTSELINIT((*cutselinit)), SCIP_DECL_CUTSELEXIT((*cutselexit)), SCIP_DECL_CUTSELINITSOL((*cutselinitsol)), SCIP_DECL_CUTSELEXITSOL((*cutselexitsol)), SCIP_DECL_CUTSELSELECT((*cutselselect)), SCIP_CUTSELDATA *cutseldata)
pyscipopt.scip.Constraint.isPropagated
def isPropagated(self)
Definition: scip.pxi:946
SCIPgetNLPs
SCIP_Longint SCIPgetNLPs(SCIP *scip)
pyscipopt.scip.Event
Definition: scip.pxi:302
SCIPcreateExprSum
SCIP_RETCODE SCIPcreateExprSum(SCIP *scip, SCIP_EXPR **expr, int nchildren, SCIP_EXPR **children, SCIP_Real *coefficients, SCIP_Real constant, SCIP_DECL_EXPR_OWNERCREATE((*ownercreate)), void *ownercreatedata)
pyscipopt.scip.Column.isIntegral
def isIntegral(self)
Definition: scip.pxi:395
pyscipopt.scip.Variable.getObj
def getObj(self)
Definition: scip.pxi:895
SCIPappendVarSOS2
SCIP_RETCODE SCIPappendVarSOS2(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var)
pyscipopt.scip.Model.chgVarLbNode
def chgVarLbNode(self, Node, node, Variable, var, lb)
Definition: scip.pxi:1729
SCIPsetConsRemovable
SCIP_RETCODE SCIPsetConsRemovable(SCIP *scip, SCIP_CONS *cons, SCIP_Bool removable)
SCIPvarIsInLP
SCIP_Bool SCIPvarIsInLP(SCIP_VAR *var)
SCIPinRepropagation
SCIP_Bool SCIPinRepropagation(SCIP *scip)
SCIPsetupBendersSubproblem
SCIP_RETCODE SCIPsetupBendersSubproblem(SCIP *scip, SCIP_BENDERS *benders, SCIP_SOL *sol, int probnumber, SCIP_BENDERSENFOTYPE type)
pyscipopt.scip.Solution.__getitem__
def __getitem__(self, Expr, expr)
Definition: scip.pxi:604
SCIPconsIsSeparated
SCIP_Bool SCIPconsIsSeparated(SCIP_CONS *cons)
pyscipopt.scip.Model.chgVarLbDive
def chgVarLbDive(self, Variable, var, newbound)
Definition: scip.pxi:4373
pyscipopt.scip.NLRow
Definition: scip.pxi:541
pyscipopt.scip.Model._createConsQuadratic
def _createConsQuadratic(self, ExprCons, quadcons, **kwargs)
Definition: scip.pxi:2167
SCIPcheckSolOrig
SCIP_RETCODE SCIPcheckSolOrig(SCIP *scip, SCIP_SOL *sol, SCIP_Bool *feasible, SCIP_Bool printreason, SCIP_Bool completely)
SCIPincludePricer
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)
SCIPtightenVarLbGlobal
SCIP_RETCODE SCIPtightenVarLbGlobal(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound, SCIP_Bool force, SCIP_Bool *infeasible, SCIP_Bool *tightened)
SCIPcreateExprExp
SCIP_RETCODE SCIPcreateExprExp(SCIP *scip, SCIP_EXPR **expr, SCIP_EXPR *child, SCIP_DECL_EXPR_OWNERCREATE((*ownercreate)), void *ownercreatedata)
pyscipopt.scip.Model.setIntParam
def setIntParam(self, name, value)
Definition: scip.pxi:5293
SCIPfindHeur
SCIP_HEUR * SCIPfindHeur(SCIP *scip, const char *name)
SCIProwGetAge
int SCIProwGetAge(SCIP_ROW *row)
pyscipopt.scip.Model.getLPObjVal
def getLPObjVal(self)
Definition: scip.pxi:1911
SCIPchgVarLbDive
SCIP_RETCODE SCIPchgVarLbDive(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
pyscipopt.scip.Model.__class__
__class__
Definition: scip.pxi:1061
SCIPfindSepa
SCIP_SEPA * SCIPfindSepa(SCIP *scip, const char *name)
pyscipopt.scip.Column.getUb
def getUb(self)
Definition: scip.pxi:412
SCIPisFeasNegative
SCIP_Bool SCIPisFeasNegative(SCIP *scip, SCIP_Real val)
SCIPgetNLPIterations
SCIP_Longint SCIPgetNLPIterations(SCIP *scip)
pyscipopt.scip.Model.writeTransSol
def writeTransSol(self, Solution, solution, filename="transprob.sol", write_zeros=False)
Definition: scip.pxi:4687
SCIPaddExprNonlinear
SCIP_RETCODE SCIPaddExprNonlinear(SCIP *scip, SCIP_CONS *cons, SCIP_EXPR *expr, SCIP_Real coef)
pyscipopt.scip.Constraint.__eq__
def __eq__(self, other)
Definition: scip.pxi:992
SCIPvarGetUbLocal
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
SCIPgetLPBInvRow
SCIP_RETCODE SCIPgetLPBInvRow(SCIP *scip, int r, SCIP_Real *coefs, int *inds, int *ninds)
SCIPgetNIntVars
int SCIPgetNIntVars(SCIP *scip)
SCIPisNLPConstructed
SCIP_Bool SCIPisNLPConstructed(SCIP *scip)
SCIPgetNReaders
int SCIPgetNReaders(SCIP *scip)
SCIPisFeasZero
SCIP_Bool SCIPisFeasZero(SCIP *scip, SCIP_Real val)
pyscipopt.expr.expr_to_nodes
def expr_to_nodes(expr)
Definition: expr.pxi:639
pyscipopt.scip.Model.setMaximize
def setMaximize(self)
Definition: scip.pxi:1328
SCIPgetLocalTransEstimate
SCIP_Real SCIPgetLocalTransEstimate(SCIP *scip)
SCIPdelVar
SCIP_RETCODE SCIPdelVar(SCIP *scip, SCIP_VAR *var, SCIP_Bool *deleted)
pyscipopt.scip.Model.getBipartiteGraphRepresentation
def getBipartiteGraphRepresentation(self, prev_col_features=None, prev_edge_features=None, prev_row_features=None, static_only=False, suppress_warnings=False)
Definition: scip.pxi:5702
pyscipopt.scip.Node.getNumber
def getNumber(self)
Definition: scip.pxi:713
SCIPversion
SCIP_Real SCIPversion(void)
SCIPgetNBinVars
int SCIPgetNBinVars(SCIP *scip)
SCIPinProbing
SCIP_Bool SCIPinProbing(SCIP *scip)
pyscipopt.scip.Model.addObjoffset
def addObjoffset(self, offset, solutions=False)
Definition: scip.pxi:1401
SCIProwGetVals
SCIP_Real * SCIProwGetVals(SCIP_ROW *row)
pyscipopt.scip.Model.getSolVal
def getSolVal(self, Solution, sol, Expr, expr)
Definition: scip.pxi:4912
SCIPchgVarType
SCIP_RETCODE SCIPchgVarType(SCIP *scip, SCIP_VAR *var, SCIP_VARTYPE vartype, SCIP_Bool *infeasible)
pyscipopt.scip.Row.__hash__
def __hash__(self)
Definition: scip.pxi:534
SCIPreleaseRow
SCIP_RETCODE SCIPreleaseRow(SCIP *scip, SCIP_ROW **row)
SCIPreleaseCons
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
pyscipopt.scip.Model.version
def version(self)
Definition: scip.pxi:1144
SCIPprintStatistics
SCIP_RETCODE SCIPprintStatistics(SCIP *scip, FILE *file)
SCIPgetConss
SCIP_CONS ** SCIPgetConss(SCIP *scip)
SCIPconsIsEnforced
SCIP_Bool SCIPconsIsEnforced(SCIP_CONS *cons)
SCIPsetObjlimit
SCIP_RETCODE SCIPsetObjlimit(SCIP *scip, SCIP_Real objlimit)
SCIPgetBendersSubproblemVar
SCIP_RETCODE SCIPgetBendersSubproblemVar(SCIP *scip, SCIP_BENDERS *benders, SCIP_VAR *var, SCIP_VAR **mappedvar, int probnumber)
SCIPwriteOrigProblem
SCIP_RETCODE SCIPwriteOrigProblem(SCIP *scip, const char *filename, const char *extension, SCIP_Bool genericnames)
SCIPincludeHeur
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)
pyscipopt.scip.Model.readSolFile
def readSolFile(self, filename)
Definition: scip.pxi:4722
SCIPgetSlackVarIndicator
SCIP_VAR * SCIPgetSlackVarIndicator(SCIP_CONS *cons)
pyscipopt.scip.Model.printExternalCodeVersions
def printExternalCodeVersions(self)
Definition: scip.pxi:1157
SCIPgetNNodes
SCIP_Longint SCIPgetNNodes(SCIP *scip)
SCIPcolGetBasisStatus
SCIP_BASESTAT SCIPcolGetBasisStatus(SCIP_COL *col)
SCIPeventGetRow
SCIP_ROW * SCIPeventGetRow(SCIP_EVENT *event)
pyscipopt.scip.Model.tightenVarUbGlobal
def tightenVarUbGlobal(self, Variable, var, ub, force=False)
Definition: scip.pxi:1653
SCIPvarGetUbOriginal
SCIP_Real SCIPvarGetUbOriginal(SCIP_VAR *var)
SCIPaddConsLocal
SCIP_RETCODE SCIPaddConsLocal(SCIP *scip, SCIP_CONS *cons, SCIP_NODE *validnode)
SCIPgetRowObjParallelism
SCIP_Real SCIPgetRowObjParallelism(SCIP *scip, SCIP_ROW *row)
SCIPfreeReoptSolve
SCIP_RETCODE SCIPfreeReoptSolve(SCIP *scip)
pyscipopt.scip.Model.setSeparating
def setSeparating(self, setting)
Definition: scip.pxi:1458
SCIPaddRow
SCIP_RETCODE SCIPaddRow(SCIP *scip, SCIP_ROW *row, SCIP_Bool forcecut, SCIP_Bool *infeasible)
pyscipopt.scip.Model.addVarLocks
def addVarLocks(self, Variable, var, nlocksdown, nlocksup)
Definition: scip.pxi:1585
pyscipopt.scip.NLRow.__hash__
def __hash__(self)
Definition: scip.pxi:580
SCIPeventGetType
SCIP_EVENTTYPE SCIPeventGetType(SCIP_EVENT *event)
pyscipopt.scip.Row.__get__
def __get__(self)
Definition: scip.pxi:444
SCIPsolveProbingLP
SCIP_RETCODE SCIPsolveProbingLP(SCIP *scip, int itlim, SCIP_Bool *lperror, SCIP_Bool *cutoff)
SCIPfixVar
SCIP_RETCODE SCIPfixVar(SCIP *scip, SCIP_VAR *var, SCIP_Real fixedval, SCIP_Bool *infeasible, SCIP_Bool *fixed)
SCIPaddVarLocks
SCIP_RETCODE SCIPaddVarLocks(SCIP *scip, SCIP_VAR *var, int nlocksdown, int nlocksup)
pyscipopt.scip.Model.getConss
def getConss(self, transformed=True)
Definition: scip.pxi:3414
pyscipopt.scip.Model.getSolObjVal
def getSolObjVal(self, Solution, sol, original=True)
Definition: scip.pxi:4863
pyscipopt.scip.Row.getCols
def getCols(self)
Definition: scip.pxi:516
SCIPcreateEmptyRowUnspec
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)
SCIPfindBenderscut
SCIP_BENDERSCUT * SCIPfindBenderscut(SCIP_BENDERS *benders, const char *name)
SCIPgetObjsense
SCIP_OBJSENSE SCIPgetObjsense(SCIP *scip)
pyscipopt.scip.Column.__hash__
def __hash__(self)
Definition: scip.pxi:425
pyscipopt.scip.Statistics.n_vars
def n_vars(self)
Definition: scip.pxi:6036
pyscipopt.scip.Model.updateNodeLowerbound
def updateNodeLowerbound(self, Node, node, lb)
Definition: scip.pxi:1830
SCIPchgVarUbDive
SCIP_RETCODE SCIPchgVarUbDive(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
SCIPsetCharParam
SCIP_RETCODE SCIPsetCharParam(SCIP *scip, const char *name, char value)
SCIPgetTransObjoffset
SCIP_Real SCIPgetTransObjoffset(SCIP *scip)
SCIPgetNFeasibleLeaves
SCIP_Longint SCIPgetNFeasibleLeaves(SCIP *scip)
pyscipopt.scip.Model.includeEventhdlr
def includeEventhdlr(self, Eventhdlr, eventhdlr, name, desc)
Definition: scip.pxi:3870
pyscipopt.scip.Model.printSol
def printSol(self, Solution, solution=None, write_zeros=False)
Definition: scip.pxi:4613
SCIProwIsRemovable
SCIP_Bool SCIProwIsRemovable(SCIP_ROW *row)
pyscipopt.scip.Model.getRowDualSol
def getRowDualSol(self, Row, row)
Definition: scip.pxi:2074
SCIPchgCoefLinear
SCIP_RETCODE SCIPchgCoefLinear(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real val)
pyscipopt.scip.Model.getBestSibling
def getBestSibling(self)
Definition: scip.pxi:1853
pyscipopt.scip.Event.getType
def getType(self)
Definition: scip.pxi:313
SCIPnewProbingNode
SCIP_RETCODE SCIPnewProbingNode(SCIP *scip)
pyscipopt.scip.Model.getDualMultiplier
def getDualMultiplier(self, Constraint, cons)
Definition: scip.pxi:3504
pyscipopt.scip.Model.includeConshdlr
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)
Definition: scip.pxi:3916
pyscipopt.scip.Solution
Definition: scip.pxi:587
SCIPsolveBendersSubproblem
SCIP_RETCODE SCIPsolveBendersSubproblem(SCIP *scip, SCIP_BENDERS *benders, SCIP_SOL *sol, int probnumber, SCIP_Bool *infeasible, SCIP_Bool solvecip, SCIP_Real *objective)
pyscipopt.scip.Model.getNLPs
def getNLPs(self)
Definition: scip.pxi:5246
SCIProwIsModifiable
SCIP_Bool SCIProwIsModifiable(SCIP_ROW *row)
SCIProwGetNorm
SCIP_Real SCIProwGetNorm(SCIP_ROW *row)
pyscipopt.scip.Model.tightenVarLbGlobal
def tightenVarLbGlobal(self, Variable, var, lb, force=False)
Definition: scip.pxi:1669
pyscipopt.scip.Model.getTermsQuadratic
def getTermsQuadratic(self, Constraint, cons)
Definition: scip.pxi:3347
SCIPgetValsLinear
SCIP_Real * SCIPgetValsLinear(SCIP *scip, SCIP_CONS *cons)
SCIPgetOrigVars
SCIP_VAR ** SCIPgetOrigVars(SCIP *scip)
SCIPaddRowDive
SCIP_RETCODE SCIPaddRowDive(SCIP *scip, SCIP_ROW *row)
pyscipopt.scip.Variable
Definition: scip.pxi:816
SCIPconsIsStickingAtNode
SCIP_Bool SCIPconsIsStickingAtNode(SCIP_CONS *cons)
SCIPgetExprNonlinear
SCIP_EXPR * SCIPgetExprNonlinear(SCIP_CONS *cons)
pyscipopt.scip.Model.startProbing
def startProbing(self)
Definition: scip.pxi:4424
pyscipopt.scip.Model.delConsLocal
def delConsLocal(self, Constraint, cons)
Definition: scip.pxi:3446
pyscipopt.scip.Model.newProbingNode
def newProbingNode(self)
Definition: scip.pxi:4434
pyscipopt.scip.Model.addBendersSubproblem
def addBendersSubproblem(self, Benders, benders, subproblem)
Definition: scip.pxi:3686
pyscipopt.scip.Model.getVarStrongbranchNode
def getVarStrongbranchNode(self, Variable, var)
Definition: scip.pxi:5622
SCIPreleaseExpr
SCIP_RETCODE SCIPreleaseExpr(SCIP *scip, SCIP_EXPR **expr)
pyscipopt.scip.Model.solveProbingLP
def solveProbingLP(self, itlim=-1)
Definition: scip.pxi:4486
pyscipopt.scip.Model._freescip
_freescip
Definition: scip.pxi:1028
pyscipopt.scip.Model.getNCuts
def getNCuts(self)
Definition: scip.pxi:2101
pyscipopt.scip.Model.chgCoefLinear
def chgCoefLinear(self, Constraint, cons, Variable, var, value)
Definition: scip.pxi:3170
SCIPappendVarSOS1
SCIP_RETCODE SCIPappendVarSOS1(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var)
pyscipopt.scip.Model.isFeasIntegral
def isFeasIntegral(self, value)
Definition: scip.pxi:1266
pyscipopt.scip.BoundChange.__repr__
def __repr__(self)
Definition: scip.pxi:676
SCIPaddCoefLinear
SCIP_RETCODE SCIPaddCoefLinear(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real val)
SCIPsetRelaxSolVal
SCIP_RETCODE SCIPsetRelaxSolVal(SCIP *scip, SCIP_RELAX *relax, SCIP_VAR *var, SCIP_Real val)
SCIPsetProbName
SCIP_RETCODE SCIPsetProbName(SCIP *scip, const char *name)
pyscipopt.scip.Node.getParentBranchings
def getParentBranchings(self)
Definition: scip.pxi:772
SCIPgetOrigObjoffset
SCIP_Real SCIPgetOrigObjoffset(SCIP *scip)
pyscipopt.scip.Model.writeStatistics
def writeStatistics(self, filename="origprob.stats")
Definition: scip.pxi:5138
pyscipopt.scip.BoundChange.isRedundant
def isRedundant(self)
Definition: scip.pxi:672
pyscipopt.scip.Model.getNLPCols
def getNLPCols(self)
Definition: scip.pxi:1936
pyscipopt.scip.Model.setObjective
def setObjective(self, expr, sense='minimize', clear='true')
Definition: scip.pxi:1345
SCIPgetDualsolLinear
SCIP_Real SCIPgetDualsolLinear(SCIP *scip, SCIP_CONS *cons)
SCIPgetNNLPNlRows
int SCIPgetNNLPNlRows(SCIP *scip)
SCIPisFeasEQ
SCIP_Bool SCIPisFeasEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIProwGetNNonz
int SCIProwGetNNonz(SCIP_ROW *row)
pyscipopt.scip.Model.getRowParallelism
def getRowParallelism(self, Row, row1, Row, row2, orthofunc=101)
Definition: scip.pxi:2068
pyscipopt.scip.Model.isEQ
def isEQ(self, val1, val2)
Definition: scip.pxi:1270
pyscipopt.scip.Model.hasPrimalRay
def hasPrimalRay(self)
Definition: scip.pxi:4944
SCIPnodeIsPropagatedAgain
SCIP_Bool SCIPnodeIsPropagatedAgain(SCIP_NODE *node)
pyscipopt.scip.Model.releaseRow
def releaseRow(self, Row, row, not, None)
Definition: scip.pxi:2037
pyscipopt.scip.Model.getBestChild
def getBestChild(self)
Definition: scip.pxi:1849
pyscipopt.scip.Model.getCurrentNode
def getCurrentNode(self)
Definition: scip.pxi:1218
SCIPhasPrimalRay
SCIP_Bool SCIPhasPrimalRay(SCIP *scip)
SCIPprintBestSol
SCIP_RETCODE SCIPprintBestSol(SCIP *scip, FILE *file, SCIP_Bool printzeros)
SCIPgetNVars
int SCIPgetNVars(SCIP *scip)
pyscipopt.scip.Model._bestSol
_bestSol
Definition: scip.pxi:1072
pyscipopt.scip.Constraint.isStickingAtNode
def isStickingAtNode(self)
Definition: scip.pxi:966
SCIPsetHeuristics
SCIP_RETCODE SCIPsetHeuristics(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
pyscipopt.scip.Model.dropVarEvent
def dropVarEvent(self, Variable, var, eventtype, Eventhdlr, eventhdlr)
Definition: scip.pxi:5097
pyscipopt.scip.Event._getEventNames
def _getEventNames(self)
Definition: scip.pxi:323
pyscipopt.scip.Model.getNTotalNodes
def getNTotalNodes(self)
Definition: scip.pxi:1194
pyscipopt.scip.Model.getCondition
def getCondition(self, exact=False)
Definition: scip.pxi:1294
pyscipopt.scip.Model.getBendersAuxiliaryVar
def getBendersAuxiliaryVar(self, probnumber, Benders, benders=None)
Definition: scip.pxi:3814
pyscipopt.scip.Model.chgReoptObjective
def chgReoptObjective(self, coeffs, sense='minimize')
Definition: scip.pxi:5528
pyscipopt.scip.Model.addConsOr
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)
Definition: scip.pxi:2820
pyscipopt.scip.Node.getNDomchg
def getNDomchg(self)
Definition: scip.pxi:794
pyscipopt.scip.Model.printBestSol
def printBestSol(self, write_zeros=False)
Definition: scip.pxi:4604
SCIPnlrowGetNLinearVars
int SCIPnlrowGetNLinearVars(SCIP_NLROW *nlrow)
pyscipopt.scip.Model.isZero
def isZero(self, value)
Definition: scip.pxi:1250
SCIPgetBestChild
SCIP_NODE * SCIPgetBestChild(SCIP *scip)
SCIPcolGetLb
SCIP_Real SCIPcolGetLb(SCIP_COL *col)
pyscipopt.scip.Model.addConsNode
def addConsNode(self, Node, node, Constraint, cons, Node, validnode=None)
Definition: scip.pxi:2676
pyscipopt.scip.Model.isLT
def isLT(self, val1, val2)
Definition: scip.pxi:1282
pyscipopt.scip.Model.chgRhs
def chgRhs(self, Constraint, cons, rhs)
Definition: scip.pxi:3104
SCIPvarGetUbGlobal
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
pyscipopt.scip.Model.getVarStrongbranchLast
def getVarStrongbranchLast(self, Variable, var)
Definition: scip.pxi:5597
pyscipopt.scip.Model.applyCutsProbing
def applyCutsProbing(self)
Definition: scip.pxi:4500
pyscipopt.scip.Model.readProblem
def readProblem(self, filename, extension=None)
Definition: scip.pxi:5481
pyscipopt.scip.Model._createConsLinear
def _createConsLinear(self, ExprCons, lincons, **kwargs)
Definition: scip.pxi:2137
SCIPwriteParams
SCIP_RETCODE SCIPwriteParams(SCIP *scip, const char *filename, SCIP_Bool comments, SCIP_Bool onlychanged)
pyscipopt.scip.Solution.__repr__
def __repr__(self)
Definition: scip.pxi:622
pyscipopt.scip.Model.backtrackProbing
def backtrackProbing(self, probingdepth)
Definition: scip.pxi:4440
SCIPchgVarUbNode
SCIP_RETCODE SCIPchgVarUbNode(SCIP *scip, SCIP_NODE *node, SCIP_VAR *var, SCIP_Real newbound)
pyscipopt.scip.Column.getAge
def getAge(self)
Definition: scip.pxi:420
SCIPgetNInfeasibleLeaves
SCIP_Longint SCIPgetNInfeasibleLeaves(SCIP *scip)
pyscipopt.scip.Model.getPrimalRay
def getPrimalRay(self)
Definition: scip.pxi:4958
pyscipopt.scip.Model.chgVarType
def chgVarType(self, Variable, var, vtype)
Definition: scip.pxi:1751
pyscipopt.scip.Model.getColRedCost
def getColRedCost(self, Column, col)
Definition: scip.pxi:1983
pyscipopt.scip.Model.getNLeaves
def getNLeaves(self)
Definition: scip.pxi:1206
pyscipopt.scip.Model.isLPSolBasic
def isLPSolBasic(self)
Definition: scip.pxi:1972
SCIPcopyOrig
SCIP_RETCODE SCIPcopyOrig(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, const char *suffix, SCIP_Bool enablepricing, SCIP_Bool threadsafe, SCIP_Bool passmessagehdlr, SCIP_Bool *valid)
pyscipopt.scip.Model.appendVarSOS1
def appendVarSOS1(self, Constraint, cons, Variable, var)
Definition: scip.pxi:3040
SCIPsetStringParam
SCIP_RETCODE SCIPsetStringParam(SCIP *scip, const char *name, const char *value)
pyscipopt.scip.Model.getStatus
def getStatus(self)
Definition: scip.pxi:5015
pyscipopt.scip.NLRow.getLinearTerms
def getLinearTerms(self)
Definition: scip.pxi:561
SCIPgetSolVal
SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
pyscipopt.scip.Constraint.isModifiable
def isModifiable(self)
Definition: scip.pxi:954
SCIPsetParamsCountsols
SCIP_RETCODE SCIPsetParamsCountsols(SCIP *scip)
pyscipopt.scip.NLRow.getConstant
def getConstant(self)
Definition: scip.pxi:557
SCIPgetNVarsLinear
int SCIPgetNVarsLinear(SCIP *scip, SCIP_CONS *cons)
pyscipopt.scip.Model.getRowNumIntCols
def getRowNumIntCols(self, Row, row)
Definition: scip.pxi:2060
SCIPgetCutLPSolCutoffDistance
SCIP_Real SCIPgetCutLPSolCutoffDistance(SCIP *scip, SCIP_SOL *sol, SCIP_ROW *cut)
pyscipopt.scip.Model.addPoolCut
def addPoolCut(self, Row, row, not, None)
Definition: scip.pxi:2079
SCIPvarGetCol
SCIP_COL * SCIPvarGetCol(SCIP_VAR *var)
SCIPchgReoptObjective
SCIP_RETCODE SCIPchgReoptObjective(SCIP *scip, SCIP_OBJSENSE objsense, SCIP_VAR **vars, SCIP_Real *coefs, int nvars)
SCIPgetRowActivity
SCIP_Real SCIPgetRowActivity(SCIP *scip, SCIP_ROW *row)
SCIPvarIsOriginal
SCIP_Bool SCIPvarIsOriginal(SCIP_VAR *var)
pyscipopt.scip.Model.chgVarLbGlobal
def chgVarLbGlobal(self, Variable, var, lb)
Definition: scip.pxi:1707
SCIPgetDualfarkasLinear
SCIP_Real SCIPgetDualfarkasLinear(SCIP *scip, SCIP_CONS *cons)
SCIPgetSols
SCIP_SOL ** SCIPgetSols(SCIP *scip)
pyscipopt.scip.Model.setEmphasis
def setEmphasis(self, paraemphasis, quiet=True)
Definition: scip.pxi:5472
pyscipopt.scip.Model.createPartialSol
def createPartialSol(self, Heur, heur=None)
Definition: scip.pxi:4568
pyscipopt.scip.Model.count
def count(self)
Definition: scip.pxi:5502
SCIPcolGetVar
SCIP_VAR * SCIPcolGetVar(SCIP_COL *col)
SCIPsetLongintParam
SCIP_RETCODE SCIPsetLongintParam(SCIP *scip, const char *name, SCIP_Longint value)
SCIPcreateExprVar
SCIP_RETCODE SCIPcreateExprVar(SCIP *scip, SCIP_EXPR **expr, SCIP_VAR *var, SCIP_DECL_EXPR_OWNERCREATE((*ownercreate)), void *ownercreatedata)
pyscipopt.scip.Model.inProbing
def inProbing(self)
Definition: scip.pxi:4482
SCIPnodeGetParentBranchings
void SCIPnodeGetParentBranchings(SCIP_NODE *node, SCIP_VAR **branchvars, SCIP_Real *branchbounds, SCIP_BOUNDTYPE *boundtypes, int *nbranchvars, int branchvarssize)
pyscipopt.scip.Model.getSolvingTime
def getSolvingTime(self)
Definition: scip.pxi:1174
pyscipopt.scip.Model.chgVarUb
def chgVarUb(self, Variable, var, ub)
Definition: scip.pxi:1696
pyscipopt.scip.Model.setParamsCountsols
def setParamsCountsols(self)
Definition: scip.pxi:5520
pyscipopt.scip.Model.getNReaders
def getNReaders(self)
Definition: scip.pxi:5506
SCIPcreateExprSin
SCIP_RETCODE SCIPcreateExprSin(SCIP *scip, SCIP_EXPR **expr, SCIP_EXPR *child, SCIP_DECL_EXPR_OWNERCREATE((*ownercreate)), void *ownercreatedata)
pyscipopt.scip.Constraint.getConshdlrName
def getConshdlrName(self)
Definition: scip.pxi:984
SCIPgetVarExprVar
SCIP_VAR * SCIPgetVarExprVar(SCIP_EXPR *expr)
SCIPgetNSols
int SCIPgetNSols(SCIP *scip)
SCIPsetRealParam
SCIP_RETCODE SCIPsetRealParam(SCIP *scip, const char *name, SCIP_Real value)
SCIPgetLPRows
SCIP_ROW ** SCIPgetLPRows(SCIP *scip)
SCIPupdateVarPseudocost
SCIP_RETCODE SCIPupdateVarPseudocost(SCIP *scip, SCIP_VAR *var, SCIP_Real solvaldelta, SCIP_Real objdelta, SCIP_Real weight)
pyscipopt.scip.Model.chgVarBranchPriority
def chgVarBranchPriority(self, Variable, var, priority)
Definition: scip.pxi:5574
pyscipopt.scip.Variable.getUbGlobal
def getUbGlobal(self)
Definition: scip.pxi:883
SCIPresetParam
SCIP_RETCODE SCIPresetParam(SCIP *scip, const char *name)
pyscipopt.scip.Solution.__setitem__
def __setitem__(self, Variable, var, value)
Definition: scip.pxi:619
SCIPisGE
SCIP_Bool SCIPisGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIPcolGetObj
SCIP_Real SCIPcolGetObj(SCIP_COL *col)
pyscipopt.scip.Model.addRowDive
def addRowDive(self, Row, row)
Definition: scip.pxi:4401
pyscipopt.scip.Model.relax
def relax(self)
Definition: scip.pxi:1840
pyscipopt.scip.Model.printCons
def printCons(self, Constraint, constraint)
Definition: scip.pxi:2645
pyscipopt.scip.Model.writeSol
def writeSol(self, Solution, solution, filename="origprob.sol", write_zeros=False)
Definition: scip.pxi:4668
SCIPgetLPSolstat
SCIP_LPSOLSTAT SCIPgetLPSolstat(SCIP *scip)
SCIPfree
SCIP_RETCODE SCIPfree(SCIP **scip)
pyscipopt.scip.Model.getVal
def getVal(self, Expr, expr)
Definition: scip.pxi:4929
pyscipopt.scip.Model.repropagateNode
def repropagateNode(self, Node, node)
Definition: scip.pxi:1889
SCIPchgLhsLinear
SCIP_RETCODE SCIPchgLhsLinear(SCIP *scip, SCIP_CONS *cons, SCIP_Real lhs)
SCIPnodeGetAddedConss
void SCIPnodeGetAddedConss(SCIP_NODE *node, SCIP_CONS **addedconss, int *naddedconss, int addedconsssize)
pyscipopt.scip.Model.printVersion
def printVersion(self)
Definition: scip.pxi:1148
SCIPfindEventhdlr
SCIP_EVENTHDLR * SCIPfindEventhdlr(SCIP *scip, const char *name)
pyscipopt.scip.Model.includePresol
def includePresol(self, Presol, presol, name, desc, priority, maxrounds, timing=SCIP_PRESOLTIMING_FAST)
Definition: scip.pxi:3982
pyscipopt.scip.Model.__eq__
def __eq__(self, other)
Definition: scip.pxi:1060
pyscipopt.scip.Statistics.n_implicit_integer_vars
def n_implicit_integer_vars(self)
Definition: scip.pxi:6048
SCIPgetDepth
int SCIPgetDepth(SCIP *scip)
pyscipopt.scip.Model.getNCutsApplied
def getNCutsApplied(self)
Definition: scip.pxi:2105
SCIPcolIsIntegral
SCIP_Bool SCIPcolIsIntegral(SCIP_COL *col)
SCIPvarGetIndex
int SCIPvarGetIndex(SCIP_VAR *var)
pyscipopt.scip.Model.getDualbound
def getDualbound(self)
Definition: scip.pxi:4977
pyscipopt.scip.Model.solveDiveLP
def solveDiveLP(self, itlim=-1)
Definition: scip.pxi:4405
SCIPsolveDiveLP
SCIP_RETCODE SCIPsolveDiveLP(SCIP *scip, int itlim, SCIP_Bool *lperror, SCIP_Bool *cutoff)
pyscipopt.scip.Model.setMinimize
def setMinimize(self)
Definition: scip.pxi:1324
pyscipopt.scip.Model.printStatistics
def printStatistics(self)
Definition: scip.pxi:5129
SCIPseparateSol
SCIP_RETCODE SCIPseparateSol(SCIP *scip, SCIP_SOL *sol, SCIP_Bool pretendroot, SCIP_Bool allowlocal, SCIP_Bool onlydelayed, SCIP_Bool *delayed, SCIP_Bool *cutoff)
SCIPgetPresolvingTime
SCIP_Real SCIPgetPresolvingTime(SCIP *scip)
SCIPgetPseudoBranchCands
SCIP_RETCODE SCIPgetPseudoBranchCands(SCIP *scip, SCIP_VAR ***pseudocands, int *npseudocands, int *npriopseudocands)
pyscipopt.scip.Row.__class__
__class__
Definition: scip.pxi:538
SCIProwGetLhs
SCIP_Real SCIProwGetLhs(SCIP_ROW *row)
SCIPgetNLimSolsFound
SCIP_Longint SCIPgetNLimSolsFound(SCIP *scip)
pyscipopt.scip.Model.addCut
def addCut(self, Row, cut, not, None, forcecut=False)
Definition: scip.pxi:2095
pyscipopt.scip.Solution._checkStage
def _checkStage(self, method)
Definition: scip.pxi:637
pyscipopt.scip.Model.isGE
def isGE(self, val1, val2)
Definition: scip.pxi:1286
pyscipopt.scip.Model.getProbingDepth
def getProbingDepth(self)
Definition: scip.pxi:4446
SCIPgetBenders
SCIP_BENDERS ** SCIPgetBenders(SCIP *scip)
pyscipopt.scip.Model.chgVarUbProbing
def chgVarUbProbing(self, Variable, var, ub)
Definition: scip.pxi:4464
SCIPconsIsOriginal
SCIP_Bool SCIPconsIsOriginal(SCIP_CONS *cons)
pyscipopt.scip.Variable.getLbLocal
def getLbLocal(self)
Definition: scip.pxi:887
pyscipopt.scip.Model.getVarRedcost
def getVarRedcost(self, Variable, var)
Definition: scip.pxi:3526
SCIPgetNSolsFound
SCIP_Longint SCIPgetNSolsFound(SCIP *scip)
SCIPgetLPI
SCIP_RETCODE SCIPgetLPI(SCIP *scip, SCIP_LPI **lpi)
SCIPincludePresol
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)
pyscipopt.scip.Model.initBendersDefault
def initBendersDefault(self, subproblems)
Definition: scip.pxi:3579
pyscipopt.scip.Model.activateBenders
def activateBenders(self, Benders, benders, int, nsubproblems)
Definition: scip.pxi:3677
SCIPgetNegatedVar
SCIP_RETCODE SCIPgetNegatedVar(SCIP *scip, SCIP_VAR *var, SCIP_VAR **negvar)
pyscipopt.scip.Model.delCons
def delCons(self, Constraint, cons)
Definition: scip.pxi:3438
SCIPchgVarObjDive
SCIP_RETCODE SCIPchgVarObjDive(SCIP *scip, SCIP_VAR *var, SCIP_Real newobj)
SCIPconstructLP
SCIP_RETCODE SCIPconstructLP(SCIP *scip, SCIP_Bool *cutoff)
pyscipopt.scip.Model.writeLP
def writeLP(self, filename="LP.lp")
Definition: scip.pxi:4538
pyscipopt.scip.Row.isLocal
def isLocal(self)
Definition: scip.pxi:483
pyscipopt.scip.Model.getSlackVarIndicator
def getSlackVarIndicator(self, Constraint, cons)
Definition: scip.pxi:3012
pyscipopt.scip.Constraint.isRemovable
def isRemovable(self)
Definition: scip.pxi:962
pyscipopt.scip.Model.getParams
def getParams(self)
Definition: scip.pxi:5404
pyscipopt.scip.Statistics.n_conss
def n_conss(self)
Definition: scip.pxi:6076
pyscipopt.scip.Constraint.isLocal
def isLocal(self)
Definition: scip.pxi:950
pyscipopt.scip.Model.addConsLocal
def addConsLocal(self, Constraint, cons, Node, validnode=None)
Definition: scip.pxi:2690
SCIPsetConsInitial
SCIP_RETCODE SCIPsetConsInitial(SCIP *scip, SCIP_CONS *cons, SCIP_Bool initial)
pyscipopt.scip.Row.getRhs
def getRhs(self)
Definition: scip.pxi:452
pyscipopt.scip.Column.getVar
def getVar(self)
Definition: scip.pxi:399
pyscipopt.scip.Model.isFeasZero
def isFeasZero(self, value)
Definition: scip.pxi:1254
pyscipopt.scip.Model.getVarStrongbranch
def getVarStrongbranch(self, Variable, var, itlim, idempotent=False, integral=False)
Definition: scip.pxi:5633