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

Add VariableInSetRef and is_variable_in_set #3955

Merged
merged 1 commit into from
Mar 11, 2025
Merged

Conversation

odow
Copy link
Member

@odow odow commented Feb 28, 2025

Closes #3951

Copy link

codecov bot commented Feb 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (812a073) to head (189c1f2).
Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #3955   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           43        43           
  Lines         6054      6085   +31     
=========================================
+ Hits          6054      6085   +31     

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

@odow
Copy link
Member Author

odow commented Mar 7, 2025

So thoughts on the naming of these?

@odow odow force-pushed the od/variable-in-set branch from b6db565 to 189c1f2 Compare March 9, 2025 23:21
@odow odow changed the title Add VariableInSetRef and has_variable_in_set Add VariableInSetRef and is_variable_in_set Mar 9, 2025
@odow
Copy link
Member Author

odow commented Mar 10, 2025

Nightly is failing because it seems to have lost the ability to infer
https://github.com/jump-dev/MutableArithmetics.jl/blob/cc1be0edc797c3dff5fadbd33371b6c3aec0e158/src/reduce.jl#L42-L52

function fused_map_reduce(op::F, args::Vararg{Any,N}) where {F<:Function,N}
    _check_same_length(args...)
    T = promote_map_reduce(op, _concrete_eltype.(args)...)
    accumulator = neutral_element(reduce_op(op), T)
    buffer = buffer_for(op, T, eltype.(args)...)
    for I in zip(eachindex.(args)...)
        accumulator =
            buffered_operate!!(buffer, op, accumulator, getindex.(args, I)...)
    end
    return accumulator
end

which is kinda-not-surprising. It's pretty weird code that relies on splatting and types and stuff.

@joaquimg
Copy link
Member

I mostly like this PR very much.
Name seems fine.

My only concern is the little inconsistency on the macro variable parameters.

All(?) explicit parameters like Bin (binary=true), Int (integer=trey), Bounds (lower...)
Have their own BinaryRef, IntegerRef, LowerBoundRef...

Except for PSD, although we do not have (posdef=true).
As a user I might expect PositiveSemidefiniteSetRef.

Maybe the solution for this is to acknowledge that the PSD key is legacy and remove is almost everywhere in the docs, and only keep it is the variable macro doc with a strong recommendation for the "set =" syntax.

@blegat
Copy link
Member

blegat commented Mar 11, 2025

Yes, the PSD is mostly legacy and in PSDCone() should be used

@odow
Copy link
Member Author

odow commented Mar 11, 2025

The reason we don't have PSDRef is that it is not trivially inferable from the variable index in the way that scalar variable constraints are just the index of the variable.

I don't have strong opinions on PSD. I agree that it's a magic symbol though that doesn't actually exist which makes it hard for new users to reason about. I'll draft a PR that removes PSD from the docs and we can decide what to do.

@odow odow merged commit 3829fb2 into master Mar 11, 2025
10 of 11 checks passed
@odow odow deleted the od/variable-in-set branch March 11, 2025 20:11
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.

Constraint associated with a variable set
3 participants