jump-dev / MathOptInterface.jl

A data structure for mathematical optimization problems
http://jump.dev/MathOptInterface.jl/
Other
380 stars 86 forks source link

[Bridges] use dual of equality in slack bridge (take 2) #2515

Closed blegat closed 1 month ago

blegat commented 1 month ago

We can take inspiration from https://github.com/jump-dev/MathOptInterface.jl/blob/08d34003cd3d7500379d9440e92445bc4d9a8fa8/src/Bridges/Constraint/bridges/set_dot_scaling.jl#L64-L75

Closes https://github.com/jump-dev/MathOptInterface.jl/issues/2513

odow commented 1 month ago

https://github.com/jump-dev/MathOptInterface.jl/actions/runs/9531770131

odow commented 1 month ago

Still the same problem: https://github.com/jump-dev/MathOptInterface.jl/actions/runs/9531770131/job/26273074388

image

There's a suspicious 1 / sqrt(2) there, so perhaps we need 1 / scale^2 somewhere?

odow commented 1 month ago

https://github.com/jump-dev/MathOptInterface.jl/actions/runs/9539455292

odow commented 1 month ago

The COPT failure is unrelated: https://github.com/COPT-Public/COPT.jl/pull/40

odow commented 1 month ago

I don't fully understand the math logic, but the code does something like set_dot(scale * x, scale * y), which is more or less equivalent to sum(scale.^2 .* x .* y), so to reverse, we need to divide by scale.^2.

blegat commented 1 month ago

Yes, the trick is to keep the same term in the Lagrangian. The equality constraints gives the term <dual, primal> with the standard inner product but <dual, primal>_PSD is like scaling each entry of dual and primal by the entry of SetDotScalingVector so dividing by the square makes sense

blegat commented 1 month ago

Maybe we should add a test in test/Bridges/Constraint/slack.jl

odow commented 1 month ago

I've added a test that triggers the scale and tweaked the comments. I also needed to update the MOI.set for ::ConstraintDualStart because it didn't scale things either.

As a more general comment: our tests just check that get/set is a round-trip. We can't easily automatically test that the numeric values are correct.

odow commented 1 month ago

Let's just double check:

https://github.com/jump-dev/MathOptInterface.jl/actions/runs/9556803924