Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create a vector of parameters #20

Closed
caioluke opened this issue Jul 1, 2021 · 1 comment
Closed

How to create a vector of parameters #20

caioluke opened this issue Jul 1, 2021 · 1 comment

Comments

@caioluke
Copy link
Contributor

caioluke commented Jul 1, 2021

Hey there again, how can I create a vector of parameters in a JuMP model?

I know I can do as below but I wondered if I could create it differently, just like the other variables with something like @variable(model, y[i=1:2], set = [POI.Parameter(0), POI.Parameter(0)])

model = Model(() -> POI.ParametricOptimizer(GLPK.Optimizer()))

@variable(model, x[i=1:2] >= 0)
y = [@variable(model, set=POI.Parameter(0)) for i=1:2]

@constraint(model, 2*x[1] + x[2] + y[1] <= 4)
@constraint(model, x[1] + 2*x[2] + y[2] <= 4)
@constraint(model, (1+y[1])*x[1] + 2*x[2] <= 4)

@objective(model, Max, sum(c[i]*x[i] for i=1:2))
@guilhermebodin
Copy link
Collaborator

One way is to do like this @variable(model, p[i in 1:N] in POI.Parameter.(0)) replacing this issue for the documentation on #69

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants