-
Notifications
You must be signed in to change notification settings - Fork 5
Add InfiniteOpt as an Extension #130
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?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #130 +/- ##
=========================================
Coverage ? 99.19%
=========================================
Files ? 17
Lines ? 1862
Branches ? 0
=========================================
Hits ? 1847
Misses ? 15
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| vars = collect(JuMP.all_variables(model)) | ||
| derivs = collect(InfiniteOpt.all_derivatives(model)) |
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.
Here, collect is unnecessary, the functions already provide you with a vector.
| function DP.collect_all_vars(model::InfiniteOpt.InfiniteModel) | ||
| vars = collect(JuMP.all_variables(model)) | ||
| derivs = collect(InfiniteOpt.all_derivatives(model)) | ||
| return vcat(vars, derivs) |
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.
more efficient would be append!(vars, derivs)
| function _is_parameter(vref::InfiniteOpt.GeneralVariableRef) | ||
| dref = InfiniteOpt.dispatch_variable_ref(vref) | ||
| if typeof(dref) <: Union{ | ||
| InfiniteOpt.DependentParameterRef, | ||
| InfiniteOpt.IndependentParameterRef, | ||
| InfiniteOpt.ParameterFunctionRef, | ||
| InfiniteOpt.FiniteParameterRef | ||
| } | ||
| return true | ||
| else | ||
| return false | ||
| end | ||
| end |
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 we use multiple dispatch here?
| return DP.VariableProperties(info, "", nothing, var_type) | ||
| end | ||
|
|
||
| function DP.VariableProperties(exprs::Vector{<:Union{InfiniteOpt.GeneralVariableRef, JuMP.GenericAffExpr{<:Any, InfiniteOpt.GeneralVariableRef}, JuMP.GenericQuadExpr{<:Any, InfiniteOpt.GeneralVariableRef}}}) |
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.
This line needs to be broken up
| Returns all variable references in the model. | ||
| Extend this for model types that have additional ref types (e.g., derivatives). | ||
| """ | ||
| collect_all_vars(model::JuMP.AbstractModel) = collect(JuMP.all_variables(model)) |
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 am not sure whether collect is needed here
test/runtests.jl
Outdated
|
|
||
| if Base.VERSION >= v"1" # extensions require Julia v1.10+ | ||
| import Pkg | ||
| Pkg.add(url = "https://github.com/infiniteopt/InfiniteOpt.jl", rev = "master") | ||
| include("extensions/InfiniteDisjunctiveProgramming.jl") | ||
| end |
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.
This can be deleted
test/runtests.jl
Outdated
| # include("aqua.jl") # temporary ignore until compat is finalized | ||
| # include("model.jl") | ||
| # include("jump.jl") |
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.
Let's be sure to bring these back
| Juniper = "0.9.3" | ||
| Ipopt = "1.9.0" | ||
| InfiniteOpt = "0.6" | ||
| Pkg ="1" |
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.
We don't need this
| HiGHS = "87dc4568-4c63-4d18-b0c0-bb2238e4078b" | ||
| InfiniteOpt = "20393b10-9daf-11e9-18c9-8db751c92c57" | ||
| Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
| Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" |
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.
Not needed
|
|
||
| [targets] | ||
| test = ["Aqua", "HiGHS", "Test", "Juniper", "Ipopt"] | ||
| test = ["Aqua", "HiGHS", "Test", "Juniper", "Ipopt","Pkg","InfiniteOpt"] |
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.
We don't need Pkg
Working version of #114 .
This adds an extension such that DisjunctiveProgramming is compatible with InfiniteOpt. It overloads the needed functions and provide the InfiniteGDPModel and InfiniteLogical functions.
A basic example is shown below:
As of right now, Hull, BigM, Indicator, and PSplit methods will function. Cutting Planes and Multiple BigM methods will be added in the future.