PySCIPOpt  5.1.1
Python Interface for the SCIP Optimization Suite
expr.pxi
Go to the documentation of this file.
1 
45 
46 
47 def _is_number(e):
48  try:
49  f = float(e)
50  return True
51  except ValueError: # for malformed strings
52  return False
53  except TypeError: # for other types (Variable, Expr)
54  return False
55 
56 
57 def _expr_richcmp(self, other, op):
58  if op == 1: # <=
59  if isinstance(other, Expr) or isinstance(other, GenExpr):
60  return (self - other) <= 0.0
61  elif _is_number(other):
62  return ExprCons(self, rhs=float(other))
63  else:
64  raise NotImplementedError
65  elif op == 5: # >=
66  if isinstance(other, Expr) or isinstance(other, GenExpr):
67  return (self - other) >= 0.0
68  elif _is_number(other):
69  return ExprCons(self, lhs=float(other))
70  else:
71  raise NotImplementedError
72  elif op == 2: # ==
73  if isinstance(other, Expr) or isinstance(other, GenExpr):
74  return (self - other) == 0.0
75  elif _is_number(other):
76  return ExprCons(self, lhs=float(other), rhs=float(other))
77  else:
78  raise NotImplementedError
79  else:
80  raise NotImplementedError("Can only support constraints with '<=', '>=', or '=='.")
81 
82 
83 class Term:
84  '''This is a monomial term'''
85 
86  __slots__ = ('vartuple', 'ptrtuple', 'hashval')
87 
88  def __init__(self, *vartuple):
89  self.vartuple = tuple(sorted(vartuple, key=lambda v: v.ptr()))
90  self.ptrtuple = tuple(v.ptr() for v in self.vartuple)
91  self.hashval = sum(self.ptrtuple)
92 
93  def __getitem__(self, idx):
94  return self.vartuple[idx]
95 
96  def __hash__(self):
97  return self.hashval
98 
99  def __eq__(self, other):
100  return self.ptrtuple == other.ptrtuple
101 
102  def __len__(self):
103  return len(self.vartuple)
104 
105  def __add__(self, other):
106  both = self.vartuple + other.vartuple
107  return Term(*both)
108 
109  def __repr__(self):
110  return 'Term(%s)' % ', '.join([str(v) for v in self.vartuple])
111 
112 
113 CONST = Term()
114 
115 # helper function
116 def buildGenExprObj(expr):
117  """helper function to generate an object of type GenExpr"""
118  if _is_number(expr):
119  return Constant(expr)
120  elif isinstance(expr, Expr):
121  # loop over terms and create a sumexpr with the sum of each term
122  # each term is either a variable (which gets transformed into varexpr)
123  # or a product of variables (which gets tranformed into a prod)
124  sumexpr = SumExpr()
125  for vars, coef in expr.terms.items():
126  if len(vars) == 0:
127  sumexpr += coef
128  elif len(vars) == 1:
129  varexpr = VarExpr(vars[0])
130  sumexpr += coef * varexpr
131  else:
132  prodexpr = ProdExpr()
133  for v in vars:
134  varexpr = VarExpr(v)
135  prodexpr *= varexpr
136  sumexpr += coef * prodexpr
137  return sumexpr
138  else:
139  assert isinstance(expr, GenExpr)
140  return expr
141 
142 
144 cdef class Expr:
145 
146  def __init__(self, terms=None):
147  '''terms is a dict of variables to coefficients.
148 
149  CONST is used as key for the constant term.'''
150  self.terms = {} if terms is None else terms
151 
152  if len(self.terms) == 0:
153  self.terms[CONST] = 0.0
154 
155  def __getitem__(self, key):
156  if not isinstance(key, Term):
157  key = Term(key)
158  return self.terms.get(key, 0.0)
159 
160  def __iter__(self):
161  return iter(self.terms)
162 
163  def __next__(self):
164  try: return next(self.terms)
165  except: raise StopIteration
166 
167  def __abs__(self):
168  return abs(buildGenExprObj(self))
169 
170  def __add__(self, other):
171  left = self
172  right = other
173 
174  if _is_number(self):
175  assert isinstance(other, Expr)
176  left,right = right,left
177  terms = left.terms.copy()
178 
179  if isinstance(right, Expr):
180  # merge the terms by component-wise addition
181  for v,c in right.terms.items():
182  terms[v] = terms.get(v, 0.0) + c
183  elif _is_number(right):
184  c = float(right)
185  terms[CONST] = terms.get(CONST, 0.0) + c
186  elif isinstance(right, GenExpr):
187  return buildGenExprObj(left) + right
188  else:
189  raise NotImplementedError
190  return Expr(terms)
191 
192  def __iadd__(self, other):
193  if isinstance(other, Expr):
194  for v,c in other.terms.items():
195  self.terms[v] = self.terms.get(v, 0.0) + c
196  elif _is_number(other):
197  c = float(other)
198  self.terms[CONST] = self.terms.get(CONST, 0.0) + c
199  elif isinstance(other, GenExpr):
200  # is no longer in place, might affect performance?
201  # can't do `self = buildGenExprObj(self) + other` since I get
202  # TypeError: Cannot convert pyscipopt.scip.SumExpr to pyscipopt.scip.Expr
203  return buildGenExprObj(self) + other
204  else:
205  raise NotImplementedError
206  return self
207 
208  def __mul__(self, other):
209  if _is_number(other):
210  f = float(other)
211  return Expr({v:f*c for v,c in self.terms.items()})
212  elif _is_number(self):
213  f = float(self)
214  return Expr({v:f*c for v,c in other.terms.items()})
215  elif isinstance(other, Expr):
216  terms = {}
217  for v1, c1 in self.terms.items():
218  for v2, c2 in other.terms.items():
219  v = v1 + v2
220  terms[v] = terms.get(v, 0.0) + c1 * c2
221  return Expr(terms)
222  elif isinstance(other, GenExpr):
223  return buildGenExprObj(self) * other
224  else:
225  raise NotImplementedError
226 
227  def __truediv__(self,other):
228  if _is_number(other):
229  f = 1.0/float(other)
230  return f * self
231  selfexpr = buildGenExprObj(self)
232  return selfexpr.__truediv__(other)
233 
234  def __rtruediv__(self, other):
235  ''' other / self '''
236  if _is_number(self):
237  f = 1.0/float(self)
238  return f * other
239  otherexpr = buildGenExprObj(other)
240  return otherexpr.__truediv__(self)
241 
242  def __pow__(self, other, modulo):
243  if float(other).is_integer() and other >= 0:
244  exp = int(other)
245  else: # need to transform to GenExpr
246  return buildGenExprObj(self)**other
247 
248  res = 1
249  for _ in range(exp):
250  res *= self
251  return res
252 
253  def __neg__(self):
254  return Expr({v:-c for v,c in self.terms.items()})
255 
256  def __sub__(self, other):
257  return self + (-other)
258 
259  def __radd__(self, other):
260  return self.__add__(other)
261 
262  def __rmul__(self, other):
263  return self.__mul__(other)
264 
265  def __rsub__(self, other):
266  return -1.0 * self + other
267 
268  def __richcmp__(self, other, op):
269  '''turn it into a constraint'''
270  return _expr_richcmp(self, other, op)
271 
272  def normalize(self):
273  '''remove terms with coefficient of 0'''
274  self.terms = {t:c for (t,c) in self.terms.items() if c != 0.0}
275 
276  def __repr__(self):
277  return 'Expr(%s)' % repr(self.terms)
278 
279  def degree(self):
280  '''computes highest degree of terms'''
281  if len(self.terms) == 0:
282  return 0
283  else:
284  return max(len(v) for v in self.terms)
285 
286 
287 cdef class ExprCons:
288  '''Constraints with a polynomial expressions and lower/upper bounds.'''
289  cdef public expr
290  cdef public _lhs
291  cdef public _rhs
292 
293  def __init__(self, expr, lhs=None, rhs=None):
294  self.expr = expr
295  self._lhs = lhs
296  self._rhs = rhs
297  assert not (lhs is None and rhs is None)
298  self.normalize()
299 
300  def normalize(self):
301  '''move constant terms in expression to bounds'''
302  if isinstance(self.expr, Expr):
303  c = self.expr[CONST]
304  self.expr -= c
305  assert self.expr[CONST] == 0.0
306  self.expr.normalize()
307  else:
308  assert isinstance(self.expr, GenExpr)
309  return
310 
311  if not self._lhs is None:
312  self._lhs -= c
313  if not self._rhs is None:
314  self._rhs -= c
315 
316 
317  def __richcmp__(self, other, op):
318  '''turn it into a constraint'''
319  if op == 1: # <=
320  if not self._rhs is None:
321  raise TypeError('ExprCons already has upper bound')
322  assert self._rhs is None
323  assert not self._lhs is None
324 
325  if not _is_number(other):
326  raise TypeError('Ranged ExprCons is not well defined!')
327 
328  return ExprCons(self.expr, lhs=self._lhs, rhs=float(other))
329  elif op == 5: # >=
330  if not self._lhs is None:
331  raise TypeError('ExprCons already has lower bound')
332  assert self._lhs is None
333  assert not self._rhs is None
334 
335  if not _is_number(other):
336  raise TypeError('Ranged ExprCons is not well defined!')
337 
338  return ExprCons(self.expr, lhs=float(other), rhs=self._rhs)
339  else:
340  raise TypeError
341 
342  def __repr__(self):
343  return 'ExprCons(%s, %s, %s)' % (self.expr, self._lhs, self._rhs)
344 
345  def __nonzero__(self):
346  '''Make sure that equality of expressions is not asserted with =='''
347 
348  msg = """Can't evaluate constraints as booleans.
349 
350 If you want to add a ranged constraint of the form
351  lhs <= expression <= rhs
352 you have to use parenthesis to break the Python syntax for chained comparisons:
353  lhs <= (expression <= rhs)
354 """
355  raise TypeError(msg)
356 
357 def quicksum(termlist):
358  '''add linear expressions and constants much faster than Python's sum
359  by avoiding intermediate data structures and adding terms inplace
360  '''
361  result = Expr()
362  for term in termlist:
363  result += term
364  return result
365 
366 def quickprod(termlist):
367  '''multiply linear expressions and constants by avoiding intermediate
368  data structures and multiplying terms inplace
369  '''
370  result = Expr() + 1
371  for term in termlist:
372  result *= term
373  return result
374 
375 
376 class Op:
377  const = 'const'
378  varidx = 'var'
379  exp, log, sqrt, sin, cos = 'exp', 'log', 'sqrt', 'sin', 'cos'
380  plus, minus, mul, div, power = '+', '-', '*', '/', '**'
381  add = 'sum'
382  prod = 'prod'
383  fabs = 'abs'
384 
385 Operator = Op()
386 
387 
395 cdef class GenExpr:
396  cdef public _op
397  cdef public children
398 
399 
400  def __init__(self): # do we need it
401  ''' '''
402 
403  def __abs__(self):
404  return UnaryExpr(Operator.fabs, self)
405 
406  def __add__(self, other):
407  left = buildGenExprObj(self)
408  right = buildGenExprObj(other)
409  ans = SumExpr()
410 
411  # add left term
412  if left.getOp() == Operator.add:
413  ans.coefs.extend(left.coefs)
414  ans.children.extend(left.children)
415  ans.constant += left.constant
416  elif left.getOp() == Operator.const:
417  ans.constant += left.number
418  else:
419  ans.coefs.append(1.0)
420  ans.children.append(left)
421 
422  # add right term
423  if right.getOp() == Operator.add:
424  ans.coefs.extend(right.coefs)
425  ans.children.extend(right.children)
426  ans.constant += right.constant
427  elif right.getOp() == Operator.const:
428  ans.constant += right.number
429  else:
430  ans.coefs.append(1.0)
431  ans.children.append(right)
432 
433  return ans
434 
435  #def __iadd__(self, other):
436  #''' in-place addition, i.e., expr += other '''
437  # assert isinstance(self, Expr)
438  # right = buildGenExprObj(other)
439  #
440  # # transform self into sum
441  # if self.getOp() != Operator.add:
442  # newsum = SumExpr()
443  # if self.getOp() == Operator.const:
444  # newsum.constant += self.number
445  # else:
446  # newsum.coefs.append(1.0)
447  # newsum.children.append(self.copy()) # TODO: what is copy?
448  # self = newsum
449  # # add right term
450  # if right.getOp() == Operator.add:
451  # self.coefs.extend(right.coefs)
452  # self.children.extend(right.children)
453  # self.constant += right.constant
454  # elif right.getOp() == Operator.const:
455  # self.constant += right.number
456  # else:
457  # self.coefs.append(1.0)
458  # self.children.append(right)
459  # return self
460 
461  def __mul__(self, other):
462  left = buildGenExprObj(self)
463  right = buildGenExprObj(other)
464  ans = ProdExpr()
465 
466  # multiply left factor
467  if left.getOp() == Operator.prod:
468  ans.children.extend(left.children)
469  ans.constant *= left.constant
470  elif left.getOp() == Operator.const:
471  ans.constant *= left.number
472  else:
473  ans.children.append(left)
474 
475  # multiply right factor
476  if right.getOp() == Operator.prod:
477  ans.children.extend(right.children)
478  ans.constant *= right.constant
479  elif right.getOp() == Operator.const:
480  ans.constant *= right.number
481  else:
482  ans.children.append(right)
483 
484  return ans
485 
486  #def __imul__(self, other):
487  #''' in-place multiplication, i.e., expr *= other '''
488  # assert isinstance(self, Expr)
489  # right = buildGenExprObj(other)
490  # # transform self into prod
491  # if self.getOp() != Operator.prod:
492  # newprod = ProdExpr()
493  # if self.getOp() == Operator.const:
494  # newprod.constant *= self.number
495  # else:
496  # newprod.children.append(self.copy()) # TODO: what is copy?
497  # self = newprod
498  # # multiply right factor
499  # if right.getOp() == Operator.prod:
500  # self.children.extend(right.children)
501  # self.constant *= right.constant
502  # elif right.getOp() == Operator.const:
503  # self.constant *= right.number
504  # else:
505  # self.children.append(right)
506  # return self
507 
508  def __pow__(self, other, modulo):
509  expo = buildGenExprObj(other)
510  if expo.getOp() != Operator.const:
511  raise NotImplementedError("exponents must be numbers")
512  if self.getOp() == Operator.const:
513  return Constant(self.number**expo.number)
514  ans = PowExpr()
515  ans.children.append(self)
516  ans.expo = expo.number
517 
518  return ans
519 
520  #TODO: ipow, idiv, etc
521  def __truediv__(self,other):
522  divisor = buildGenExprObj(other)
523  # we can't divide by 0
524  if divisor.getOp() == Operator.const and divisor.number == 0.0:
525  raise ZeroDivisionError("cannot divide by 0")
526  return self * divisor**(-1)
527 
528  def __rtruediv__(self, other):
529  ''' other / self '''
530  otherexpr = buildGenExprObj(other)
531  return otherexpr.__truediv__(self)
532 
533  def __neg__(self):
534  return -1.0 * self
535 
536  def __sub__(self, other):
537  return self + (-other)
538 
539  def __radd__(self, other):
540  return self.__add__(other)
541 
542  def __rmul__(self, other):
543  return self.__mul__(other)
544 
545  def __rsub__(self, other):
546  return -1.0 * self + other
547 
548  def __richcmp__(self, other, op):
549  '''turn it into a constraint'''
550  return _expr_richcmp(self, other, op)
551 
552  def degree(self):
553  '''Note: none of these expressions should be polynomial'''
554  return float('inf')
555 
556  def getOp(self):
557  '''returns operator of GenExpr'''
558  return self._op
559 
560 
561 # Sum Expressions
562 cdef class SumExpr(GenExpr):
563 
564  cdef public constant
565  cdef public coefs
566 
567  def __init__(self):
568  self.constant = 0.0
569  self.coefs = []
570  self.children = []
571  self._op = Operator.add
572  def __repr__(self):
573  return self._op + "(" + str(self.constant) + "," + ",".join(map(lambda child : child.__repr__(), self.children)) + ")"
574 
575 # Prod Expressions
576 cdef class ProdExpr(GenExpr):
577  cdef public constant
578  def __init__(self):
579  self.constant = 1.0
580  self.children = []
581  self._op = Operator.prod
582  def __repr__(self):
583  return self._op + "(" + str(self.constant) + "," + ",".join(map(lambda child : child.__repr__(), self.children)) + ")"
584 
585 # Var Expressions
586 cdef class VarExpr(GenExpr):
587  cdef public var
588  def __init__(self, var):
589  self.children = [var]
590  self._op = Operator.varidx
591  def __repr__(self):
592  return self.children[0].__repr__()
593 
594 # Pow Expressions
595 cdef class PowExpr(GenExpr):
596  cdef public expo
597  def __init__(self):
598  self.expo = 1.0
599  self.children = []
600  self._op = Operator.power
601  def __repr__(self):
602  return self._op + "(" + self.children[0].__repr__() + "," + str(self.expo) + ")"
603 
604 # Exp, Log, Sqrt, Sin, Cos Expressions
605 cdef class UnaryExpr(GenExpr):
606  def __init__(self, op, expr):
607  self.children = []
608  self.children.append(expr)
609  self._op = op
610  def __repr__(self):
611  return self._op + "(" + self.children[0].__repr__() + ")"
612 
613 # class for constant expressions
614 cdef class Constant(GenExpr):
615  cdef public number
616  def __init__(self,number):
617  self.number = number
618  self._op = Operator.const
619 
620  def __repr__(self):
621  return str(self.number)
622 
623 def exp(expr):
624  """returns expression with exp-function"""
625  return UnaryExpr(Operator.exp, buildGenExprObj(expr))
626 def log(expr):
627  """returns expression with log-function"""
628  return UnaryExpr(Operator.log, buildGenExprObj(expr))
629 def sqrt(expr):
630  """returns expression with sqrt-function"""
631  return UnaryExpr(Operator.sqrt, buildGenExprObj(expr))
632 def sin(expr):
633  """returns expression with sin-function"""
634  return UnaryExpr(Operator.sin, buildGenExprObj(expr))
635 def cos(expr):
636  """returns expression with cos-function"""
637  return UnaryExpr(Operator.cos, buildGenExprObj(expr))
638 
639 def expr_to_nodes(expr):
640  '''transforms tree to an array of nodes. each node is an operator and the position of the
641  children of that operator (i.e. the other nodes) in the array'''
642  assert isinstance(expr, GenExpr)
643  nodes = []
644  expr_to_array(expr, nodes)
645  return nodes
646 
647 def value_to_array(val, nodes):
648  """adds a given value to an array"""
649  nodes.append(tuple(['const', [val]]))
650  return len(nodes) - 1
651 
652 # there many hacky things here: value_to_array is trying to mimick
653 # the multiple dispatch of julia. Also that we have to ask which expression is which
654 # in order to get the constants correctly
655 # also, for sums, we are not considering coefficients, because basically all coefficients are 1
656 # haven't even consider substractions, but I guess we would interpret them as a - b = a + (-1) * b
657 def expr_to_array(expr, nodes):
658  """adds expression to array"""
659  op = expr._op
660  if op == Operator.const: # FIXME: constant expr should also have children!
661  nodes.append(tuple([op, [expr.number]]))
662  elif op != Operator.varidx:
663  indices = []
664  nchildren = len(expr.children)
665  for child in expr.children:
666  pos = expr_to_array(child, nodes) # position of child in the final array of nodes, 'nodes'
667  indices.append(pos)
668  if op == Operator.power:
669  pos = value_to_array(expr.expo, nodes)
670  indices.append(pos)
671  elif (op == Operator.add and expr.constant != 0.0) or (op == Operator.prod and expr.constant != 1.0):
672  pos = value_to_array(expr.constant, nodes)
673  indices.append(pos)
674  nodes.append( tuple( [op, indices] ) )
675  else: # var
676  nodes.append( tuple( [op, expr.children] ) )
677  return len(nodes) - 1
pyscipopt.expr.SumExpr.__init__
def __init__(self)
Definition: expr.pxi:567
pyscipopt.expr.GenExpr.__rtruediv__
def __rtruediv__(self, other)
Definition: expr.pxi:528
pyscipopt.expr.quicksum
def quicksum(termlist)
Definition: expr.pxi:357
pyscipopt.expr.Constant._op
_op
Definition: expr.pxi:618
pyscipopt.expr.GenExpr.__truediv__
def __truediv__(self, other)
Definition: expr.pxi:521
pyscipopt.expr.Expr.__neg__
def __neg__(self)
Definition: expr.pxi:253
pyscipopt.expr.Expr.normalize
def normalize(self)
Definition: expr.pxi:272
pyscipopt.expr.ProdExpr._op
_op
Definition: expr.pxi:581
pyscipopt.expr.SumExpr
Definition: expr.pxi:562
pyscipopt.expr.UnaryExpr
Definition: expr.pxi:605
pyscipopt.expr.ProdExpr.children
children
Definition: expr.pxi:580
pyscipopt.expr.ExprCons.expr
expr
Definition: expr.pxi:294
pyscipopt.expr.Expr.__richcmp__
def __richcmp__(self, other, op)
Definition: expr.pxi:268
pyscipopt.expr.Term.ptrtuple
ptrtuple
Definition: expr.pxi:90
pyscipopt.expr.Expr.__iter__
def __iter__(self)
Definition: expr.pxi:160
pyscipopt.expr.ExprCons._lhs
_lhs
Definition: expr.pxi:295
pyscipopt.expr.SumExpr.constant
constant
Definition: expr.pxi:568
pyscipopt.expr.value_to_array
def value_to_array(val, nodes)
Definition: expr.pxi:647
pyscipopt.expr.Expr
Definition: expr.pxi:144
pyscipopt.expr.GenExpr.__init__
def __init__(self)
Definition: expr.pxi:400
pyscipopt.expr.ProdExpr
Definition: expr.pxi:576
pyscipopt.expr.GenExpr.__sub__
def __sub__(self, other)
Definition: expr.pxi:536
pyscipopt.expr.ExprCons.__richcmp__
def __richcmp__(self, other, op)
Definition: expr.pxi:317
pyscipopt.expr.VarExpr.children
children
Definition: expr.pxi:589
pyscipopt.expr.Term.__eq__
def __eq__(self, other)
Definition: expr.pxi:99
pyscipopt.expr.ExprCons.__repr__
def __repr__(self)
Definition: expr.pxi:342
pyscipopt.expr.Expr.__rsub__
def __rsub__(self, other)
Definition: expr.pxi:265
pyscipopt.expr.ExprCons.__nonzero__
def __nonzero__(self)
Definition: expr.pxi:345
pyscipopt.expr.PowExpr.expo
expo
Definition: expr.pxi:598
pyscipopt.expr.SumExpr._op
_op
Definition: expr.pxi:571
pyscipopt.expr.SumExpr.coefs
coefs
Definition: expr.pxi:569
pyscipopt.expr.GenExpr.__mul__
def __mul__(self, other)
Definition: expr.pxi:461
pyscipopt.expr.GenExpr.__abs__
def __abs__(self)
Definition: expr.pxi:403
pyscipopt.expr.PowExpr.children
children
Definition: expr.pxi:599
pyscipopt.expr.ExprCons.__init__
def __init__(self, expr, lhs=None, rhs=None)
Definition: expr.pxi:293
pyscipopt.expr.Expr.__mul__
def __mul__(self, other)
Definition: expr.pxi:208
pyscipopt.expr.Term.__hash__
def __hash__(self)
Definition: expr.pxi:96
pyscipopt.expr.Expr.__radd__
def __radd__(self, other)
Definition: expr.pxi:259
pyscipopt.expr.VarExpr.__init__
def __init__(self, var)
Definition: expr.pxi:588
pyscipopt.expr.Expr.__repr__
def __repr__(self)
Definition: expr.pxi:276
pyscipopt.expr.Expr.__iadd__
def __iadd__(self, other)
Definition: expr.pxi:192
pyscipopt.expr.UnaryExpr.children
children
Definition: expr.pxi:607
pyscipopt.expr.sqrt
def sqrt(expr)
Definition: expr.pxi:629
pyscipopt.expr.GenExpr
Definition: expr.pxi:395
pyscipopt.expr.Expr.__rtruediv__
def __rtruediv__(self, other)
Definition: expr.pxi:234
pyscipopt.expr.SumExpr.__repr__
def __repr__(self)
Definition: expr.pxi:572
pyscipopt.expr.Expr.__init__
def __init__(self, terms=None)
Definition: expr.pxi:146
pyscipopt.expr.GenExpr.__add__
def __add__(self, other)
Definition: expr.pxi:406
pyscipopt.expr.GenExpr.__neg__
def __neg__(self)
Definition: expr.pxi:533
pyscipopt.expr.PowExpr
Definition: expr.pxi:595
pyscipopt.expr.ProdExpr.__repr__
def __repr__(self)
Definition: expr.pxi:582
pyscipopt.expr.Term
Definition: expr.pxi:83
pyscipopt.expr.Expr.__getitem__
def __getitem__(self, key)
Definition: expr.pxi:155
pyscipopt.expr.ProdExpr.constant
constant
Definition: expr.pxi:579
pyscipopt.expr.UnaryExpr._op
_op
Definition: expr.pxi:609
pyscipopt.expr.UnaryExpr.__init__
def __init__(self, op, expr)
Definition: expr.pxi:606
pyscipopt.expr.cos
def cos(expr)
Definition: expr.pxi:635
pyscipopt.expr.VarExpr
Definition: expr.pxi:586
pyscipopt.expr.Constant.number
number
Definition: expr.pxi:617
pyscipopt.expr.Constant.__init__
def __init__(self, number)
Definition: expr.pxi:616
pyscipopt.expr.expr_to_array
def expr_to_array(expr, nodes)
Definition: expr.pxi:657
pyscipopt.expr.GenExpr.__pow__
def __pow__(self, other, modulo)
Definition: expr.pxi:508
pyscipopt.expr.buildGenExprObj
def buildGenExprObj(expr)
Definition: expr.pxi:116
pyscipopt.expr.Op
Definition: expr.pxi:376
pyscipopt.expr.GenExpr.__radd__
def __radd__(self, other)
Definition: expr.pxi:539
pyscipopt.expr.GenExpr.__rsub__
def __rsub__(self, other)
Definition: expr.pxi:545
pyscipopt.expr.quickprod
def quickprod(termlist)
Definition: expr.pxi:366
pyscipopt.expr.ExprCons
Definition: expr.pxi:287
pyscipopt.expr.VarExpr.__repr__
def __repr__(self)
Definition: expr.pxi:591
pyscipopt.expr.Expr.degree
def degree(self)
Definition: expr.pxi:279
pyscipopt.expr.GenExpr.degree
def degree(self)
Definition: expr.pxi:552
pyscipopt.expr.Expr.__sub__
def __sub__(self, other)
Definition: expr.pxi:256
pyscipopt.expr.VarExpr._op
_op
Definition: expr.pxi:590
pyscipopt.expr.Expr.__truediv__
def __truediv__(self, other)
Definition: expr.pxi:227
pyscipopt.expr.GenExpr.getOp
def getOp(self)
Definition: expr.pxi:556
pyscipopt.expr.Term.__len__
def __len__(self)
Definition: expr.pxi:102
pyscipopt.expr.Constant.__repr__
def __repr__(self)
Definition: expr.pxi:620
pyscipopt.expr.expr_to_nodes
def expr_to_nodes(expr)
Definition: expr.pxi:639
pyscipopt.expr.UnaryExpr.__repr__
def __repr__(self)
Definition: expr.pxi:610
pyscipopt.expr.GenExpr.__rmul__
def __rmul__(self, other)
Definition: expr.pxi:542
pyscipopt.expr.Expr.__pow__
def __pow__(self, other, modulo)
Definition: expr.pxi:242
pyscipopt.expr.Expr.__abs__
def __abs__(self)
Definition: expr.pxi:167
pyscipopt.expr.sin
def sin(expr)
Definition: expr.pxi:632
pyscipopt.expr.ExprCons.normalize
def normalize(self)
Definition: expr.pxi:300
pyscipopt.expr.Expr.__add__
def __add__(self, other)
Definition: expr.pxi:170
pyscipopt.expr.ProdExpr.__init__
def __init__(self)
Definition: expr.pxi:578
pyscipopt.expr.Expr.terms
terms
Definition: expr.pxi:150
pyscipopt.expr.exp
def exp(expr)
Definition: expr.pxi:623
pyscipopt.expr.PowExpr.__init__
def __init__(self)
Definition: expr.pxi:597
pyscipopt.expr.Expr.__next__
def __next__(self)
Definition: expr.pxi:163
pyscipopt.expr.Term.__repr__
def __repr__(self)
Definition: expr.pxi:109
pyscipopt.expr.log
def log(expr)
Definition: expr.pxi:626
pyscipopt.expr.Term.__getitem__
def __getitem__(self, idx)
Definition: expr.pxi:93
pyscipopt.expr.Term.vartuple
vartuple
Definition: expr.pxi:89
pyscipopt.expr.Term.__add__
def __add__(self, other)
Definition: expr.pxi:105
pyscipopt.expr.GenExpr.__richcmp__
def __richcmp__(self, other, op)
Definition: expr.pxi:548
pyscipopt.expr.Term.hashval
hashval
Definition: expr.pxi:91
pyscipopt.expr.Expr.__rmul__
def __rmul__(self, other)
Definition: expr.pxi:262
pyscipopt.expr.Term.__init__
def __init__(self, *vartuple)
Definition: expr.pxi:88
pyscipopt.expr.ExprCons._rhs
_rhs
Definition: expr.pxi:296
pyscipopt.expr.PowExpr._op
_op
Definition: expr.pxi:600
pyscipopt.expr.SumExpr.children
children
Definition: expr.pxi:570
pyscipopt.expr.Constant
Definition: expr.pxi:614
pyscipopt.expr.PowExpr.__repr__
def __repr__(self)
Definition: expr.pxi:601