@@ -15,7 +15,7 @@ def _is_number(e):
1515 return False
1616
1717
18- cdef class Term:
18+ class Term :
1919 """ A monomial term consisting of one or more variables."""
2020
2121 __slots__ = (" vars" , " ptrs" )
@@ -46,7 +46,7 @@ cdef class Term:
4646 def __repr__ (self ):
4747 return f" Term({', '.join(map(str, self.vars))})"
4848
49- cdef float _evaluate(self , SCIP * scip, SCIP_SOL * sol):
49+ def _evaluate (self , scip , sol ):
5050 if self .vars:
5151 return math.prod(SCIPgetSolVal(scip, sol, ptr) for ptr in self .ptrs)
5252 return 1.0 # constant term
@@ -226,7 +226,7 @@ class Expr:
226226 return nodes
227227
228228
229- cdef class SumExpr(Expr ):
229+ class SumExpr(Expr ):
230230 """ Expression like `expression1 + expression2 + constant`."""
231231
232232 def __add__ (self , other ):
@@ -246,7 +246,7 @@ cdef class SumExpr(Expr):
246246 def degree (self ):
247247 return float (" inf" )
248248
249- cdef float _evaluate(self , SCIP * scip, SCIP_SOL * sol):
249+ def _evaluate (self , scip , sol ):
250250 return _evaluate(self .children, scip, sol)
251251
252252
@@ -370,7 +370,7 @@ class FuncExpr(Expr):
370370 return float (" inf" )
371371
372372
373- cdef class ProdExpr(FuncExpr):
373+ class ProdExpr (FuncExpr ):
374374 """ Expression like `coefficient * expression`."""
375375
376376 def __init__ (self , *children , coef: float = 1.0 ):
@@ -402,11 +402,11 @@ cdef class ProdExpr(FuncExpr):
402402 return ConstExpr(0.0)
403403 return self
404404
405- cdef float _evaluate(self , SCIP* scip , SCIP_SOL* sol ):
405+ def _evaluate(self , scip , sol ):
406406 return self .coef * _evaluate(self .children, scip, sol)
407407
408408
409- cdef class PowExpr(FuncExpr):
409+ class PowExpr (FuncExpr ):
410410 """ Expression like `pow(expression, exponent)`."""
411411
412412 def __init__ (self , base , expo: float = 1.0 ):
@@ -426,11 +426,11 @@ cdef class PowExpr(FuncExpr):
426426 return tuple(self )[0]
427427 return self
428428
429- cdef float _evaluate(self , SCIP* scip , SCIP_SOL* sol ):
429+ def _evaluate(self , scip , sol ):
430430 return pow (_evaluate(self .children, scip, sol), self .expo)
431431
432432
433- cdef class UnaryExpr(FuncExpr):
433+ class UnaryExpr (FuncExpr ):
434434 """ Expression like `f(expression)`."""
435435
436436 def __init__ (self , expr: Expr ):
@@ -451,7 +451,7 @@ cdef class UnaryExpr(FuncExpr):
451451 nodes.append((type(self ), start + len(nodes ) - 1))
452452 return nodes
453453
454- cdef float _evaluate(self , SCIP* scip , SCIP_SOL* sol ):
454+ def _evaluate(self , scip , sol ):
455455 return self .op(_evaluate(self .children, scip, sol))
456456
457457
0 commit comments