Skip to content
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

Refactor GeomMeanEpiCone into GenericConstraint #604

Merged
merged 13 commits into from
May 7, 2024
Merged

Conversation

blegat
Copy link
Member

@blegat blegat commented Apr 23, 2024

This is an attempt to refactor GeomMeanEpiCone into GenericConstraint. In the long term (meaning definitely post v0.16), we can replace the custom _add_constraint with a bridge so that the cone can be used in JuMP as well.
If we do the same for the two other remaining constraints, we can then get rid of abstract type Constraint and rename GenericConstraint into Constraint.
This design is blocked by #603

@odow
Copy link
Member

odow commented Apr 25, 2024

I don't particularly like this design. The "Convex.jl" approach would probably be to add a TupleAtom?

Copy link

codecov bot commented Apr 25, 2024

Codecov Report

Attention: Patch coverage is 97.87234% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 97.84%. Comparing base (bb17c4c) to head (02c96ab).
Report is 3 commits behind head on master.

Files Patch % Lines
src/expressions.jl 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #604      +/-   ##
==========================================
+ Coverage   97.82%   97.84%   +0.02%     
==========================================
  Files          88       88              
  Lines        5140     5112      -28     
==========================================
- Hits         5028     5002      -26     
+ Misses        112      110       -2     

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

@blegat
Copy link
Member Author

blegat commented Apr 25, 2024

It's the concatenation that should belong to the cone so we should use a vcat atom (which is seems gets rewritten with hcat and reshapes). If getindex on a vcat atom, would check if the index fit exactly in one of the argument of vcat and then in that case unwrap the vcat atom then it would fix #603

@odow odow mentioned this pull request May 2, 2024
@blegat
Copy link
Member Author

blegat commented May 6, 2024

Now that #603 is fixed, I reverted the Tuple approach

@blegat
Copy link
Member Author

blegat commented May 6, 2024

I had to refactor a bit in e220a8e to work around this bug of JuliaFormatter: domluna/JuliaFormatter.jl#833


function GeomMeanEpiConeConstraint(T::Value, cone::GeomMeanEpiCone)
return GeomMeanEpiConeConstraint(constant(T), cone)
function Base.in(func::Tuple, set::GeomMeanEpiConeSquare)
Copy link
Member Author

Choose a reason for hiding this comment

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

We should probably get rid of this as it will become type piracy once GeomMeanEpiConeSquare is moved to MOI

Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe we can have syntax like (A,B,C) in Constraint(MOI.GeomMeanEpiConeSquare()) instead, where Constraint would be owned by Convex

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this can be a follow up PR

Copy link
Member

Choose a reason for hiding this comment

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

Let's just make this GenericConstraint(::Tuple, ::GeometricMeanEpiConeSquare) for now?

Copy link
Member

Choose a reason for hiding this comment

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

Or Base.in(f::AbstractExpr, set::MOI.AbstractSet) = GenericConstraint(f, set)? Why do we need the tuple? Why not vcat(T, A, B)?

Copy link
Member Author

Choose a reason for hiding this comment

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

It was just be able to throw the DimensionMismatch errors

Copy link
Member Author

Choose a reason for hiding this comment

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

We can also just have some internal utility for now

Copy link
Member Author

Choose a reason for hiding this comment

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

Like we did for _add_vectorized_exp_cone

Copy link
Member

Choose a reason for hiding this comment

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

How about now? I've just gone for explicit Convex.GenericConstraint.

test/test_constraints.jl Outdated Show resolved Hide resolved
odow and others added 2 commits May 7, 2024 16:01
Co-authored-by: Benoît Legat <benoit.legat@gmail.com>
@blegat
Copy link
Member Author

blegat commented May 7, 2024

Looks good to me, any objection to merge ?

@blegat blegat merged commit 96904be into master May 7, 2024
10 checks passed
@odow odow deleted the bl/geomeanepicone branch May 8, 2024 02:52
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.

None yet

3 participants