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

Merged
merged 36 commits into from
May 24, 2025
Merged

Move code to MOI and add JuMP layer #19

merged 36 commits into from
May 24, 2025

Conversation

joaquimg
Copy link
Member

@joaquimg joaquimg commented Apr 30, 2025

close #6
close #22
close #24

  • 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 98.59155% with 10 lines in your changes missing coverage. Please review.

Project coverage is 98.52%. Comparing base (c65e636) to head (2fc4f3f).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/feasibility.jl 97.77% 5 Missing ⚠️
src/numerical.jl 98.84% 3 Missing ⚠️
src/infeasibility.jl 98.76% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #19      +/-   ##
==========================================
+ Coverage   97.05%   98.52%   +1.46%     
==========================================
  Files           5        7       +2     
  Lines        1054     1357     +303     
==========================================
+ Hits         1023     1337     +314     
+ Misses         31       20      -11     

☔ 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
@joaquimg joaquimg merged commit 8ba404c into main May 24, 2025
9 checks passed
@joaquimg joaquimg deleted the jg/moi branch May 24, 2025 08:47
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.

Feasibility: Dualization should use the mode with constrained variables Make JuMP a weakdep JuMP or MOI?
3 participants