HiGHS icon indicating copy to clipboard operation
HiGHS copied to clipboard

QP solver infinite loop

Open jajhall opened this issue 1 year ago • 8 comments

For the following very simple QP, the solver gets into an infinite loop

#include "Highs.h" int main() { HighsModel model; HighsLp& lp = model.lp_; HighsHessian& hessian = model.hessian_; lp.num_col_ = 2; lp.num_row_ = 2; lp.col_cost_ = {0, 1}; lp.col_lower_ = {0, 0}; lp.col_upper_ = {kHighsInf, kHighsInf}; lp.a_matrix_.start_ = {0, 2, 4}; lp.a_matrix_.index_ = {0, 1, 0, 1}; lp.a_matrix_.value_ = {800, 400, 1, 1}; lp.row_lower_ = {40000, 30000}; lp.row_upper_ = {kHighsInf, kHighsInf}; hessian.dim_ = lp.num_col_; hessian.start_ = {0, 1, 1}; hessian.index_ = {0}; hessian.value_ = {6}; Highs highs; highs.passModel(model); highs.setOptionValue("time_limit", 0.1); highs.run(); exit(1); }

It also exposes a bug when the time limit is reached for a QP

jajhall avatar Jan 15 '24 12:01 jajhall

Thanks, will try to reproduce and fix

feldmeier avatar Jan 15 '24 13:01 feldmeier

The loop arises as the QP solver wrongly thinks that the search direction in the second iteration doesn't have curvature (p'Qp is less than a threshold) and thus oversteps. It is fixed by tightening the threshold in computemaxsteplength() in quass.cpp to e.g. 10E-8. I'll need to check whether this potential fix negatively impacts any other instances. I'll also move the hard coded threshold into a solver setting.

What's the issue with the time limit?

feldmeier avatar Jan 16 '24 21:01 feldmeier

I think the time limit is just that the solver doesn't terminate until it hits the time limit.

We don't necessarily need to fix the tolerance (the model is arguably poorly scaled), but if it starts to cycle ideally we should detect that and terminate.

odow avatar Jan 16 '24 21:01 odow

The QP solver stops OK on the time limit, but the next level of HiGHS doesn't handle the situation correctly

That's for me to fix

jajhall avatar Jan 16 '24 21:01 jajhall

I'll see what I can do. Detecting overstepping (objective getting worse) is easy, Detecting a loop of length 2 should be doable, but arbitrary length loops without objective change takes massive housekeeping to detect

feldmeier avatar Jan 16 '24 21:01 feldmeier

The simplex solvers have a system for identifying cycling - written by @lgottwald - that hashes a basis to see whether there is a possible repetition. Still non-trivial, though

jajhall avatar Jan 16 '24 22:01 jajhall

Tightening the tolerance doesn't appear to break any other QP instances. I'll leave cycle detection for when I'm done with my dissertation

feldmeier avatar Jan 17 '24 23:01 feldmeier