You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to model a specific assignment problem, but unfortunately I'm not too fluent in R, so I'm struggling to find the most idiomatic way to do so.
Say, I add an assignment matrix x of binary decision variables to my model like this:
n <- 10
m <- 12
model <- MIPModel() %>%
add_variable(x[i,j], i = 1:n, j = 1:m, type = "binary")
What I want to do now, is to add a set of constraints, which have the following structure (pseudocode):
sum(x[1,2] + x[3,1] + x[2,8] + ...) <= someNumber
So basically these constraints shall enforce, that the sum of some more or less arbitrary set of variables in x is smaller than some limit.
My question now is: What would be a good data structure in R to bring this information (for each constraint the tuples which carry the constrained indices and the limit to enforce) into model construction with ompr? And how could these constraints be added to the model automatically by looping over this input data?
I guess there is a way to do so seamlessly, without the requirement to add each of the constraints manually, but I'm a little bit stuck in finding the best way to do so in R.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi everyone,
I want to model a specific assignment problem, but unfortunately I'm not too fluent in R, so I'm struggling to find the most idiomatic way to do so.
Say, I add an assignment matrix
x
of binary decision variables to my model like this:What I want to do now, is to add a set of constraints, which have the following structure (pseudocode):
sum(x[1,2] + x[3,1] + x[2,8] + ...) <= someNumber
So basically these constraints shall enforce, that the sum of some more or less arbitrary set of variables in
x
is smaller than some limit.My question now is: What would be a good data structure in R to bring this information (for each constraint the tuples which carry the constrained indices and the limit to enforce) into model construction with ompr? And how could these constraints be added to the model automatically by looping over this input data?
I guess there is a way to do so seamlessly, without the requirement to add each of the constraints manually, but I'm a little bit stuck in finding the best way to do so in R.
Thanks very much for your help in advance!
Regards,
Thomas
Beta Was this translation helpful? Give feedback.
All reactions