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
------------------------------
Original Message:
Sent: Mon August 01, 2022 11:56 PM
From: Steve Chen
Subject: Docplex | AttributeError: 'Var' object has no attribute 'grab_subscribers'
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