Skip to content

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

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open

Move code to MOI and add JuMP layer #19

wants to merge 20 commits into from

Conversation

joaquimg
Copy link
Member

@joaquimg joaquimg commented Apr 30, 2025

close #6
close #22

  • use ModelAnalyzer.variable and similar methods in tests
  • increase codecov
  • IIS: what to do with solver parameters ? suggest constructor in docs?
  • A verbose keyword for in-analysis printing in IIS especially

Copy link

codecov bot commented Apr 30, 2025

Codecov Report

Attention: Patch coverage is 84.70907% with 113 lines in your changes missing coverage. Please review.

Project coverage is 89.91%. Comparing base (c65e636) to head (a88f0e8).

Files with missing lines Patch % Lines
src/ModelAnalyzer.jl 13.63% 38 Missing ⚠️
src/feasibility.jl 83.87% 35 Missing ⚠️
src/numerical.jl 91.50% 22 Missing ⚠️
src/infeasibility.jl 89.94% 18 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #19      +/-   ##
==========================================
- Coverage   97.05%   89.91%   -7.15%     
==========================================
  Files           5        7       +2     
  Lines        1054     1388     +334     
==========================================
+ Hits         1023     1248     +225     
- Misses         31      140     +109     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@joaquimg
Copy link
Member Author

joaquimg commented May 1, 2025

@odow
This works with the Numerical Analysis module.

Thoughts?


This variant allows summarizing a single issue instance of type `AbstractIssue`.
The model tha led to the issue can be provided to `name_source`, it will be used
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The model tha led to the issue can be provided to `name_source`, it will be used
The model that led to the issue can be provided to `name_source`, it will be used

Copy link
Member

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?

Copy link
Member Author

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

@@ -107,9 +109,11 @@ julia> ModelAnalyzer.summarize(ModelAnalyzer.Numerical.DenseConstraint)
```
"""
struct DenseConstraint <: AbstractNumericalIssue
ref::JuMP.ConstraintRef
ref::MOI.ConstraintIndex
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open question whether we should add {F,S} in many places. Not sure

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure as well, so I was keeping it simpler for now.

Comment on lines 23 to 26
# TODO: this conversion exists in JuMP, but not in MOI
S = Base.promote_op(value_fn, MOI.VariableIndex)
U = Base.promote_op(*, T, S)
out = convert(U, f.constant)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@odow and @blegat
Is there a special reason why JuMP has this and MOI does not?
Performance?

An alternative to this would be a method for converting ScalarAffineFunction{T} into ScalarAffineFunction{R}.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get it, what does not exist in MOI ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, MOI only works if the return type of the function is the same as the type of f.constant. In JuMP, we try to be more general to be more user-friendly.

data = ModelAnalyzer.analyze(
ModelAnalyzer.Feasibility.Analyzer(),
model,
primal_point = Dict(JuMP.index(x) => 1.0),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@odow this might be slightly bad for user.
We could try allowing Dict(x => 1.0): either intercepting the specific kwarg or some sort of map_variables

@joaquimg joaquimg changed the title [WIP] Move code to MOI and add JuMP layer Move code to MOI and add JuMP layer May 13, 2025
@joaquimg joaquimg requested a review from odow May 13, 2025 05:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Make JuMP a weakdep JuMP or MOI?
3 participants