Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor UniversalFallback and Model with VectorOfConstraints #1234

Closed
blegat opened this issue Feb 7, 2021 · 0 comments · Fixed by #1245
Closed

Refactor UniversalFallback and Model with VectorOfConstraints #1234

blegat opened this issue Feb 7, 2021 · 0 comments · Fixed by #1245

Comments

@blegat
Copy link
Member

blegat commented Feb 7, 2021

With the addition of DoubleDict that maps pairs (F, S) to a container parametrized by F and S, we could create a struct VectorOfConstraints designed to hold a list of constraints as Vector{Tuple{F, S}} and efficiently handle modifications, deletion, additions, ...
Then UniversalFallback would hold a DoubleDict with a VectorOfConstraints for each constraint type and MOIU.AbstractModel would have different fields holding with VectorOfConstraints for each constraint type so that accessing the right struct is type-stable.
This has the advantages of:

  • make Utilities/model.jl more readable as part of the code will be moved to the definition of this struct.
  • share code between Utilities/model.jl and Utilities/universal_fallback.jl
  • More efficient UniversalFallback
    It will have the effect that MOIU.AbstractModel may have clashes of indices between different constraint types but this is already the case for UniversalFallback and shouldn't be breaking.

This also open the possibility to have a tighter integration with MatrixOptInterface. MatrixOptInterface could define a MatrixOfConstraints that hold a list of constraints of the same type storing the list of coefficients in a big sparse matrix (which is similar to concatenating all the constrints in a big VectorAffineFunction-in-(cartesian product of the sets). Then holding these MatrixOfConstraints in UniversalFallback and MOIU.AbstractModel instead of the VectorOfConstraints would effectively create models similar to the matrix forms in MatrixOptInterface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant