-
-
Notifications
You must be signed in to change notification settings - Fork 420
Refactor moi_function and jump_function into separate file #4190
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -757,28 +757,6 @@ function add_constraint( | |
| return add_constraint(model, con.constraint, name) | ||
| end | ||
|
|
||
| """ | ||
| jump_function(constraint::AbstractConstraint) | ||
|
|
||
| Return the function of the constraint `constraint` in the function-in-set form | ||
| as a `AbstractJuMPScalar` or `Vector{AbstractJuMPScalar}`. | ||
| """ | ||
| jump_function(constraint::AbstractConstraint) = constraint.func | ||
|
|
||
| """ | ||
| moi_function(constraint::AbstractConstraint) | ||
|
|
||
| Return the function of the constraint `constraint` in the function-in-set form | ||
| as a `MathOptInterface.AbstractFunction`. | ||
| """ | ||
| function moi_function(constraint::AbstractConstraint) | ||
| return moi_function(jump_function(constraint)) | ||
| end | ||
|
|
||
| function moi_function(model, constraint::AbstractConstraint) | ||
| return moi_function(model, jump_function(constraint)) | ||
| end | ||
|
|
||
| """ | ||
| moi_set(constraint::AbstractConstraint) | ||
|
|
||
|
|
@@ -1045,11 +1023,6 @@ function check_belongs_to_model(f::Vector, model) | |
| return | ||
| end | ||
|
|
||
| function moi_function(model, f) | ||
| check_belongs_to_model(f, model) | ||
| return moi_function(f) | ||
| end | ||
|
|
||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So this is a very weird method. It's not just a fallback. I think the only reason it was needed was because of |
||
| """ | ||
| add_constraint( | ||
| model::GenericModel, | ||
|
|
@@ -1066,6 +1039,7 @@ function add_constraint( | |
| name::String = "", | ||
| ) | ||
| con = model_convert(model, con) | ||
| check_belongs_to_model(con, model) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We just do it explicitly here now instead. |
||
| func, set = moi_function(model, con), moi_set(con) | ||
| # The type of backend(model) is unknown so we directly redirect to another | ||
| # function. | ||
|
|
||
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.
These ones were missing from #4032