cog-imperial / suspect

Special Structure Detection for Pyomo
https://cog-imperial.github.io/suspect/
Apache License 2.0
26 stars 4 forks source link

KeyError: <class 'pyomo.core.expr.numeric_expr.DivisionExpression'> #10

Closed ZedongPeng closed 3 years ago

ZedongPeng commented 3 years ago

When I use detect_special_structure function for pyomo model. An error came up.

/Users/zedongpeng/Github/suspect/suspect/math/floating_point.py:29: RuntimeWarning: divide by zero encountered in log
  globals()[name] = lambda n, _: float(fun(n))
Traceback (most recent call last):
  File "test.py", line 84, in <module>
    info = detect_special_structure(module.m)
  File "/Users/zedongpeng/Github/suspect/suspect/summary.py", line 124, in detect_special_structure
    monotonicity, convexity = propagate_special_structure(problem, bounds)
  File "/Users/zedongpeng/Github/suspect/suspect/propagation.py", line 97, in propagate_special_structure
    _propagate_special_structure(constraint.body, bounds, cvx, mono)
  File "/Users/zedongpeng/Github/suspect/suspect/propagation.py", line 115, in _propagate_special_structure
    ).walk_expression(expr)
  File "/Users/zedongpeng/Github/pyomo/pyomo/core/expr/visitor.py", line 325, in walk_expression
    node_result = self.exitNode(node, data)
  File "/Users/zedongpeng/Github/suspect/suspect/propagation.py", line 109, in exit_node
    result = propagate_expression_convexity(node, cvx, mono, bounds)
  File "/Users/zedongpeng/Github/suspect/suspect/convexity/visitor.py", line 75, in propagate_expression_convexity
    rule = _expr_to_rule_map[type(expr)]
KeyError: <class 'pyomo.core.expr.numeric_expr.DivisionExpression'>

I think it's related to division operation. The example I tested is feedtray. Can it error be fixed?

fracek commented 3 years ago

I will check and get back to you as soon as possible.

fracek commented 3 years ago

I push version 2.0.2 to pypi, it should fix this problem.