Sparse Matrix Constraints with multi-index #440
optimizationnoob
started this conversation in
General
Replies: 1 comment
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
cross posting an issue if that is the wrong place
Hello,
I'm working on a modified assignment problem that assigns an individual in an occupation code to a division at a facility. However, not all occupations can be assigned to each division, and not all facilities have each division, so the matrix is sparse. I am attempting to filter while adding in a constraint that sums across divisions and facilities for each occupation code, but am getting the error "Error: You used the variable 'x' with at least one index that does not exists." Below is my code that should reprouce the error. Given the IT system I have access to, I must use R 4.0.2 and ompr 0.8.0. I'm able to add variables and set the objective function, but not add a constraint.
The constraint I am trying to incorporate sums across all divisions and facilities for each occupation code (so there should be 30 constraints of this type, one for each occupation code, and each occupation has a different supply) to ensure that the total assignment of each worker type across all divisions/facilities does not exceed the supply.
What is the proper syntax to filter a sparse matrix in a constraint that sums through only two of the three indices, and then generates one constraint for each value of the third index? Thanks!
Beta Was this translation helpful? Give feedback.
All reactions