Foggalong / RobustOCS

Robust optimal contirbution selection problems for genetics with Python
https://pypi.org/project/robustocs
MIT License
1 stars 0 forks source link

Maximum Duality Gap in HiGHS #27

Closed Foggalong closed 1 month ago

Foggalong commented 1 month ago

At the moment the solvers which use HiGHS don't make use of max_duality_gap in the same way it is used with Gurobi. Any parameter passed in that case is just ignored.

While HiGHS doesn't have a quick attribute to set a maximum like Gurobi does, the same functionality could still be implemented on our end to keep the two on feature parity.

jajhall commented 1 month ago

While HiGHS doesn't have a quick attribute to set a maximum like Gurobi does, the same functionality could still be implemented on our end to keep the two on feature parity.

It does, but there's no need to set max_duality_gap for HiGHS, as you're only ever solving continuous QPs, and it's a parameter used when solving MIPs.

If Gurobi used it at all, it was when it was mistakenly solving a nonconvex problem due to the error in gurobipy interpreting innerprod

Foggalong commented 1 month ago

Huh okay, I think I may have misunderstood what this was controlling then when looking at Gurobi's output. Will go back and review.

jajhall commented 1 month ago

Will go back and review.

Not a priority: it corresponded to an error that's now been corrected.

Foggalong commented 1 month ago

I more meant reviewing where this is mentioned in code so that it can be corrected / removed where needed.

Foggalong commented 1 month ago

Yeah looking back I entirely missed that this was a MIP-specific parameter, even though it's set using

model.setParam('MIPGap', max_duality_gap)

and is explicit in the docs that it only takes effect for MIPs. In my head this was doing the same type of check at each SQP iteration but clearly that's not needed.

                  Objective                Residual
Iter       Primal          Dual         Primal    Dual     Compl     Time
   0  -1.20860312e+05  2.11304339e+05  2.50e+04 2.24e+00  3.27e+05     0s
   1  -1.44390122e+03  1.17564418e+03  6.19e+02 1.36e+01  8.33e+03     0s
   2  -3.10345731e+03  5.85361009e+02  1.22e-01 2.27e-07  3.32e+01     0s
   3  -1.30888015e+00  2.34548696e+01  3.32e-06 6.20e-12  2.12e-01     0s
   4   1.79106695e+00  2.25759242e+00  4.95e-08 9.23e-14  3.99e-03     0s
   5   1.84454291e+00  1.93778992e+00  2.13e-10 4.02e-16  7.97e-04     0s
   6   1.91968740e+00  1.92673678e+00  1.33e-15 1.33e-15  6.03e-05     0s
   7   1.92327553e+00  1.92347963e+00  1.11e-15 1.78e-15  1.74e-06     0s
   8   1.92337269e+00  1.92338338e+00  3.20e-13 1.33e-15  9.14e-08     0s
   9   1.92337765e+00  1.92337797e+00  8.87e-12 1.11e-15  2.80e-09     0s
  10   1.92337782e+00  1.92337783e+00  9.58e-11 8.88e-16  4.20e-11     0s

Will push a commit to remove that now :+1:

Foggalong commented 1 month ago

Fixed in 9544057