Skip to content

Fix vector functions#345

Open
joaquimg wants to merge 10 commits intomasterfrom
jg/fix-vec
Open

Fix vector functions#345
joaquimg wants to merge 10 commits intomasterfrom
jg/fix-vec

Conversation

@joaquimg
Copy link
Member

Most important to agree on are the functions on jump_wrapper.jl
Later on, we will need to deprecate the MOI functions that are not compliant with #288

Claude helped me with the bridging stuff and created first version of tests.

close #103
close #283
close #288
close #305

@joaquimg joaquimg mentioned this pull request Mar 23, 2026
return MOI.set(model, attr, bridge.constraint, mapped_func)
end

"""
Copy link
Member Author

Choose a reason for hiding this comment

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

cc @blegat

return MOI.get(model, ForwardObjectiveSensitivity())
end

"""
Copy link
Member Author

Choose a reason for hiding this comment

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

cc @blegat

@codecov
Copy link

codecov bot commented Mar 23, 2026

Codecov Report

❌ Patch coverage is 96.27329% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.16%. Comparing base (e395b28) to head (9eb811b).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
src/bridges.jl 91.83% 4 Missing ⚠️
src/moi_wrapper.jl 66.66% 1 Missing ⚠️
src/parameters.jl 98.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #345      +/-   ##
==========================================
+ Coverage   90.73%   91.16%   +0.42%     
==========================================
  Files          16       16              
  Lines        2300     2457     +157     
==========================================
+ Hits         2087     2240     +153     
- Misses        213      217       +4     

☔ 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.

JuMP.backend(model),
ForwardConstraintFunction(),
JuMP.index(con_ref),
JuMP.moi_function(value),
Copy link
Member

Choose a reason for hiding this comment

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

This won't work if value is not a Vector. We actually always need to look at the shame of con_ref and do a reshaping, this will be needed for example for PSD constraints

Copy link
Member

Choose a reason for hiding this comment

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

I see JuMP.vectorize is used below, maybe it should be used here as well ?

Copy link
Member Author

Choose a reason for hiding this comment

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

unified and simplified

src/bridges.jl Outdated
) where {T}
indices = _square_to_triangle_indices(bridge)
tri_func = MOI.Utilities.eachscalar(func)[indices]
return MOI.set(model, attr, bridge.triangle, tri_func)
Copy link
Member

@blegat blegat Mar 24, 2026

Choose a reason for hiding this comment

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

ForwardConstraintFunction is set like ConstraintPrimalStart is set so you should imitate
https://github.com/jump-dev/MathOptInterface.jl/blob/b5778d01ec690e5514630ff2a2fe51ae0bd480f0/src/Bridges/Constraint/bridges/SquareBridge.jl#L328-L352
So you should also set functions to sym.

Copy link
Member Author

Choose a reason for hiding this comment

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

Now I followed very closely the MOI code


function MOI.get(
model::MOI.ModelLike,
attr::DiffOpt.ReverseConstraintFunction,
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Now I followed very closely the MOI code

@joaquimg
Copy link
Member Author

joaquimg commented Mar 24, 2026

Open question:
Do we keep model as an input argument to set_forward_constraint_function and others?
Or we just get it through owner_model?

@joaquimg joaquimg requested a review from blegat March 25, 2026 03:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants