Operators from Binf to Box constraints#149
Operators from Binf to Box constraints#149arnavk23 wants to merge 40 commits intoJuliaSmoothOptimizers:masterfrom
Conversation
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ocations in group prox implementations; update includes and tests (follow PR #104 pattern)
…lear norm, rank, and IndBallL0 Box
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…perations with in-place loops and explicit χ-norm projection; fix prox! to avoid temporaries and ensure robust root-bracketing.
…c_allocs!/J_allocs! in allocs tests to avoid method overwrites
|
@dpo Fixed issues in tests, like allocations which are causing error also in Maxence's pr as mentioned here #150 (comment) |
MaxenceGollier
left a comment
There was a problem hiding this comment.
I am not sure to understand the point of this PR.
Are you trying to remove allocations or to fix #88 ?
Moreover, you can not fix tests by letting the operators allocate.
There was a problem hiding this comment.
Pull request overview
This PR generalizes shifted proximal operators from Binf (L∞-ball) constraints to Box constraints, enabling support for arbitrary box bounds [l, u]. The changes maintain backward compatibility by providing adapter methods that convert legacy Binf signatures (Δ, χ) to the new Box constraint format [-Δ, Δ]. Additionally, the PR includes performance optimizations across several operators to reduce allocations.
Key changes:
- Introduced
ShiftedIndBallL0BoxandShiftedGroupNormL2Boxas generalized Box constraint operators - Added backward compatibility methods in the new Box files to handle legacy Binf signatures
- Removed includes for old Binf files from the main module while keeping the files in the repository
- Applied allocation-reducing optimizations to SVD-based operators and other performance-critical paths
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/ShiftedProximalOperators.jl |
Replaced Binf file includes with Box file includes; added property accessors for backward compatibility; optimized function evaluation |
src/shiftedIndBallL0Box.jl |
New file implementing generalized Box constraints for IndBallL0 with backward compatibility methods |
src/shiftedGroupNormL2Box.jl |
New file implementing generalized Box constraints for GroupNormL2/NormL2 with backward compatibility methods |
src/shiftedIndBallL0BInf.jl |
Removed the legacy shifted() constructor (moved to Box variant) |
src/shiftedGroupNormL2Binf.jl |
Removed legacy shifted() constructors (moved to Box variants); optimized prox! to reduce allocations |
src/shiftedNormL1B2.jl |
Refactored prox! for reduced allocations and improved numerical stability |
src/shiftedRank.jl |
Optimized prox! with in-place operations to avoid temporaries |
src/shiftedNuclearnorm.jl |
Optimized prox! with in-place operations to avoid temporaries |
src/Nuclearnorm.jl |
Optimized prox! with copyto! and in-place operations |
src/psvd.jl |
Removed complex number divide-and-conquer SVD implementations; fixed type conversion and various bugs; moved psvd() function |
test/test_allocs.jl |
Updated macro and switched from @allocated to @wrappedallocs for more accurate allocation testing |
test/runtests.jl |
Updated test expectations to use Box variants; added comprehensive tests for new Box operators; adjusted tolerance for numerical comparisons |
Comments suppressed due to low confidence (3)
src/psvd.jl:466
- The complex number SVD implementations for the divide-and-conquer algorithm (psvd_workspace_dd and psvd_dd! for ComplexF32 and ComplexF64) were completely removed from the file. However, the complex number implementations for QRIteration algorithm remain. This creates an asymmetry where complex matrices can only use QRIteration algorithm but not the divide-and-conquer algorithm. If this is intentional, it should be documented. If not, this is a breaking change that removes functionality.
end
end
end
src/ShiftedProximalOperators.jl:160
- When accessing ψ.Δ on a Box variant with vector bounds where elements have different symmetric constraints (e.g., l = [-0.5, -0.3], u = [0.5, 0.3]), this code will return u[1] (0.5) even though the second element has a different radius (0.3). This is incorrect and could lead to silent bugs. The code should either error for non-uniform bounds or return the vector of radii.
fun_expr(ψ::ShiftedProximableFunction) = "t ↦ h(xk + sj + t)"
fun_params(ψ::ShiftedProximableFunction) = "xk = $(ψ.xk)\n" * " "^14 * "sj = $(ψ.sj)"
src/ShiftedProximalOperators.jl:170
- Returning a dummy Conjugate(IndBallL1(1.0)) for Box variants when accessing ψ.χ is misleading and could cause subtle bugs. The actual constraints are Box constraints with bounds [l, u], not L∞-ball constraints with conjugate IndBallL1. If the χ field doesn't exist on Box variants, accessing it should either error clearly or return a value that accurately represents the constraints.
show(io, ψ.h)
end
"""
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This reverts commit 0d32e4a.
This PR successfully generalizes shifted proximal operators from Binf (L∞-ball) constraints to Box constraints, enabling support for arbitrary box bounds [l, u] while maintaining backward compatibility with symmetric constraints [-Δ, Δ].
Key Changes
Continues from #144, #148, #147
Fixes #88