Skip to content

RFC: Refactor moi_function and jump_function into separate file#4190

Open
odow wants to merge 1 commit into
od/restore-moi-functionfrom
od/moi-function-2
Open

RFC: Refactor moi_function and jump_function into separate file#4190
odow wants to merge 1 commit into
od/restore-moi-functionfrom
od/moi-function-2

Conversation

@odow

@odow odow commented Jul 1, 2026

Copy link
Copy Markdown
Member

x-ref #4189

We don't necessarily need to merge this. But these functions were spread all over the place. I'll comment in-line on something.

Comment thread src/callbacks.jl
function MOI.submit(model::GenericModel, cb::MOI.UserCut, con::ScalarConstraint)
return MOI.submit(backend(model), cb, moi_function(con.func), con.set)
f = moi_function(model, con.func)
return MOI.submit(backend(model), cb, f, con.set)

Copy link
Copy Markdown
Member Author

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

Comment thread src/constraints.jl
check_belongs_to_model(f, model)
return moi_function(f)
end

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The 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 check_belongs_to_model?

Comment thread src/constraints.jl
name::String = "",
)
con = model_convert(model, con)
check_belongs_to_model(con, model)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We just do it explicitly here now instead.

Comment thread src/jump_moi_function.jl

# A default fallback for backwards compatibility. The first argument `model` was
# introduced in JuMP@1.31.0.
moi_function(model, f) = moi_function(f)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

And now I have a much more sensible fallback.

@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.85%. Comparing base (9e33fcd) to head (a5d35f1).

Additional details and impacted files
@@                     Coverage Diff                     @@
##           od/restore-moi-function    #4190      +/-   ##
===========================================================
- Coverage                    99.93%   99.85%   -0.08%     
===========================================================
  Files                           42       43       +1     
  Lines                         6277     6276       -1     
===========================================================
- Hits                          6273     6267       -6     
- Misses                           4        9       +5     

☔ View full report in Codecov by Harness.
📢 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.

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.

1 participant