Skip to content

Commit 1631cde

Browse files
committed
Added HiPdlpWrapper.h/cpp and unit test to run HiPDLP
1 parent 2aff705 commit 1631cde

File tree

8 files changed

+103
-8
lines changed

8 files changed

+103
-8
lines changed

check/TestPdlp.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,3 +329,17 @@ TEST_CASE("pdlp-restart-add-row", "[pdlp]") {
329329
run_status = h.run();
330330
if (dev_run) h.writeSolution("", 1);
331331
}
332+
333+
TEST_CASE("hi-pdlp", "[pdlp]") {
334+
std::string model = "avgas";
335+
std::string model_file =
336+
std::string(HIGHS_DIR) + "/check/instances/" + model + ".mps";
337+
Highs h;
338+
// h.setOptionValue("output_flag", dev_run);
339+
REQUIRE(h.readModel(model_file) == HighsStatus::kOk);
340+
h.setOptionValue("solver", kHiPdlpString);
341+
h.setOptionValue("kkt_tolerance", kkt_tolerance);
342+
HighsStatus run_status = h.run();
343+
REQUIRE(run_status == HighsStatus::kOk);
344+
REQUIRE(h.getModelStatus() == HighsModelStatus::kOptimal);
345+
}

cmake/sources-python.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ set(highs_sources_python
236236
highs/model/HighsModel.cpp
237237
highs/parallel/HighsTaskExecutor.cpp
238238
highs/pdlp/CupdlpWrapper.cpp
239+
highs/pdlp/HiPdlpWrapper.cpp
239240
highs/pdlp/hipdlp/linalg.cc
240241
highs/presolve/HighsPostsolveStack.cpp
241242
highs/presolve/HighsSymmetry.cpp
@@ -367,6 +368,7 @@ set(highs_headers_python
367368
highs/parallel/HighsTask.h
368369
highs/parallel/HighsTaskExecutor.h
369370
highs/pdlp/CupdlpWrapper.h
371+
highs/pdlp/HiPdlpWrapper.h
370372
highs/presolve/HighsPostsolveStack.h
371373
highs/presolve/HighsSymmetry.h
372374
highs/presolve/HPresolve.h

cmake/sources.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ set(highs_sources
320320
model/HighsModel.cpp
321321
parallel/HighsTaskExecutor.cpp
322322
pdlp/CupdlpWrapper.cpp
323+
pdlp/HiPdlpWrapper.cpp
323324
pdlp/hipdlp/linalg.cc
324325
presolve/HighsPostsolveStack.cpp
325326
presolve/HighsSymmetry.cpp
@@ -454,6 +455,7 @@ set(highs_headers
454455
parallel/HighsTask.h
455456
parallel/HighsTaskExecutor.h
456457
pdlp/CupdlpWrapper.h
458+
pdlp/HiPdlpWrapper.h
457459
presolve/HighsPostsolveStack.h
458460
presolve/HighsSymmetry.h
459461
presolve/HPresolve.h

highs/lp_data/HighsSolve.cpp

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "ipm/IpxWrapper.h"
1313
#include "lp_data/HighsSolutionDebug.h"
1414
#include "pdlp/CupdlpWrapper.h"
15+
#include "pdlp/HiPdlpWrapper.h"
1516
#include "simplex/HApp.h"
1617

1718
// The method below runs the simplex, IPX, HiPO or PDLP solver on the LP
@@ -68,7 +69,7 @@ HighsStatus solveLp(HighsLpSolverObject& solver_object, const string message) {
6869
return_status = interpretCallStatus(options.log_options, call_status,
6970
return_status, "solveUnconstrainedLp");
7071
if (return_status == HighsStatus::kError) return return_status;
71-
} else if (use_only_ipm || options.solver == kPdlpString) {
72+
} else if (use_only_ipm || usePdlp(options.solver)) {
7273
// Use IPM or PDLP
7374
if (use_only_ipm) {
7475
// Use IPM to solve the LP
@@ -111,16 +112,26 @@ HighsStatus solveLp(HighsLpSolverObject& solver_object, const string message) {
111112
return_status, "solveLpIpx");
112113
}
113114
} else {
114-
// Use cuPDLP-C to solve the LP
115+
// Use cuPDLP-C or HiPDLP to solve the LP
115116
sub_solver_call_time.num_call[kSubSolverPdlp]++;
116117
sub_solver_call_time.run_time[kSubSolverPdlp] =
117118
-solver_object.timer_.read();
118-
try {
119-
call_status = solveLpCupdlp(solver_object);
120-
} catch (const std::exception& exception) {
121-
highsLogDev(options.log_options, HighsLogType::kError,
122-
"Exception %s in solveLpCupdlp\n", exception.what());
123-
call_status = HighsStatus::kError;
119+
if (options.solver == kPdlpString || options.solver == kCuPdlpString) {
120+
try {
121+
call_status = solveLpCupdlp(solver_object);
122+
} catch (const std::exception& exception) {
123+
highsLogDev(options.log_options, HighsLogType::kError,
124+
"Exception %s in solveLpCupdlp\n", exception.what());
125+
call_status = HighsStatus::kError;
126+
}
127+
} else {
128+
try {
129+
call_status = solveLpHiPdlp(solver_object);
130+
} catch (const std::exception& exception) {
131+
highsLogDev(options.log_options, HighsLogType::kError,
132+
"Exception %s in solveHiPdlp\n", exception.what());
133+
call_status = HighsStatus::kError;
134+
}
124135
}
125136
sub_solver_call_time.run_time[kSubSolverPdlp] +=
126137
solver_object.timer_.read();
@@ -588,6 +599,10 @@ bool useIpm(const std::string& solver) {
588599
return solver == kIpmString || solver == kHipoString || solver == kIpxString;
589600
}
590601

602+
bool usePdlp(const std::string& solver) {
603+
return solver == kPdlpString || solver == kHiPdlpString || solver == kCuPdlpString;
604+
}
605+
591606
// Decide whether to use the HiPO IPM solver
592607
bool useHipo(const HighsOptions& options,
593608
const std::string& specific_solver_option, const HighsLp& lp,

highs/lp_data/HighsSolve.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ HighsStatus solveUnconstrainedLp(const HighsOptions& options, const HighsLp& lp,
2121
void assessExcessiveBoundCost(const HighsLogOptions log_options,
2222
const HighsModel& model);
2323
bool useIpm(const std::string& solver);
24+
bool usePdlp(const std::string& solver);
2425
bool useHipo(const HighsOptions& options,
2526
const std::string& specific_solver_option, const HighsLp& lp,
2627
const bool logging = false);

highs/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ _srcs = [
253253
'model/HighsModel.cpp',
254254
'parallel/HighsTaskExecutor.cpp',
255255
'pdlp/CupdlpWrapper.cpp',
256+
'pdlp/HiPdlpWrapper.cpp',
256257
'presolve/HPresolve.cpp',
257258
'presolve/HPresolveAnalysis.cpp',
258259
'presolve/HighsPostsolveStack.cpp',

highs/pdlp/HiPdlpWrapper.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2+
/* */
3+
/* This file is part of the HiGHS linear optimization suite */
4+
/* */
5+
/* Available as open-source under the MIT License */
6+
/* */
7+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
8+
/**@file pdlp/HiPdlpWrapper.cpp
9+
* @brief
10+
* @author Julian Hall
11+
*/
12+
#include "pdlp/HiPdlpWrapper.h"
13+
HighsStatus solveLpHiPdlp(HighsLpSolverObject& solver_object) {
14+
return solveLpHiPdlp(solver_object.options_, solver_object.timer_,
15+
solver_object.lp_, solver_object.basis_,
16+
solver_object.solution_, solver_object.model_status_,
17+
solver_object.highs_info_, solver_object.callback_);
18+
}
19+
20+
HighsStatus solveLpHiPdlp(const HighsOptions& options, HighsTimer& timer,
21+
const HighsLp& lp, HighsBasis& highs_basis,
22+
HighsSolution& highs_solution,
23+
HighsModelStatus& model_status, HighsInfo& highs_info,
24+
HighsCallback& callback) {
25+
// Indicate that no imprecise solution has (yet) been found
26+
resetModelStatusAndHighsInfo(model_status, highs_info);
27+
28+
return HighsStatus::kError;
29+
}
30+

highs/pdlp/HiPdlpWrapper.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2+
/* */
3+
/* This file is part of the HiGHS linear optimization suite */
4+
/* */
5+
/* Available as open-source under the MIT License */
6+
/* */
7+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
8+
/**@file pdlp/HiPdlpWrapper.h
9+
* @brief
10+
*/
11+
#ifndef PDLP_HIPDLP_WRAPPER_H_
12+
#define PDLP_HIPDLP_WRAPPER_H_
13+
14+
#include <algorithm>
15+
#include <cassert>
16+
17+
#include "lp_data/HighsSolution.h"
18+
//#include "pdlp/cupdlp/cupdlp.h"
19+
20+
//typedef enum CONSTRAINT_TYPE { EQ = 0, LEQ, GEQ, BOUND } constraint_type;
21+
22+
HighsStatus solveLpHiPdlp(HighsLpSolverObject& solver_object);
23+
24+
HighsStatus solveLpHiPdlp(const HighsOptions& options, HighsTimer& timer,
25+
const HighsLp& lp, HighsBasis& highs_basis,
26+
HighsSolution& highs_solution,
27+
HighsModelStatus& model_status, HighsInfo& highs_info,
28+
HighsCallback& callback);
29+
30+
#endif

0 commit comments

Comments
 (0)