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

Implement bisection for gradient proj of power cone #84

Merged
merged 10 commits into from
Jan 14, 2025

Conversation

blegat
Copy link
Collaborator

@blegat blegat commented Jan 12, 2025

I had a lot of warnings when running the tests, the bisection method should solve them. Bisection is also the method recommended by the paper.

Comment on lines 390 to 393
const DEFAULT_POWER_CONE_MAX_ITERS_NEWTON = 100
const DEFAULT_POWER_CONE_MAX_ITERS_BISSECTION = 1_000
const DEFAULT_POWER_CONE_TOL_CONV = 1e-7
const DEFAULT_POWER_CONE_TOL_IN_CONE = 1e-10
Copy link
Collaborator

Choose a reason for hiding this comment

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

I did not optimize these a lot.

Comment on lines 584 to 588
r = if isnan(r_newton) || abs(Φ_newton) > abs(Φ_bissection)
r_bissection
else
r_newton
end
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should use the best we have.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I'm guessing it's always going to be bisection with Float64 because it can go all the way to epsilon precision but for BigFloat, Newton could win ^^

@blegat
Copy link
Collaborator Author

blegat commented Jan 13, 2025

We should add at least one test where Newton was failing

@joaquimg
Copy link
Collaborator

you mean explicitly?

Because bisection is being called a few times.

Φ_bisection = _power_cone_system(r_bisection, x, y, z, α)
if abs(Φ_bisection) > tol
# This happens for instance for
# `_solve_system_power_cone([-10, 10, 1e-3], MOI.PowerCone(0.15))`
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

An example like this used to throw the warning because Newton was just returning 0 or abs(z). I'm surprised the tests were actually passing. The bisection does much better on these so we should have tests that fail for these and pass thanks to this PR

@blegat blegat merged commit ab9433a into master Jan 14, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants