Skip to content

Commit 1b836fa

Browse files
committed
Bug fixes in HighsSparseMatrix::scaleCols and HighsSparseMatrix::scaleRows, and catching iteration limit in HiPDLP
1 parent 2875ef5 commit 1b836fa

File tree

5 files changed

+38
-27
lines changed

5 files changed

+38
-27
lines changed

check/TestPdlp.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,14 +331,16 @@ TEST_CASE("pdlp-restart-add-row", "[pdlp]") {
331331
}
332332

333333
TEST_CASE("hi-pdlp", "[pdlp]") {
334-
std::string model = "avgas";
334+
std::string model = "adlittle";//"avgas";
335335
std::string model_file =
336336
std::string(HIGHS_DIR) + "/check/instances/" + model + ".mps";
337337
Highs h;
338338
// h.setOptionValue("output_flag", dev_run);
339339
REQUIRE(h.readModel(model_file) == HighsStatus::kOk);
340340
h.setOptionValue("solver", kHiPdlpString);
341341
h.setOptionValue("kkt_tolerance", kkt_tolerance);
342+
h.setOptionValue("pdlp_iteration_limit", 10000);
343+
h.setOptionValue("log_dev_level", kHighsLogDevLevelVerbose);
342344
HighsStatus run_status = h.run();
343345
// REQUIRE(run_status == HighsStatus::kOk);
344346
// REQUIRE(h.getModelStatus() == HighsModelStatus::kOptimal);

highs/lp_data/HighsInterface.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,20 @@ void Highs::reportModelStats() const {
6767
highsLogDev(log_options, HighsLogType::kInfo, "%4s : %s\n",
6868
problem_type.c_str(), lp.model_name_.c_str());
6969
highsLogDev(log_options, HighsLogType::kInfo,
70-
"Row%s : %" HIGHSINT_FORMAT "\n", lp.num_row_,
71-
lp.num_row_ == 1 ? "" : "s");
70+
"Row%s : %" HIGHSINT_FORMAT "\n",
71+
lp.num_row_ == 1 ? "" : "s", lp.num_row_);
7272
highsLogDev(log_options, HighsLogType::kInfo,
73-
"Col%s : %" HIGHSINT_FORMAT "\n", lp.num_col_,
74-
lp.num_col_ == 1 ? "" : "s");
73+
"Col%s : %" HIGHSINT_FORMAT "\n",
74+
lp.num_col_ == 1 ? "" : "s", lp.num_col_);
7575
if (q_num_nz) {
7676
highsLogDev(log_options, HighsLogType::kInfo,
7777
"Matrix Nz : %" HIGHSINT_FORMAT "\n", a_num_nz);
7878
highsLogDev(log_options, HighsLogType::kInfo,
7979
"Hessian Nz: %" HIGHSINT_FORMAT "\n", q_num_nz);
8080
} else {
8181
highsLogDev(log_options, HighsLogType::kInfo,
82-
"Nonzero%s : %" HIGHSINT_FORMAT "\n", a_num_nz,
83-
a_num_nz == 1 ? "" : "s");
82+
"Nonzero%s : %" HIGHSINT_FORMAT "\n",
83+
a_num_nz == 1 ? "" : "s", a_num_nz);
8484
}
8585
if (num_integer)
8686
highsLogDev(log_options, HighsLogType::kInfo,

highs/lp_data/HighsOptions.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1284,7 +1284,8 @@ class HighsOptions : public HighsOptionsStruct {
12841284
record_int = new OptionRecordInt("pdlp_scaling_mode",
12851285
"Scaling mode for PDLP solver (default = "
12861286
"5): 1 => Ruiz; 2 => L2; 4 => PC",
1287-
advanced, &pdlp_scaling_mode, kPdlpScalingMin, kPdlpScalingRuiz+kPdlpScalingPC, kPdlpStepSizeStrategyMax);
1287+
advanced, &pdlp_scaling_mode,
1288+
kPdlpScalingMin, kPdlpScalingRuiz+kPdlpScalingPC, kPdlpScalingMax);
12881289
records.push_back(record_int);
12891290

12901291
record_int = new OptionRecordInt("pdlp_ruiz_iterations",

highs/pdlp/HiPdlpWrapper.cpp

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,16 @@ HighsStatus solveLpHiPdlp(const HighsOptions& options, HighsTimer& timer,
3232
resetModelStatusAndHighsInfo(model_status, highs_info);
3333

3434
std::string log_filename = "";
35-
LogLevel log_level = LogLevel::kInfo;
36-
35+
LogLevel log_level;
36+
if (options.log_dev_level == kHighsLogDevLevelInfo) {
37+
log_level = LogLevel::kInfo;
38+
} else if (options.log_dev_level == kHighsLogDevLevelDetailed) {
39+
log_level = LogLevel::kVerbose;
40+
} else if (options.log_dev_level == kHighsLogDevLevelVerbose) {
41+
log_level = LogLevel::kDebug;
42+
} else {
43+
log_level = LogLevel::kNone;
44+
}
3745
// --- Initialize Logger ---
3846
Logger logger(log_level);
3947
if (!log_filename.empty()) logger.set_log_file(log_filename);
@@ -77,8 +85,10 @@ HighsStatus solveLpHiPdlp(const HighsOptions& options, HighsTimer& timer,
7785
break;
7886
}
7987
case TerminationStatus::TIMEOUT: {
80-
assert(111 == 444);
81-
model_status = HighsModelStatus::kTimeLimit;
88+
// ToDo IterationLimit termination needs to be handled separately
89+
model_status = highs_info.pdlp_iteration_count >= options.pdlp_iteration_limit
90+
? HighsModelStatus::kIterationLimit
91+
: HighsModelStatus::kTimeLimit;
8292
break;
8393
}
8494
case TerminationStatus::WARNING:
@@ -108,10 +118,7 @@ HighsStatus solveLpHiPdlp(const HighsOptions& options, HighsTimer& timer,
108118
void getHiPpdlpParamsFromOptions(const HighsOptions& options, HighsTimer& timer, PrimalDualParams& params) {
109119
params.initialise();
110120
// params.eta = 0; Not set in parse_options_file
111-
// params.omega = 0; Not set in parse_opions_file
112-
//
113-
// Is params.tolerance for primal and dual feasibility, and
114-
// optimality?
121+
// params.omega = 0; Not set in parse_options_file
115122
params.tolerance = options.pdlp_optimality_tolerance;
116123
if (options.kkt_tolerance != kDefaultKktTolerance) {
117124
params.tolerance = options.kkt_tolerance;
@@ -139,8 +146,8 @@ void getHiPpdlpParamsFromOptions(const HighsOptions& options, HighsTimer& timer,
139146
params.use_l2_scaling = options.pdlp_scaling_mode & kPdlpScalingL2;
140147
}
141148
params.ruiz_iterations = options.pdlp_ruiz_iterations;
142-
// params.ruiz_norm = INFINITY; Not set in parse_opions_file
143-
// params.pc_alpha = 1.0; Not set in parse_opions_file
149+
// params.ruiz_norm = INFINITY; Not set in parse_options_file
150+
// params.pc_alpha = 1.0; Not set in parse_options_file
144151

145152
// Restart strategy maps 0/1/2 to RestartStrategy
146153
params.restart_strategy = RestartStrategy::NO_RESTART;
@@ -152,8 +159,8 @@ void getHiPpdlpParamsFromOptions(const HighsOptions& options, HighsTimer& timer,
152159
params.restart_strategy = RestartStrategy::ADAPTIVE_RESTART;
153160
}
154161
}
155-
// params.fixed_restart_interval = 0; Not set in parse_opions_file
156-
// params.use_halpern_restart = false; Not set in parse_opions_file
162+
// params.fixed_restart_interval = 0; Not set in parse_options_file
163+
// params.use_halpern_restart = false; Not set in parse_options_file
157164

158165
params.step_size_strategy = StepSizeStrategy::FIXED;
159166
if ((options.pdlp_features_off & kPdlpAdaptiveStepSizeOff) == 0) {
@@ -164,8 +171,8 @@ void getHiPpdlpParamsFromOptions(const HighsOptions& options, HighsTimer& timer,
164171
params.step_size_strategy = StepSizeStrategy::MALITSKY_POCK;
165172
}
166173
}
167-
// params.malitsky_pock_params.initialise(); Not set in parse_opions_file
168-
// params.adaptive_linesearch_params.initialise(); Not set in parse_opions_file
174+
// params.malitsky_pock_params.initialise(); Not set in parse_options_file
175+
// params.adaptive_linesearch_params.initialise(); Not set in parse_options_file
169176

170177
}
171178

highs/util/HighsSparseMatrix.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,13 @@ void HighsSparseMatrix::addVec(const HighsInt num_nz, const HighsInt* index,
253253
void HighsSparseMatrix::scaleCols(const double* scale) {
254254
if (this->isColwise()) {
255255
for (HighsInt iCol = 0; iCol < this->num_col_; iCol++) {
256-
for (HighsInt iEl = this->start_[iCol]; iCol < this->start_[iCol + 1];
256+
for (HighsInt iEl = this->start_[iCol]; iEl < this->start_[iCol + 1];
257257
iEl++)
258258
this->value_[iEl] *= scale[iCol];
259259
}
260260
} else {
261261
for (HighsInt iRow = 0; iRow < this->num_row_; iRow++) {
262-
for (HighsInt iEl = this->start_[iRow]; iRow < this->start_[iRow + 1];
262+
for (HighsInt iEl = this->start_[iRow]; iEl < this->start_[iRow + 1];
263263
iEl++)
264264
this->value_[iEl] *= scale[this->index_[iEl]];
265265
}
@@ -269,15 +269,16 @@ void HighsSparseMatrix::scaleCols(const double* scale) {
269269
void HighsSparseMatrix::scaleRows(const double* scale) {
270270
if (this->isColwise()) {
271271
for (HighsInt iCol = 0; iCol < this->num_col_; iCol++) {
272-
for (HighsInt iEl = this->start_[iCol]; iCol < this->start_[iCol + 1];
272+
for (HighsInt iEl = this->start_[iCol]; iEl < this->start_[iCol + 1];
273273
iEl++)
274274
this->value_[iEl] *= scale[this->index_[iEl]];
275275
}
276276
} else {
277277
for (HighsInt iRow = 0; iRow < this->num_row_; iRow++) {
278-
for (HighsInt iEl = this->start_[iRow]; iRow < this->start_[iRow + 1];
279-
iEl++)
278+
for (HighsInt iEl = this->start_[iRow]; iEl < this->start_[iRow + 1];
279+
iEl++) {
280280
this->value_[iEl] *= scale[iRow];
281+
}
281282
}
282283
}
283284
}

0 commit comments

Comments
 (0)