What do you mean by "new expression"? The right hand side of a constraint is just a single
floating point number.
In Python, and the other object oriented APIs, you can define constraints in a very
flexible way like
lhs-expression <= rhs-expression.
But internally, this is then converted into standard form
lhs-expression <= rhs
with rhs being just a floating number. All variables are on the left hand side, all
constants are aggregated into the right hand side.
The RHS attribute only deals with this single floating point value.
If you want to modify the coefficients of the variables in a constraint, you can use the
chgCoeff() method. Alternatively, you could just delete the constraint and add back the
new version of the constraint.
Best regards,
Tobias
Am 2018-06-10 um 13:04 schrieb GurobiUser:
> Hi Daniel,
>
> I am running a similar case repeatedly (i.e., 24) and now I want to update one of my
> constraint during each iteration.
>
> The procedure I follow is this:
>
> 1. Create the model and solve it with m.optimize()
>
> 2. Get the constraint I want to update as above: *c = model.getConstrByName("name")*
>
> 3. Set the rhs attribute which I want to change as: *c.setAttr(GRB.Attr.rhs, new
> expression...)*
>
> 4. Then I solve it again with m.optimize() but I get the error: "Encountered an attribute
> error" . This error comes after the 3 step: *c.setAttr(GRB.Attr.rhs, new expression...)*
>
> Is this the right procedure to follow for updating a constraint each iteration? And why I
> get the error?
>
> Thanks for any reply and help,
>
> On Friday, 13 October 2017 13:21:56 UTC+1, Daniel Espinoza wrote:
>
> Hi,
>
> Can you show what kind of error are you getting?
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups "Gurobi
> Optimization" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
>
gurobi+un...@googlegroups.com <mailto:
gurobi+un...@googlegroups.com>.