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

Names for variables and constraints #5

Open
dirkschumacher opened this issue Sep 6, 2019 · 3 comments
Open

Names for variables and constraints #5

dirkschumacher opened this issue Sep 6, 2019 · 3 comments

Comments

@dirkschumacher
Copy link
Member

Would be nice to be able to name constraints and variables

@dirkschumacher
Copy link
Member Author

Maybe support the glue syntax?

MIPModel(solver) %>% 
  add_variable(x[i, j], i = 1:10, j = 1:10, name = "x_[{i}, {j}]") %>% 
  set_objective(sum_expr(x[i, j], i = 1:10, j = 1:10)) %>%
  add_constraint(sum_expr(x[i, j], j = 1:i) <= 10, i = 1:10, name = "constr_{i}")

@dirkschumacher
Copy link
Member Author

Probably like this:

model <- MIPModel(solver)
x <- model$add_variable(x[i], type = "binary", i = 1:10, name = "x_[{i}, {j}]")
model$set_objective(sum_expr(v[i] * x[i], i = 1:10), sense = "max")
model$add_constraint(sum_expr(w[i] * x[i], i = 1:10) <= 10, name = "constr_{i}")
model$optimize()

@dirkschumacher
Copy link
Member Author

Note to self: I need to investigage if ROI supports partial variable names

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

No branches or pull requests

1 participant