Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Feature/xpress solver for mathopt #137

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
7 changes: 0 additions & 7 deletions ortools/linear_solver/xpress_interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,6 @@ void interruptXPRESS(XPRSprob& xprsProb, CUSTOM_INTERRUPT_REASON reason) {
XPRSinterrupt(xprsProb, 1000 + reason);
}

enum XPRS_BASIS_STATUS {
XPRS_AT_LOWER = 0,
XPRS_BASIC = 1,
XPRS_AT_UPPER = 2,
XPRS_FREE_SUPER = 3
};

// In case we need to return a double but don't have a value for that
// we just return a NaN.
#if !defined(XPRS_NAN)
Expand Down
2 changes: 2 additions & 0 deletions ortools/math_opt/cpp/parameters.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ std::optional<absl::string_view> Enum<SolverType>::ToOptString(
return "highs";
case SolverType::kSantorini:
return "santorini";
case SolverType::kXpress:
return "xpress";
}
return std::nullopt;
}
Expand Down
6 changes: 6 additions & 0 deletions ortools/math_opt/cpp/parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ enum class SolverType {
// Slow/not recommended for production. Not an LP solver (no dual information
// returned).
kSantorini = SOLVER_TYPE_SANTORINI,

// Fico XPRESS solver (third party).
//
// Supports LP, MIP, and nonconvex integer quadratic problems.
// A fast option, but has special licensing.
kXpress = SOLVER_TYPE_XPRESS
};

MATH_OPT_DEFINE_ENUM(SolverType, SOLVER_TYPE_UNSPECIFIED);
Expand Down
6 changes: 6 additions & 0 deletions ortools/math_opt/parameters.proto
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ enum SolverTypeProto {
// Slow/not recommended for production. Not an LP solver (no dual information
// returned).
SOLVER_TYPE_SANTORINI = 11;

// Fico XPRESS solver (third party).
//
// Supports LP, MIP, and nonconvex integer quadratic problems.
// A fast option, but has special licensing.
SOLVER_TYPE_XPRESS = 12;
}

// Selects an algorithm for solving linear programs.
Expand Down
6 changes: 6 additions & 0 deletions ortools/math_opt/solver_tests/base_solver_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ bool ActivatePrimalRay(const SolverType solver_type, SolveParameters& params) {
return false;
case SolverType::kHighs:
return false;
case SolverType::kXpress:
// TODO: support XPRESS
return false;
default:
LOG(FATAL)
<< "Solver " << solver_type
Expand Down Expand Up @@ -82,6 +85,9 @@ bool ActivateDualRay(const SolverType solver_type, SolveParameters& params) {
return false;
case SolverType::kHighs:
return false;
case SolverType::kXpress:
// TODO: support XPRESS
return false;
default:
LOG(FATAL)
<< "Solver " << solver_type
Expand Down
36 changes: 36 additions & 0 deletions ortools/math_opt/solvers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ if(NOT USE_SCIP)
list(FILTER _SRCS EXCLUDE REGEX "/gscip_.*.h$")
list(FILTER _SRCS EXCLUDE REGEX "/gscip_.*.cc$")
endif()
if(NOT USE_XPRESS)
list(FILTER _SRCS EXCLUDE REGEX "/xpress/")
list(FILTER _SRCS EXCLUDE REGEX "/xpress_.*.h$")
list(FILTER _SRCS EXCLUDE REGEX "/xpress_.*.cc$")
endif()
target_sources(${NAME} PRIVATE ${_SRCS})
set_target_properties(${NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_include_directories(${NAME} PUBLIC
Expand Down Expand Up @@ -233,3 +238,34 @@ if(USE_HIGHS)
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_status_tests>"
)
endif()

if(USE_XPRESS)
ortools_cxx_test(
NAME
math_opt_solvers_xpress_solver_test
SOURCES
"xpress_solver_test.cc"
LINK_LIBRARIES
GTest::gmock
GTest::gmock_main
absl::status
ortools::math_opt_matchers
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_callback_tests>"
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_invalid_input_tests>"
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_generic_tests>"
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_infeasible_subsystem_tests>"
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_ip_model_solve_parameters_tests>"
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_ip_parameter_tests>"
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_logical_constraint_tests>"
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_lp_incomplete_solve_tests>"
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_lp_model_solve_parameters_tests>"
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_lp_parameter_tests>"
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_lp_tests>"
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_mip_tests>"
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_multi_objective_tests>"
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_status_tests>"
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_qp_tests>"
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_second_order_cone_tests>"
"$<LINK_LIBRARY:WHOLE_ARCHIVE,ortools::math_opt_qc_tests>"
)
endif()
Loading