-
Notifications
You must be signed in to change notification settings - Fork 92
VectorAffineFunction easy constructor #2626
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
Conversation
I'm in favor of this. It hurts me every time I try to create a VAF. Thoughts on VectorQuadraticFunction as well? |
I'll take a shot in the next days, it will be in a separate PR |
I can do it |
I'm not sure we need this since we already have |
the constructor is easier to discover and search for, it has zero cost, gives you a way to construct the VAF that is close to the way it's printed, and the mental model makes sense -> constructing a vector affine expression takes a vector of scalar affine expressions. MOI.Utilities.vectorize or MOI.Utilities.operate are both awkward to use constructors in disguise IMO |
We could consider having two names for the same thing but we shouldn't duplicate the implementation. One of the two should call the other one |
We could document But case in point: I forget about |
Yes, and vectorize should call the constructor instead of duplicating the code |
I like this PR, I almost wrote it twice recently. |
Nah we should go the other way around: vectorize use this constructor. I can update the PR. |
Now the code is a bit weird. |
A more naive constructor is not terrible for tests as functions would be small. But |
Closing in favor of #2636 |
VectorAffineFunction has always been a massive pain to construct.
This added constructor builds one from a vector of scalar affine functions, which is the mental model most people will have from a VAF.
This can drastically simplify a lot of code