Skip to content

Commit 35a1ffc

Browse files
committed
ctest passes; Formatted
1 parent dc985f2 commit 35a1ffc

20 files changed

+294
-216
lines changed

check/TestCallbacks.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,14 +400,17 @@ TEST_CASE("highs-callback-ipm-interrupt", "[highs_callback]") {
400400
highs.setOptionValue("solver", kIpxString);
401401
REQUIRE(highs.run() == HighsStatus::kWarning);
402402
REQUIRE(highs.getModelStatus() == HighsModelStatus::kInterrupt);
403-
REQUIRE(highs.getInfo().ipm_iteration_count == adlittle_ipm_iteration_limit+1);
403+
REQUIRE(highs.getInfo().ipm_iteration_count ==
404+
adlittle_ipm_iteration_limit + 1);
404405

405406
highs.readModel(filename);
406407
#ifdef HIPO
407-
REQUIRE(highs.setOptionValue("solver", kHipoString) == HighsStatus::kOk);;
408+
REQUIRE(highs.setOptionValue("solver", kHipoString) == HighsStatus::kOk);
409+
;
408410
REQUIRE(highs.run() == HighsStatus::kWarning);
409411
REQUIRE(highs.getModelStatus() == HighsModelStatus::kInterrupt);
410-
REQUIRE(highs.getInfo().ipm_iteration_count == adlittle_ipm_iteration_limit+1);
412+
REQUIRE(highs.getInfo().ipm_iteration_count ==
413+
adlittle_ipm_iteration_limit + 1);
411414
#endif
412415
highs.resetGlobalScheduler(true);
413416
}

check/TestMipSolver.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,26 +1050,30 @@ TEST_CASE("mip-lp-solver", "[highs_test_mip_solver]") {
10501050
REQUIRE(h.readModel(model_file) == HighsStatus::kOk);
10511051
REQUIRE(h.run() == HighsStatus::kOk);
10521052
REQUIRE(h.getModelStatus() == HighsModelStatus::kOptimal);
1053-
1053+
10541054
REQUIRE(h.readModel(model_file) == HighsStatus::kOk);
1055-
REQUIRE(h.setOptionValue(kMipLpSolverString, kIpxString) == HighsStatus::kOk);
1056-
REQUIRE(h.setOptionValue(kMipIpmSolverString, kIpxString) == HighsStatus::kOk);
1055+
REQUIRE(h.setOptionValue(kMipLpSolverString, kIpxString) ==
1056+
HighsStatus::kOk);
1057+
REQUIRE(h.setOptionValue(kMipIpmSolverString, kIpxString) ==
1058+
HighsStatus::kOk);
10571059
REQUIRE(h.run() == HighsStatus::kOk);
10581060
REQUIRE(h.getModelStatus() == HighsModelStatus::kOptimal);
10591061
}
10601062
#ifdef HIPO
10611063
REQUIRE(h.readModel(model_file) == HighsStatus::kOk);
1062-
REQUIRE(h.setOptionValue(kMipLpSolverString, kHipoString) == HighsStatus::kOk);
1063-
REQUIRE(h.setOptionValue(kMipIpmSolverString, kHipoString) == HighsStatus::kOk);
1064+
REQUIRE(h.setOptionValue(kMipLpSolverString, kHipoString) ==
1065+
HighsStatus::kOk);
1066+
REQUIRE(h.setOptionValue(kMipIpmSolverString, kHipoString) ==
1067+
HighsStatus::kOk);
10641068
REQUIRE(h.run() == HighsStatus::kOk);
10651069
REQUIRE(h.getModelStatus() == HighsModelStatus::kOptimal);
10661070
#endif
10671071
}
10681072

10691073
TEST_CASE("mip-sub-solver-time", "[highs_test_mip_solver]") {
1070-
const std::string model = "flugpl"; //"rgn"; //
1074+
const std::string model = "flugpl"; //"rgn"; //
10711075
std::string model_file =
1072-
std::string(HIGHS_DIR) + "/check/instances/" + model + ".mps";
1076+
std::string(HIGHS_DIR) + "/check/instances/" + model + ".mps";
10731077
Highs h;
10741078
h.setOptionValue("output_flag", dev_run);
10751079
h.setOptionValue("highs_analysis_level", kHighsAnalysisLevelMipTime);

check/TestSpecialLps.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,9 @@ void issue425(Highs& highs) {
210210
solve(highs, "off", "simplex", require_model_status, 0, 3);
211211
const bool use_hipo =
212212
#ifdef HIPO
213-
true;
213+
true;
214214
#else
215-
false;
215+
false;
216216
#endif
217217
if (use_hipo) {
218218
solve(highs, "off", "ipm", require_model_status, 0, 15);

highs/Highs.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,9 +1205,12 @@ class Highs {
12051205
HighsStatus setBasis();
12061206

12071207
/**
1208-
* @brief Return a const reference to the internal sub-solver call and time instance
1208+
* @brief Return a const reference to the internal sub-solver call and time
1209+
* instance
12091210
*/
1210-
const HighsSubSolverCallTime& getSubSolverCallTime() const { return sub_solver_call_time_; }
1211+
const HighsSubSolverCallTime& getSubSolverCallTime() const {
1212+
return sub_solver_call_time_;
1213+
}
12111214

12121215
/**
12131216
* @brief Report internal sub-solver call and time instance
@@ -1217,7 +1220,9 @@ class Highs {
12171220
/**
12181221
* @brief Initialise the internal sub-solver call and time instance
12191222
*/
1220-
void initialiseSubSolverCallTime() { this->sub_solver_call_time_.initialise(); }
1223+
void initialiseSubSolverCallTime() {
1224+
this->sub_solver_call_time_.initialise();
1225+
}
12211226

12221227
/**
12231228
* @brief Run IPX crossover from a given HighsSolution instance and,

highs/lp_data/HStruct.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ struct HighsSubSolverCallTime {
175175
std::vector<double> run_time;
176176
void initialise();
177177
void add(const HighsSubSolverCallTime& sub_solver_call_time,
178-
const bool analytic_centre = false);
178+
const bool analytic_centre = false);
179179
};
180180

181181
struct HighsSimplexStats {

highs/lp_data/Highs.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,10 +1313,10 @@ HighsStatus Highs::optimizeModel() {
13131313
// There is no valid basis, but there is a valid solution, so use
13141314
// it to construct a basis
13151315
return_status =
1316-
interpretCallStatus(options_.log_options, basisForSolution(),
1317-
return_status, "basisForSolution");
1316+
interpretCallStatus(options_.log_options, basisForSolution(),
1317+
return_status, "basisForSolution");
13181318
if (return_status == HighsStatus::kError)
1319-
return returnFromOptimizeModel(return_status, undo_mods);
1319+
return returnFromOptimizeModel(return_status, undo_mods);
13201320
assert(basis_.valid);
13211321
}
13221322
} else {
@@ -1356,7 +1356,9 @@ HighsStatus Highs::optimizeModel() {
13561356
}
13571357
if (basis_.valid) assert(basis_.useful);
13581358

1359-
if (((options_.presolve == kHighsOffString || has_basis) && solver_will_use_basis) || unconstrained_lp) {
1359+
if (((options_.presolve == kHighsOffString || has_basis) &&
1360+
solver_will_use_basis) ||
1361+
unconstrained_lp) {
13601362
ekk_instance_.lp_name_ =
13611363
"LP without presolve, or with basis, or unconstrained";
13621364
// If there is a valid HiGHS basis, refine any status values that
@@ -2456,10 +2458,9 @@ HighsStatus Highs::setBasis(const HighsBasis& basis,
24562458
}
24572459
HighsBasis modifiable_basis = basis;
24582460
modifiable_basis.was_alien = true;
2459-
HighsLpSolverObject solver_object(model_.lp_, modifiable_basis, solution_,
2460-
info_, ekk_instance_, callback_,
2461-
options_, timer_,
2462-
sub_solver_call_time_);
2461+
HighsLpSolverObject solver_object(
2462+
model_.lp_, modifiable_basis, solution_, info_, ekk_instance_,
2463+
callback_, options_, timer_, sub_solver_call_time_);
24632464
HighsStatus return_status = formSimplexLpBasisAndFactor(solver_object);
24642465
if (return_status != HighsStatus::kOk) return HighsStatus::kError;
24652466
// Update the HiGHS basis
@@ -3843,7 +3844,7 @@ HighsStatus Highs::callSolveLp(HighsLp& lp, const string message) {
38433844

38443845
HighsLpSolverObject solver_object(lp, basis_, solution_, info_, ekk_instance_,
38453846
callback_, options_, timer_,
3846-
sub_solver_call_time_);
3847+
sub_solver_call_time_);
38473848

38483849
// Check that the model is column-wise
38493850
assert(model_.lp_.a_matrix_.isColwise());
@@ -4269,7 +4270,7 @@ HighsStatus Highs::callRunPostsolve(const HighsSolution& solution,
42694270
ekk_instance_.lp_name_ = "Postsolve LP";
42704271
// Set up the timing record so that adding the corresponding
42714272
// values after callSolveLp gives difference
4272-
this->sub_solver_call_time_.initialise();
4273+
this->sub_solver_call_time_.initialise();
42734274
timer_.start(timer_.solve_clock);
42744275
call_status = callSolveLp(
42754276
incumbent_lp,

highs/lp_data/HighsInterface.cpp

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1858,7 +1858,7 @@ HighsStatus Highs::getPrimalRayInterface(bool& has_primal_ray,
18581858
HighsStatus Highs::getRangingInterface() {
18591859
HighsLpSolverObject solver_object(model_.lp_, basis_, solution_, info_,
18601860
ekk_instance_, callback_, options_, timer_,
1861-
sub_solver_call_time_);
1861+
sub_solver_call_time_);
18621862
solver_object.model_status_ = model_status_;
18631863
return getRangingData(this->ranging_, solver_object);
18641864
}
@@ -3062,8 +3062,7 @@ void Highs::restoreInfCost(HighsStatus& return_status) {
30623062
// Modify status and info if user bound or cost scaling, or
30633063
// primal/dual feasibility tolerances have changed
30643064
HighsStatus Highs::optionChangeAction() {
3065-
this->timer_.setPrintfFlag(options_.output_flag,
3066-
options_.log_to_console);
3065+
this->timer_.setPrintfFlag(options_.output_flag, options_.log_to_console);
30673066
HighsModel& model = this->model_;
30683067
HighsLp& lp = model.lp_;
30693068
HighsInfo& info = this->info_;
@@ -4319,8 +4318,9 @@ void HighsSubSolverCallTime::initialise() {
43194318
this->name[kSubSolverSubMip] = "Sub-MIP";
43204319
}
43214320

4322-
void HighsSubSolverCallTime::add(const HighsSubSolverCallTime& sub_solver_call_time,
4323-
const bool analytic_centre) {
4321+
void HighsSubSolverCallTime::add(
4322+
const HighsSubSolverCallTime& sub_solver_call_time,
4323+
const bool analytic_centre) {
43244324
for (HighsInt Ix = 0; Ix < kSubSolverCount; Ix++) {
43254325
HighsInt ToIx = Ix;
43264326
if (Ix == kSubSolverHipo) {
@@ -4337,30 +4337,38 @@ void Highs::reportSubSolverCallTime() const {
43374337
double mip_time = this->sub_solver_call_time_.run_time[kSubSolverMip];
43384338
std::stringstream ss;
43394339
ss.str(std::string());
4340-
ss << highsFormatToString("\nSub-solver timing\nSolver Calls Time Time/call");
4341-
if (mip_time > 0) ss << " MIP%";
4342-
highsLogUser(options_.log_options, HighsLogType::kInfo, "%s\n", ss.str().c_str());
4343-
4340+
ss << highsFormatToString(
4341+
"\nSub-solver timing\nSolver Calls Time "
4342+
"Time/call");
4343+
if (mip_time > 0) ss << " MIP%";
4344+
highsLogUser(options_.log_options, HighsLogType::kInfo, "%s\n",
4345+
ss.str().c_str());
43444346

43454347
double sum_mip_sub_solve_time = 0;
43464348
for (HighsInt Ix = 0; Ix < kSubSolverCount; Ix++) {
43474349
if (this->sub_solver_call_time_.num_call[Ix]) {
43484350
ss.str(std::string());
4349-
ss << highsFormatToString("%-18s %9d %11.4e %11.4e",
4350-
this->sub_solver_call_time_.name[Ix].c_str(),
4351-
int(this->sub_solver_call_time_.num_call[Ix]),
4352-
this->sub_solver_call_time_.run_time[Ix],
4353-
this->sub_solver_call_time_.run_time[Ix]/(1.0 * this->sub_solver_call_time_.num_call[Ix]));
4351+
ss << highsFormatToString(
4352+
"%-18s %9d %11.4e %11.4e",
4353+
this->sub_solver_call_time_.name[Ix].c_str(),
4354+
int(this->sub_solver_call_time_.num_call[Ix]),
4355+
this->sub_solver_call_time_.run_time[Ix],
4356+
this->sub_solver_call_time_.run_time[Ix] /
4357+
(1.0 * this->sub_solver_call_time_.num_call[Ix]));
43544358
if (mip_time > 0 && Ix != kSubSolverMip) {
4355-
if (Ix != kSubSolverHipoAc && Ix != kSubSolverIpxAc)
4356-
sum_mip_sub_solve_time += this->sub_solver_call_time_.run_time[Ix];
4357-
ss << highsFormatToString(" %5.1f", 1e2 * this->sub_solver_call_time_.run_time[Ix] / mip_time);
4359+
if (Ix != kSubSolverHipoAc && Ix != kSubSolverIpxAc)
4360+
sum_mip_sub_solve_time += this->sub_solver_call_time_.run_time[Ix];
4361+
ss << highsFormatToString(
4362+
" %5.1f",
4363+
1e2 * this->sub_solver_call_time_.run_time[Ix] / mip_time);
43584364
}
4359-
highsLogUser(options_.log_options, HighsLogType::kInfo, "%s\n", ss.str().c_str());
4365+
highsLogUser(options_.log_options, HighsLogType::kInfo, "%s\n",
4366+
ss.str().c_str());
43604367
}
43614368
}
43624369
if (mip_time > 0)
4363-
highsLogUser(options_.log_options, HighsLogType::kInfo, "TOTAL (excluding AC) %11.4e %5.1f\n",
4364-
sum_mip_sub_solve_time, 1e2 * sum_mip_sub_solve_time / mip_time);
4370+
highsLogUser(options_.log_options, HighsLogType::kInfo,
4371+
"TOTAL (excluding AC) %11.4e %5.1f\n",
4372+
sum_mip_sub_solve_time,
4373+
1e2 * sum_mip_sub_solve_time / mip_time);
43654374
}
4366-

highs/lp_data/HighsLpSolverObject.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
class HighsLpSolverObject {
1919
public:
2020
HighsLpSolverObject(HighsLp& lp, HighsBasis& basis, HighsSolution& solution,
21-
HighsInfo& highs_info,
22-
HEkk& ekk_instance,
21+
HighsInfo& highs_info, HEkk& ekk_instance,
2322
HighsCallback& callback, HighsOptions& options,
24-
HighsTimer& timer, HighsSubSolverCallTime& sub_solver_call_time)
23+
HighsTimer& timer,
24+
HighsSubSolverCallTime& sub_solver_call_time)
2525
: lp_(lp),
2626
basis_(basis),
2727
solution_(solution),
@@ -30,7 +30,7 @@ class HighsLpSolverObject {
3030
callback_(callback),
3131
options_(options),
3232
timer_(timer),
33-
sub_solver_call_time_(sub_solver_call_time) {}
33+
sub_solver_call_time_(sub_solver_call_time) {}
3434

3535
HighsLp& lp_;
3636
HighsBasis& basis_;

highs/lp_data/HighsOptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ class HighsOptions : public HighsOptionsStruct {
833833
record_int = new OptionRecordInt(
834834
"highs_analysis_level", "Analysis level in HiGHS", now_advanced,
835835
&highs_analysis_level, kHighsAnalysisLevelMin,
836-
kHighsAnalysisLevelMin, //kHighsAnalysisLevelMipTime, //
836+
kHighsAnalysisLevelMin, // kHighsAnalysisLevelMipTime, //
837837
kHighsAnalysisLevelMax);
838838
records.push_back(record_int);
839839

highs/lp_data/HighsSolve.cpp

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ HighsStatus solveLp(HighsLpSolverObject& solver_object, const string message) {
1919
HighsStatus return_status = HighsStatus::kOk;
2020
HighsStatus call_status;
2121
HighsOptions& options = solver_object.options_;
22-
HighsSubSolverCallTime& sub_solver_call_time = solver_object.sub_solver_call_time_;
22+
HighsSubSolverCallTime& sub_solver_call_time =
23+
solver_object.sub_solver_call_time_;
2324
// Reset unscaled model status and solution params - except for
2425
// iteration counts
2526
resetModelStatusAndHighsInfo(solver_object);
@@ -51,12 +52,11 @@ HighsStatus solveLp(HighsLpSolverObject& solver_object, const string message) {
5152
return_status = HighsStatus::kOk;
5253
call_status = solveLpSimplex(solver_object);
5354
return_status = interpretCallStatus(options.log_options, call_status,
54-
return_status, "solveLpSimplex");
55+
return_status, "solveLpSimplex");
5556
if (return_status == HighsStatus::kError) return return_status;
56-
if (!isSolutionRightSize(solver_object.lp_,
57-
solver_object.solution_)) {
57+
if (!isSolutionRightSize(solver_object.lp_, solver_object.solution_)) {
5858
highsLogUser(options.log_options, HighsLogType::kError,
59-
"Inconsistent solution returned from solver\n");
59+
"Inconsistent solution returned from solver\n");
6060
return_status = HighsStatus::kError;
6161
}
6262
return return_status;
@@ -75,16 +75,18 @@ HighsStatus solveLp(HighsLpSolverObject& solver_object, const string message) {
7575
if (use_hipo) {
7676
#ifdef HIPO
7777
// Use HIPO to solve the LP
78-
sub_solver_call_time.num_call[kSubSolverHipo]++;
79-
sub_solver_call_time.run_time[kSubSolverHipo] = -solver_object.timer_.read();
78+
sub_solver_call_time.num_call[kSubSolverHipo]++;
79+
sub_solver_call_time.run_time[kSubSolverHipo] =
80+
-solver_object.timer_.read();
8081
try {
8182
call_status = solveLpHipo(solver_object);
8283
} catch (const std::exception& exception) {
8384
highsLogDev(options.log_options, HighsLogType::kError,
8485
"Exception %s in solveLpHipo\n", exception.what());
8586
call_status = HighsStatus::kError;
8687
}
87-
sub_solver_call_time.run_time[kSubSolverHipo] += solver_object.timer_.read();
88+
sub_solver_call_time.run_time[kSubSolverHipo] +=
89+
solver_object.timer_.read();
8890
return_status = interpretCallStatus(options.log_options, call_status,
8991
return_status, "solveLpHipo");
9092
#else
@@ -93,31 +95,35 @@ HighsStatus solveLp(HighsLpSolverObject& solver_object, const string message) {
9395
return HighsStatus::kError;
9496
#endif
9597
} else if (use_ipx) {
96-
sub_solver_call_time.num_call[kSubSolverIpx]++;
97-
sub_solver_call_time.run_time[kSubSolverIpx] = -solver_object.timer_.read();
98+
sub_solver_call_time.num_call[kSubSolverIpx]++;
99+
sub_solver_call_time.run_time[kSubSolverIpx] =
100+
-solver_object.timer_.read();
98101
try {
99102
call_status = solveLpIpx(solver_object);
100103
} catch (const std::exception& exception) {
101104
highsLogDev(options.log_options, HighsLogType::kError,
102105
"Exception %s in solveLpIpx\n", exception.what());
103106
call_status = HighsStatus::kError;
104107
}
105-
sub_solver_call_time.run_time[kSubSolverIpx] += solver_object.timer_.read();
108+
sub_solver_call_time.run_time[kSubSolverIpx] +=
109+
solver_object.timer_.read();
106110
return_status = interpretCallStatus(options.log_options, call_status,
107111
return_status, "solveLpIpx");
108112
}
109113
} else {
110114
// Use cuPDLP-C to solve the LP
111115
sub_solver_call_time.num_call[kSubSolverPdlp]++;
112-
sub_solver_call_time.run_time[kSubSolverPdlp] = -solver_object.timer_.read();
116+
sub_solver_call_time.run_time[kSubSolverPdlp] =
117+
-solver_object.timer_.read();
113118
try {
114119
call_status = solveLpCupdlp(solver_object);
115120
} catch (const std::exception& exception) {
116121
highsLogDev(options.log_options, HighsLogType::kError,
117122
"Exception %s in solveLpCupdlp\n", exception.what());
118123
call_status = HighsStatus::kError;
119124
}
120-
sub_solver_call_time.run_time[kSubSolverPdlp] += solver_object.timer_.read();
125+
sub_solver_call_time.run_time[kSubSolverPdlp] +=
126+
solver_object.timer_.read();
121127
return_status = interpretCallStatus(options.log_options, call_status,
122128
return_status, "solveLpCupdlp");
123129
}
@@ -163,7 +169,7 @@ HighsStatus solveLp(HighsLpSolverObject& solver_object, const string message) {
163169
highsLogUser(options.log_options, HighsLogType::kWarning,
164170
"IPM solution is imprecise, so clean up with simplex\n");
165171
return_status = simplexSolve();
166-
if (return_status == HighsStatus::kError) return return_status;
172+
if (return_status == HighsStatus::kError) return return_status;
167173
} // options.run_crossover == kHighsOnString
168174
// clang-format off
169175
} // unwelcome_ipx_status
@@ -601,12 +607,11 @@ bool useHipo(const HighsOptions& options,
601607
if (specific_solver_option_value == kIpxString) {
602608
use_hipo = false;
603609
} else if (specific_solver_option_value == kIpmString ||
604-
specific_solver_option_value == kHipoString ||
605-
force_ipm) {
610+
specific_solver_option_value == kHipoString || force_ipm) {
606611
#ifdef HIPO
607-
use_hipo = true;
612+
use_hipo = true;
608613
#else
609-
use_hipo = false;
614+
use_hipo = false;
610615
#endif
611616
}
612617
if (options.run_centring) use_hipo = false;

0 commit comments

Comments
 (0)