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

Variable Declaration and Index Sets #43

Open
dirkdegel opened this issue Mar 30, 2020 · 1 comment
Open

Variable Declaration and Index Sets #43

dirkdegel opened this issue Mar 30, 2020 · 1 comment

Comments

@dirkdegel
Copy link

Hi Dirk,

I'm curious about the way variables are declared in rmpl compared to ompr and why the way how to do it changed or what the idea is behind this change.

rmpk

x <- model$add_variable(i = 1:n, j = 1:n, k = 1:9, type = "binary")

vs ompr

add_variable(model, x[i, j, k], i = 1:n, j = 1:n, k = 1:9, type = "binary")

I personally find the "ompr" way much better readable and much more consistent with regards to how the objective and the constraints are set and added.

Also, from reading the Julia/JuMP documentation: Is there not the risk of "mixing" R variables with "rmpk variables", e.g. x should be a R variable whereas in add_variable(model, x) x is something like a reference from the model variable x to the variable representation in the solver (I hope that makes sense). I think it would be beneficial if the syntax would be consistent and look something like

add_variable(model, x[i], I = index_set, name = "...")
add_constraint(model, expression, quantifier, name = "...")
add_objective(model, ...) or set_objective()

This should be equivalent to

model$add_variable(x[i], I = index_set, name = "...")
model$add_constraint(expression, quantifier, name = "...")
model$add_objective(, ...)

Thanks a lot for your great work!
Dirk

@dirkschumacher
Copy link
Member

Thanks for the feedback. #33 and PR #36 are related to this interface idea.

I also like the ompr interface, but I would also like to have direct control over the model/ without any non-standard evaluation. One problem with e.g. add_variable(model, x[i, j, k], ...) is that it if used within a package you will get an R CMD check error, due to unassigned variable usage.

But yeah, I want to offer an api that is very similiar (or even fully compatible) to ompr but also have a more lower level interface using the R6 class. At least for now. Some steps have been made in PR #36 :)

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

2 participants