Hi,
The reason for the error is that the max function is called ‘max_’. (You are missing an underscore.)
But even with the correct function name, you cannot use it the way you are trying to: The arguments of max_ can only be variables or a constant (not an expression like x1-x2) and you can only use max_ in a constraint of this form: m.addConstr(z == max_(x, y, 3))
Here is the documentation:
https://www.gurobi.com/documentation/8.1/refman/py_max_.html
A quick way to fix your code would be to introduce two auxiliary variables, say x3 and x4, and then do the following:
m.addConstr( x3 == x1 - x2 )
m.addConstr( x4 == max_(0, x3) )
m.setObjective( 1 + 0.9 * x4 )
Also note that ‘m.update()’ is not necessary.
- Silke
> --
>
> ---
> 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.
> For more options, visit
https://groups.google.com/d/optout.