-
Notifications
You must be signed in to change notification settings - Fork 1
Move code to MOI and add JuMP layer #19
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
Merged
Changes from 4 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
4018990
Move code to MOI and add JuMP layer
joaquimg 4f716b0
format
joaquimg 3185a6f
Improve API
joaquimg cea96e6
fixes
joaquimg 7b0c0a2
name_source -> model
joaquimg 2c79007
suggestions
joaquimg 9241ee1
small fix
joaquimg 9c83751
Merge branch 'main' into jg/moi
joaquimg ed42075
feasibility almost ready
joaquimg 87aacb2
Finish feasibility rewrite
joaquimg e378889
Merge branch 'main' into jg/moi
joaquimg 85e00fb
MOI infeasibility analysis
joaquimg 38ae419
use MA
joaquimg 2e39b0c
MOI IIS
joaquimg 997200a
format
joaquimg e059c41
add query functions in numerical
joaquimg fc09db0
format
joaquimg f0d70fa
Add query tools
joaquimg 833e6c1
Add query tools
joaquimg a88f0e8
add tests
joaquimg 1cd08a3
add tests
joaquimg b5253c7
add tests
joaquimg 4fc7565
add comments
joaquimg 5ecd302
simplify api
joaquimg ceccb9f
cleanup api
joaquimg 97cde56
add tests
joaquimg 0b3e9e4
add tests
joaquimg e1288d6
format
joaquimg e719b96
more tests
joaquimg 7e36757
more tests
joaquimg 90903ee
fix and test
joaquimg 1426502
add tests and cleanup
joaquimg 6f641ad
format
joaquimg e9035d7
add features and tests
joaquimg ad37c02
add tests
joaquimg 2fc4f3f
add docs
joaquimg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import JuMP | ||
joaquimg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# struct JuMPData{T<:AbstractData} <: ModelAnalyzer.AbstractData | ||
# data::T | ||
# model::JuMP.Model | ||
# end | ||
|
||
# struct JuMPIssue{T<:AbstractIssue} <: ModelAnalyzer.AbstractIssue | ||
# issue::T | ||
# model::JuMP.Model | ||
# end | ||
joaquimg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
function ModelAnalyzer.analyze( | ||
analyzer::T, | ||
model::JuMP.Model; | ||
joaquimg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
kwargs..., | ||
) where {T<:ModelAnalyzer.AbstractAnalyzer} | ||
moi_model = JuMP.backend(model) | ||
result = ModelAnalyzer.analyze(analyzer, moi_model; kwargs...) | ||
joaquimg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# return JuMPData(result, model) | ||
return result | ||
end | ||
|
||
function ModelAnalyzer._name(ref::MOI.VariableIndex, model::JuMP.Model) | ||
jump_ref = JuMP.VariableRef(model, ref) | ||
joaquimg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
name = JuMP.name(jump_ref) | ||
if !isempty(name) | ||
return name | ||
end | ||
return "$jump_ref" | ||
end | ||
|
||
function ModelAnalyzer._name(ref::MOI.ConstraintIndex, model::JuMP.Model) | ||
jump_ref = JuMP.constraint_ref_with_index(model, ref) | ||
name = JuMP.name(jump_ref) | ||
if !isempty(name) | ||
return name | ||
end | ||
return "$jump_ref" | ||
end | ||
|
||
""" | ||
variable(issue::ModelAnalyzer.AbstractIssue, model::JuMP.Model) | ||
|
||
Return the **JuMP** variable reference associated to a particular issue. | ||
""" | ||
function ModelAnalyzer.variable( | ||
issue::ModelAnalyzer.AbstractIssue, | ||
model::JuMP.Model, | ||
) | ||
ref = ModelAnalyzer.variable(issue) | ||
return JuMP.VariableRef(model, ref) | ||
end | ||
|
||
""" | ||
variables(issue::ModelAnalyzer.AbstractIssue, model::JuMP.Model) | ||
|
||
Return the **JuMP** variable references associated to a particular issue. | ||
""" | ||
function ModelAnalyzer.variables( | ||
issue::ModelAnalyzer.AbstractIssue, | ||
model::JuMP.Model, | ||
) | ||
refs = ModelAnalyzer.variables(issue) | ||
return JuMP.VariableRef.(model, refs) | ||
end | ||
|
||
""" | ||
constraint(issue::ModelAnalyzer.AbstractIssue, model::JuMP.Model) | ||
|
||
Return the **JuMP** constraint reference associated to a particular issue. | ||
""" | ||
function ModelAnalyzer.constraint( | ||
issue::ModelAnalyzer.AbstractIssue, | ||
model::JuMP.Model, | ||
) | ||
ref = ModelAnalyzer.constraint(issue) | ||
return JuMP.constraint_ref_with_index(model, ref) | ||
end |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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.
Why not just
; model::Union{Nothing,JuMP.AbstractModel} = nothing
?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.
Fixed!
I don't want to type this because I want to have JuMP as a weakdep