Skip to content

Commit c330aec

Browse files
authored
Merge pull request #4505 from rte-france/feature/xpress_mathopt_from_google_main
Add XPRESS support to MathOpt (LP & QP)
2 parents 9f398f6 + ebdbfc0 commit c330aec

File tree

14 files changed

+1737
-7
lines changed

14 files changed

+1737
-7
lines changed

ortools/linear_solver/xpress_interface.cc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -203,13 +203,6 @@ void interruptXPRESS(XPRSprob& xprsProb, CUSTOM_INTERRUPT_REASON reason) {
203203
XPRSinterrupt(xprsProb, 1000 + reason);
204204
}
205205

206-
enum XPRS_BASIS_STATUS {
207-
XPRS_AT_LOWER = 0,
208-
XPRS_BASIC = 1,
209-
XPRS_AT_UPPER = 2,
210-
XPRS_FREE_SUPER = 3
211-
};
212-
213206
// In case we need to return a double but don't have a value for that
214207
// we just return a NaN.
215208
#if !defined(XPRS_NAN)

ortools/math_opt/cpp/parameters.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ std::optional<absl::string_view> Enum<SolverType>::ToOptString(
8585
return "highs";
8686
case SolverType::kSantorini:
8787
return "santorini";
88+
case SolverType::kXpress:
89+
return "xpress";
8890
}
8991
return std::nullopt;
9092
}

ortools/math_opt/cpp/parameters.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ enum class SolverType {
109109
// Slow/not recommended for production. Not an LP solver (no dual information
110110
// returned).
111111
kSantorini = SOLVER_TYPE_SANTORINI,
112+
113+
// Fico XPRESS solver (third party).
114+
//
115+
// Supports LP, MIP, and nonconvex integer quadratic problems.
116+
// A fast option, but has special licensing.
117+
kXpress = SOLVER_TYPE_XPRESS
112118
};
113119

114120
MATH_OPT_DEFINE_ENUM(SolverType, SOLVER_TYPE_UNSPECIFIED);

ortools/math_opt/parameters.proto

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ enum SolverTypeProto {
105105
// Slow/not recommended for production. Not an LP solver (no dual information
106106
// returned).
107107
SOLVER_TYPE_SANTORINI = 11;
108+
109+
// Fico XPRESS solver (third party).
110+
//
111+
// Supports LP, MIP, and nonconvex integer quadratic problems.
112+
// A fast option, but has special licensing.
113+
SOLVER_TYPE_XPRESS = 12;
108114
}
109115

110116
// Selects an algorithm for solving linear programs.

ortools/math_opt/solver_tests/base_solver_test.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ bool ActivatePrimalRay(const SolverType solver_type, SolveParameters& params) {
5050
return false;
5151
case SolverType::kHighs:
5252
return false;
53+
case SolverType::kXpress:
54+
// TODO: support XPRESS
55+
return false;
5356
default:
5457
LOG(FATAL)
5558
<< "Solver " << solver_type
@@ -82,6 +85,9 @@ bool ActivateDualRay(const SolverType solver_type, SolveParameters& params) {
8285
return false;
8386
case SolverType::kHighs:
8487
return false;
88+
case SolverType::kXpress:
89+
// TODO: support XPRESS
90+
return false;
8591
default:
8692
LOG(FATAL)
8793
<< "Solver " << solver_type

ortools/math_opt/solvers/CMakeLists.txt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ if(NOT USE_SCIP)
4040
list(FILTER _SRCS EXCLUDE REGEX "/gscip_.*.h$")
4141
list(FILTER _SRCS EXCLUDE REGEX "/gscip_.*.cc$")
4242
endif()
43+
if(NOT USE_XPRESS)
44+
list(FILTER _SRCS EXCLUDE REGEX "/xpress/")
45+
list(FILTER _SRCS EXCLUDE REGEX "/xpress_.*.h$")
46+
list(FILTER _SRCS EXCLUDE REGEX "/xpress_.*.cc$")
47+
endif()
4348
target_sources(${NAME} PRIVATE ${_SRCS})
4449
set_target_properties(${NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
4550
target_include_directories(${NAME} PUBLIC
@@ -233,3 +238,34 @@ if(USE_HIGHS)
233238
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_status_tests>"
234239
)
235240
endif()
241+
242+
if(USE_XPRESS)
243+
ortools_cxx_test(
244+
NAME
245+
math_opt_solvers_xpress_solver_test
246+
SOURCES
247+
"xpress_solver_test.cc"
248+
LINK_LIBRARIES
249+
GTest::gmock
250+
GTest::gmock_main
251+
absl::status
252+
ortools::math_opt_matchers
253+
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_callback_tests>"
254+
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_invalid_input_tests>"
255+
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_generic_tests>"
256+
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_infeasible_subsystem_tests>"
257+
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_ip_model_solve_parameters_tests>"
258+
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_ip_parameter_tests>"
259+
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_logical_constraint_tests>"
260+
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_lp_incomplete_solve_tests>"
261+
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_lp_model_solve_parameters_tests>"
262+
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_lp_parameter_tests>"
263+
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_lp_tests>"
264+
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_mip_tests>"
265+
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_multi_objective_tests>"
266+
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_status_tests>"
267+
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_qp_tests>"
268+
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_second_order_cone_tests>"
269+
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_qc_tests>"
270+
)
271+
endif()

0 commit comments

Comments
 (0)