-
Notifications
You must be signed in to change notification settings - Fork 87
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
Add CanonicalConstraintFunction attribute #1118
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we agreed that solvers should just check if the function was canonicalized. What is the benefit of having ConstraintFunction
and CanonicalizedConstraintFunction
?
Couldn't we just make it that all solvers return canonicalized functions?
Many times we dont need cannonicalized functions. |
Any objection to merge ? |
struct CanonicalConstraintFunction <: AbstractConstraintAttribute end | ||
|
||
function get_fallback(model::ModelLike, ::CanonicalConstraintFunction, ci::ConstraintIndex) | ||
return Utilities.canonical(get(model, ConstraintFunction(), ci)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the is_canonical
check go in this fallback? It would save the checks in Model
and UniversalFallback
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done :)
For models that knows that the constraint function is already canonical they can just
For
MOI.Utilities.Model
, the function are not canonicalized when added (should we ?) so we canonicalize them thenCanonicalConstraintFunction
is called to spare thecopy
that is done inMOI.Utilities.canonical
as it can slows things down dramatically (see jump-dev/SCS.jl#186).Alternatively, we could say that the functions added to
MOI.Utilities.Model
are automatically canonicalized in addition of being copied by replacing thiscopy(f)
bycanonical(f)
:MathOptInterface.jl/src/Utilities/model.jl
Line 550 in 26e0af4