Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
Expand all | Collapse all

Docplex | AttributeError: 'Var' object has no attribute 'grab_subscribers'

  • 1.  Docplex | AttributeError: 'Var' object has no attribute 'grab_subscribers'

    Posted Tue August 02, 2022 09:03 AM
    I installed the latest version of docplex (2.23.222) and modify model constraint by adding new variable, e.g.

    ctlhs = ct.lhs
    ctlhs += new_route_var

    here is the error log:
    File line 1656, in
    ctlhs += new_route_var
    File "\lib\site-packages\docplex\mp\linear.py", line 1292, in __iadd__
    self.notify_replaced(linear_other)
    File "\lib\site-packages\docplex\mp\basic.py", line 532, in notify_replaced
    s.notify_expr_replaced(self, new_expr)
    File "\lib\site-packages\docplex\mp\constr.py", line 602, in notify_expr_replaced
    new_expr.grab_subscribers(old_expr)
    AttributeError: 'Var' object has no attribute 'grab_subscribers'

    ------------------------------
    Steve Chen
    ------------------------------

    #DecisionOptimization


  • 2.  RE: Docplex | AttributeError: 'Var' object has no attribute 'grab_subscribers'

    Posted Wed August 17, 2022 04:55 AM
    A work around may be
    ctlhs += 1*new_route_var​


    In the latest versions of docplex, normalization of expressions has been improved. 
    I think that in your code, the left hand side of your constraint is simplified to 0 while with previous versions, it was a more complex expression which evaluated to 0.
    And the notification system in docplex to notify optimization objects of a change hits an issue with this 0 += variable.
    We will investigate this on our side.



    ------------------------------
    Vincent Beraudier
    ------------------------------