Skip to content

Commit 37951b4

Browse files
committed
Needs more wotk than I've got time for ATM
1 parent e1d1477 commit 37951b4

File tree

4 files changed

+36
-17
lines changed

4 files changed

+36
-17
lines changed

check/TestQpSolver.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,3 +1138,31 @@ 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+
assert(h.setOptionValue("log_dev_level", 3) == HighsStatus::kOk);
1155+
assert(h.addCol(1.0, -10.0, 10.0, 0, NULL, NULL) == HighsStatus::kOk);
1156+
assert(h.addCol(0.0, -10.0, 10.0, 0, NULL, NULL) == HighsStatus::kOk);
1157+
assert(h.addRow(0.0, 0.0, 0, NULL, NULL) == HighsStatus::kOk);
1158+
HighsHessian hessian;
1159+
hessian.dim_ = 1;
1160+
hessian.format_ = HessianFormat::kTriangular;
1161+
hessian.start_ = {0, 1};
1162+
hessian.index_ = {0};
1163+
hessian.value_ = {1.0};
1164+
assert(h.passHessian(hessian) == HighsStatus::kOk);
1165+
assert(h.run() == HighsStatus::kOk);
1166+
1167+
h.resetGlobalScheduler(true);
1168+
}

highs/interfaces/highs_c_api.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ HighsInt Highs_mipCall(const HighsInt num_col, const HighsInt num_row,
108108
}
109109

110110
highs.resetGlobalScheduler(true);
111-
111+
112112
return (HighsInt)status;
113113
}
114114

@@ -173,9 +173,9 @@ HighsInt Highs_qpCall(
173173

174174
void* Highs_create(void) { return new Highs(); }
175175

176-
void Highs_destroy(void* highs) {
176+
void Highs_destroy(void* highs) {
177177
Highs::resetGlobalScheduler(true);
178-
delete (Highs*)highs;
178+
delete (Highs*)highs;
179179
}
180180

181181
const char* Highs_version(void) { return highsVersion(); }

highs/model/HighsHessianUtils.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,11 @@ void completeHessianDiagonal(const HighsOptions& options,
131131
num_missing_diagonal_entries++;
132132
}
133133
}
134-
highsLogDev(options.log_options, HighsLogType::kInfo,
135-
"Hessian has dimension %d and %d nonzeros: inserting %d zeros "
136-
"onto the diagonal\n",
137-
(int)dim, (int)num_nz, (int)num_missing_diagonal_entries);
134+
if (num_missing_diagonal_entries > 0)
135+
highsLogDev(options.log_options, HighsLogType::kInfo,
136+
"Hessian has dimension %d and %d nonzeros: inserting %d zeros "
137+
"onto the diagonal\n",
138+
int(dim), int(num_nz), int(num_missing_diagonal_entries));
138139
assert(num_missing_diagonal_entries >= dim - num_nz);
139140
if (!num_missing_diagonal_entries) return;
140141
// 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
@@ -57,16 +57,6 @@ void Basis::build() {
5757
baseindex[counter++] = i;
5858
}
5959

60-
const bool empty_matrix = (int)Atran.index.size() == 0;
61-
if (empty_matrix) {
62-
// The index/value vectors have size zero if the matrix has no
63-
// columns. However, in the Windows build, referring to index 0 of a
64-
// vector of size zero causes a failure, so resize to 1 to prevent
65-
// this.
66-
assert(Atran.num_col == 0);
67-
Atran.index.resize(1);
68-
Atran.value.resize(1);
69-
}
7060
basisfactor.setup(Atran.num_col, Atran.num_row, Atran.start.data(),
7161
Atran.index.data(), Atran.value.data(), baseindex.data());
7262
basisfactor.build();

0 commit comments

Comments
 (0)