Jump.jl: Modify RHS (and define RHS)

Created on 8 Mar 2019  路  8Comments  路  Source: jump-dev/JuMP.jl

In #1183 we decided to not implement: ScalarConstantChange.
Probably following: #470
According to the manual (http://www.juliaopt.org/JuMP.jl/v0.19.0/constraints/#Modifying-a-constant-term-1):
In this constraint: @constraint(model, 2x + 1 <= x - 3), why the coefficient of x is well defined and the constant of the function is not?

Moreover, in #1332 we are considering bounds on RHS, but we have not defined RHS.

Maybe we should reconsider?
At least bring back add_constant (or add_to_rhs)? https://github.com/JuliaOpt/JuMP.jl/pull/1351#discussion_r224945107

Most helpful comment

I'm not a fan of add_to_rhs without a nice way to query the current (standard-form) rhs.

How about set_standard_form_rhs and set_standard_form_coefficient. That makes it pretty clear something weird is going on, and hopefully people go read the documentation.

All 8 comments

It seems to me that add_constant is clearer. You add a constant to the the function. For vector constraints, this is what will be done. For scalar constraints, it will substract this constant from the set. From the user perspective, he needs to understand that add_constant is defined based on the @constraint(model, func in set) syntax so he needs to understand that @constraint(model, a <= b) is translated to @constraint(model, a - b in MOI.LessThan(0.0)).

I'm not a fan of add_to_rhs without a nice way to query the current (standard-form) rhs.

How about set_standard_form_rhs and set_standard_form_coefficient. That makes it pretty clear something weird is going on, and hopefully people go read the documentation.

The functionality is essencial.
I think is reasonable to have a verbose name to highlight some possibly confusing behavior.

without a nice way to query the current (standard-form) rhs.

What prevents us from defining constant(::ConstraintRef) is interval constraints. But rhs wont work for interval constraint either so we could have

  • a constant function that works with every non-interval constraint;
  • a add_constant function that works even with interval constraints and is as described in https://github.com/JuliaOpt/JuMP.jl/issues/1890#issuecomment-470877385 and
  • a set_function_constant that only works for non-interval constraints and sets the function constant where the set constant is zero.

set_standard_from_rhs(cref, a) is equivalent to set_function_constant(cref, -a).

For what it's worth, I support the addition of _any_ functionality that allows you to modify the constant term of a constraint that doesn't involve adding dummy variables to the problem.

For now, have you looked at ParameterJuMP.jl?

https://github.com/JuliaStochOpt/ParameterJuMP.jl

Maybe ParameterJuMP is the right way to go about this, rather than adding functionality to JuMP.

set_standard_form_rhs and set_standard_form_coefficient sound good to me. I don't see a reason to keep this functionality out of JuMP. It's exposing something already well-defined in MOI.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

IainNZ picture IainNZ  路  10Comments

igormcoelho picture igormcoelho  路  3Comments

mlubin picture mlubin  路  9Comments

matbesancon picture matbesancon  路  5Comments

martinbiel picture martinbiel  路  8Comments