Linear parameter

I want to define a parameter so that the model will change if I set a different value for the parameter. The following is an example, while the real problem is much more complicated.

using JuMP
model = Model()
@variable(model, x1 >= 0)
@variable(model, x2 >= 0)
@constraint(model, a*x + y>= 1.33)
@constraint(model, x + y <= a )

I want to solve a bunch of problems for different values of a. I don’t like to declare a as fixed variable because it will treat this LP as NLP.

Thanks.

Just define a as an ordinary Julia (non-JuMP) variable, i.e. don’t declare it with @variable:

using JuMP
a = 2.0
model = Model()
@variable(model, x >= 0)
@variable(model, y >= 0)
@constraint(model, a*x + y>= 1.33)
@constraint(model, x + y <= a )

EDIT: Remember that JuMP is just an extension to the Julia programming language. If you plan to build models in JuMP it’s worth spending an hour or two going through some basic Julia tutorials.

Modifying constraint coefficients is currently not supported as written here. You have to rebuild the model every time you change the parameter a.