How to Set Constraints for Multiple Dimensions in R
回答済みHello! I'm using Gurobi in R and I'm struggling to figure out how to define a constraint that spans multiple dimensions - i.e., rather than the sum of one column has to be x and the sum of one column has to be y, I need the sum of one of my columns to be x and the sum of two of my columns to be y.
Basically, say I'm selecting 10 people for a city committee. I have a list of 50 people that lists their areas of expertise (e.g., art, science, history, architecture) as binary columns of yes/no. Rather than constrain my model to pick say, 5 people that are experts in say, art specifically, I want it to have at least 5 people in the solution that are experts in the same area (could be art, science, whatever), and at least 3 people that are experts in the same area twice (e.g., 3 people who are experts in science, and 3 people who are experts in history).
Please let me know if I can make that clearer but basically I don't get how to make a constraint that depends on multiple columns but could be any combination! Thanks in advance - I'm new to Gurobi so any help with coding this into Gurobi/pseudocode would be great!
-
Hi Kat,
In R, you cannot define constraints one by one but rather have to provide the whole linear matrix \(A\). I am not familiar with R so I cannot really help with a cope snippet but maybe the diet.R examples provides some insight of how sums are constructed in the R API.
Best regards,
Jaromił0
サインインしてコメントを残してください。
コメント
1件のコメント