Mask MVar to only treat part of the array as decision variables
AnsweredSay, I have a 5x4 array p that looks like this:
nan nan nan 1
nan 1 1.1 1
nan 1 0.5 1
1 0.8 1 0.34
1 1 nan nan
I want to create an array of decision variables, X, in Gurobu with model.addMVar that has the same size as p, but only treats the non-nan values as decision variables. Basically, for my problem I have decision variables for which the coordinates matter, but the coordinates do not form a rectangular shape together. To reduce the amount of decision variables (in my real problem p has size (204,127)) I want to esentially 'mask' the non-nan values such that the model only considers these as decision variables
-
Hi Jelle,
We don't have an ability to mask, but you can set the upper bound on these variables to 0, and our presolve routine will remove them.
With our matrix API this can be done like so:
X = model.addMVar(p.shape, vtype="B", ub=~np.isnan(p))
- Riley
1
Please sign in to leave a comment.
Comments
1 comment