Skip to content

Commit a20b869

Browse files
authored
Merge pull request #2830 from ERGO-Code/fix-2489
Fix 2489
2 parents 0a84909 + c5da8e8 commit a20b869

File tree

4 files changed

+46
-15
lines changed

4 files changed

+46
-15
lines changed

check/TestQpSolver.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,3 +1138,39 @@ TEST_CASE("rowless-qp", "[qpsolver]") {
11381138

11391139
highs.resetGlobalScheduler(true);
11401140
}
1141+
1142+
TEST_CASE("2489", "[qpsolver]") {
1143+
// This QP is
1144+
//
1145+
// Min, x^2/2 + x
1146+
//
1147+
// 0*x + 0*y <= 1
1148+
//
1149+
// -10 <= (x, y) <= 10
1150+
//
1151+
// Hence it has a constraint, but its coefficients are zero
1152+
Highs h;
1153+
h.setOptionValue("output_flag", dev_run);
1154+
REQUIRE(h.setOptionValue("log_dev_level", 3) == HighsStatus::kOk);
1155+
REQUIRE(h.setOptionValue("time_limit", 3) == HighsStatus::kOk);
1156+
REQUIRE(h.setOptionValue("qp_iteration_limit", 10) == HighsStatus::kOk);
1157+
REQUIRE(h.addCol(1.0, -10.0, 10.0, 0, NULL, NULL) == HighsStatus::kOk);
1158+
REQUIRE(h.addCol(0.0, -10.0, 10.0, 0, NULL, NULL) == HighsStatus::kOk);
1159+
REQUIRE(h.addRow(0.0, 0.0, 0, NULL, NULL) == HighsStatus::kOk);
1160+
HighsHessian hessian;
1161+
hessian.dim_ = 1;
1162+
hessian.format_ = HessianFormat::kTriangular;
1163+
hessian.start_ = {0, 1};
1164+
hessian.index_ = {0};
1165+
hessian.value_ = {1.0};
1166+
REQUIRE(h.passHessian(hessian) == HighsStatus::kOk);
1167+
HighsStatus run_status = h.run();
1168+
if (dev_run)
1169+
printf("Test 2489: run_status = %s\n",
1170+
run_status == HighsStatus::kError ? "Error"
1171+
: run_status == HighsStatus::kWarning ? "Warning"
1172+
: "OK");
1173+
REQUIRE(run_status == HighsStatus::kWarning);
1174+
1175+
h.resetGlobalScheduler(true);
1176+
}

highs/lp_data/Highs.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4010,7 +4010,11 @@ HighsStatus Highs::callSolveQp() {
40104010
Statistics stats;
40114011

40124012
settings.reportingfequency = 100;
4013-
4013+
if (options_.qp_iteration_limit <= 10) {
4014+
settings.reportingfequency = 1;
4015+
} else if (options_.qp_iteration_limit <= 100) {
4016+
settings.reportingfequency = 10;
4017+
}
40144018
// Setting qp_update_limit = 10 leads to error with lpHighs3
40154019
const HighsInt qp_update_limit = 1000; // 1000; // default
40164020
if (qp_update_limit != settings.reinvertfrequency) {

highs/model/HighsHessianUtils.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,11 @@ void completeHessianDiagonal(const HighsOptions& options,
126126
num_missing_diagonal_entries++;
127127
}
128128
}
129-
highsLogDev(options.log_options, HighsLogType::kInfo,
130-
"Hessian has dimension %d and %d nonzeros: inserting %d zeros "
131-
"onto the diagonal\n",
132-
(int)dim, (int)num_nz, (int)num_missing_diagonal_entries);
129+
if (num_missing_diagonal_entries > 0)
130+
highsLogDev(options.log_options, HighsLogType::kInfo,
131+
"Hessian has dimension %d and %d nonzeros: inserting %d zeros "
132+
"onto the diagonal\n",
133+
int(dim), int(num_nz), int(num_missing_diagonal_entries));
133134
assert(num_missing_diagonal_entries >= dim - num_nz);
134135
if (!num_missing_diagonal_entries) return;
135136
// There are missing diagonal entries to be inserted as explicit zeros

highs/qpsolver/basis.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,6 @@ void Basis::build() {
6464
baseindex[counter++] = i;
6565
}
6666

67-
const bool empty_matrix = (int)Atran.index.size() == 0;
68-
if (empty_matrix) {
69-
// The index/value vectors have size zero if the matrix has no
70-
// columns. However, in the Windows build, referring to index 0 of a
71-
// vector of size zero causes a failure, so resize to 1 to prevent
72-
// this.
73-
assert(Atran.num_col == 0);
74-
Atran.index.resize(1);
75-
Atran.value.resize(1);
76-
}
7767
basisfactor.setup(Atran.num_col, Atran.num_row, Atran.start.data(),
7868
Atran.index.data(), Atran.value.data(), baseindex.data());
7969
basisfactor.build();

0 commit comments

Comments
 (0)