dirkschumacher / ompr

R package to model Mixed Integer Linear Programs
https://dirkschumacher.github.io/ompr/
Other
268 stars 35 forks source link

Request regarding index #325

Open nipnipj opened 3 years ago

nipnipj commented 3 years ago

Hello!

I'm new to ompr. The following suggestion might be already implemented. I think it would be better if once the indexes for a variable were stablished with add_variable they do need to be written again in other functions like set_objetive or add_constraint. This would make easier to handle Multi-dimensional Index sets.

dirkschumacher commented 2 years ago

Thanks for the suggestion. Can you elaborate a bit what you mean?

sbmack commented 2 years ago

Hello!

I'm new to ompr. The following suggestion might be already implemented. I think it would be better if once the indexes for a variable were stablished with add_variable they do need to be written again in other functions like set_objetive or add_constraint. This would make easier to handle Multi-dimensional Index sets.

The added feature couldn't hurt. But many (most?) formulations have constraints that use only a subset of variables based on categories. E.g. in a product mix problem where only some products use only some specific raw material. So the index subsets of the constraints would only include the products that use the specific material. So in those cases the subsets of the indexes would still have to be explicitly articulated for those constraints. Of course a formulation could be completely dense using zero values for some coefficients, but that is not generally advised.