Skip to content

Commit 0f29be3

Browse files
committed
Highs::qFormatOk now allows square Hessian
1 parent 2c3d586 commit 0f29be3

4 files changed

Lines changed: 17 additions & 18 deletions

File tree

check/TestCAPI.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ void minimalApiQp() {
501501
HighsInt a_index[2] = {0, 0};
502502
double a_value[2] = {1.0, 1.0};
503503

504-
// Start with triuangular Hessian, then
504+
// Start with triangular Hessian, then
505505
HighsInt q_format = kHighsHessianFormatTriangular;
506506
HighsInt q_num_nz = 4;
507507
HighsInt q_start[3] = {0, 2, 3};
@@ -1546,9 +1546,9 @@ void testPassHessian() {
15461546
for (HighsInt k = 0; k < 2; k++) {
15471547
HighsInt q_format = -1;
15481548
if (k == 0) {
1549-
q_format = 1;
1549+
q_format = kHighsHessianFormatTriangular;
15501550
} else {
1551-
q_format = 2;
1551+
q_format = kHighsHessianFormatSquare;
15521552
}
15531553
return_status = Highs_passHessian(highs, 1, 1, q_format, start, index, value);
15541554
assertIntValuesEqual("Return of passHessian", return_status, kHighsStatusOk);

check/TestQpSolver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1358,7 +1358,7 @@ TEST_CASE("pass-square-hessian", "[qpsolver]") {
13581358
REQUIRE(h.run() == HighsStatus::kOk);
13591359
REQUIRE(okValueDifference(info.objective_function_value,
13601360
optimal_objective_value));
1361-
1361+
13621362
h.resetGlobalScheduler(true);
13631363
}
13641364

highs/lp_data/Highs.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ HighsStatus Highs::passModel(
491491
assert(q_value != NULL);
492492
HighsHessian& hessian = model.hessian_;
493493
hessian.dim_ = num_col;
494-
hessian.format_ = HessianFormat::kTriangular;
494+
hessian.format_ = static_cast<HessianFormat>(q_format);
495495
hessian.start_.assign(q_start, q_start + num_col);
496496
hessian.start_.resize(num_col + 1);
497497
hessian.start_[num_col] = q_num_nz;
@@ -556,7 +556,7 @@ HighsStatus Highs::passHessian(const HighsInt dim, const HighsInt num_nz,
556556
HighsInt num_col = model_.lp_.num_col_;
557557
if (dim != num_col) return HighsStatus::kError;
558558
hessian.dim_ = num_col;
559-
hessian.format_ = HessianFormat::kTriangular;
559+
hessian.format_ = static_cast<HessianFormat>(format);
560560
if (dim > 0) {
561561
assert(start != NULL);
562562
hessian.start_.assign(start, start + num_col);

highs/lp_data/HighsInterface.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2865,25 +2865,24 @@ bool Highs::aFormatOk(const HighsInt num_nz, const HighsInt format) {
28652865
if (!num_nz) return true;
28662866
const bool ok_format = format == (HighsInt)MatrixFormat::kColwise ||
28672867
format == (HighsInt)MatrixFormat::kRowwise;
2868-
assert(ok_format);
28692868
if (!ok_format)
2870-
highsLogUser(
2871-
options_.log_options, HighsLogType::kError,
2872-
"Non-empty Constraint matrix has illegal format = %" HIGHSINT_FORMAT
2873-
"\n",
2874-
format);
2869+
highsLogUser(options_.log_options, HighsLogType::kError,
2870+
"Non-empty Constraint matrix has illegal format = %d\n",
2871+
int(format));
2872+
assert(ok_format);
28752873
return ok_format;
28762874
}
28772875

28782876
bool Highs::qFormatOk(const HighsInt num_nz, const HighsInt format) {
28792877
if (!num_nz) return true;
2880-
const bool ok_format = format == (HighsInt)HessianFormat::kTriangular;
2881-
assert(ok_format);
2878+
const bool ok_format =
2879+
format == static_cast<HighsInt>(HessianFormat::kTriangular) ||
2880+
static_cast<HighsInt>(HessianFormat::kSquare);
28822881
if (!ok_format)
2883-
highsLogUser(
2884-
options_.log_options, HighsLogType::kError,
2885-
"Non-empty Hessian matrix has illegal format = %" HIGHSINT_FORMAT "\n",
2886-
format);
2882+
highsLogUser(options_.log_options, HighsLogType::kError,
2883+
"Non-empty Hessian matrix has illegal format = %d\n",
2884+
int(format));
2885+
assert(ok_format);
28872886
return ok_format;
28882887
}
28892888

0 commit comments

Comments
 (0)