Skip to content

Commit

Permalink
Merge pull request #4417 from galabovaa/ig-lp-highs
Browse files Browse the repository at this point in the history
HiGHS updates
  • Loading branch information
lperron authored Oct 21, 2024
2 parents a48f334 + d5f005e commit 217594e
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Dependencies.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Clp=1.17.7
Cgl=0.60.5
Cbc=2.10.7
GLPK=5.0
HiGHS=v1.7.2
HiGHS=v1.8.0
Scip=v900
# Python
pybind11=v2.12.0
Expand Down
2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ cc_library(

git_repository(
name = "highs",
branch = "v1.7.2",
branch = "v1.8.0",
remote = "https://github.com/ERGO-Code/HiGHS.git",
)

Expand Down
4 changes: 2 additions & 2 deletions cmake/dependencies/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,10 @@ if(BUILD_HIGHS)
FetchContent_Declare(
highs
GIT_REPOSITORY "https://github.com/ERGO-Code/HiGHS.git"
GIT_TAG "v1.7.2"
GIT_TAG "v1.8.0"
GIT_SHALLOW TRUE
PATCH_COMMAND git apply --ignore-whitespace
"${CMAKE_CURRENT_LIST_DIR}/../../patches/highs-v1.7.2.patch"
"${CMAKE_CURRENT_LIST_DIR}/../../patches/highs-v1.8.0.patch"
)
FetchContent_MakeAvailable(highs)
list(POP_BACK CMAKE_MESSAGE_INDENT)
Expand Down
1 change: 1 addition & 0 deletions examples/cpp/linear_programming.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ void RunAllExamples() {
RunLinearProgrammingExample("GLPK_LP");
RunLinearProgrammingExample("XPRESS_LP");
RunLinearProgrammingExample("PDLP");
RunLinearProgrammingExample("HIGHS");
}
} // namespace operations_research

Expand Down
45 changes: 41 additions & 4 deletions ortools/linear_solver/proto_solver/highs_proto_solver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ absl::StatusOr<MPSolutionResponse> HighsSolveProto(
const MPModelProto& model = **optional_model;

Highs highs;
// TODO(user): Set model name.
// Set model name.
if (model.has_name()) {
const std::string model_name = model.name();
highs.passModelName(model_name);
}

if (request->has_solver_specific_parameters()) {
const auto parameters_status = SetSolverSpecificParameters(
Expand Down Expand Up @@ -111,8 +115,29 @@ absl::StatusOr<MPSolutionResponse> HighsSolveProto(
highs.changeColCost(column, obj_coeffs[column]);
}

// TODO(user): Support variable names.
// TODO(user): Support hints.
// Variable names.
for (int v = 0; v < variable_size; ++v) {
const MPVariableProto& variable = model.variable(v);
std::string varname_str = "";
if (!variable.name().empty()) {
varname_str = variable.name().c_str();
highs.passColName(v, varname_str);
}
}

// Hints.
int num_hints = model.solution_hint().var_index_size();
if (num_hints > 0) {
std::vector<HighsInt> hint_index(0, num_hints);
std::vector<double> hint_value(0, num_hints);
for (int i = 0; i < num_hints; ++i) {
hint_index[i] = model.solution_hint().var_index(i);
hint_value[i] = model.solution_hint().var_value(i);
}
const int* hint_indices = &hint_index[0];
const double* hint_values = &hint_value[0];
highs.setSolution((HighsInt)num_hints, hint_indices, hint_values);
}
}

{
Expand Down Expand Up @@ -157,7 +182,16 @@ absl::StatusOr<MPSolutionResponse> HighsSolveProto(
return response;
}
}
// TODO(user): Support constraint names.

// Constraint names.
for (int c = 0; c < model.constraint_size(); ++c) {
const MPConstraintProto& constraint = model.constraint(c);
std::string constraint_name_str = "";
if (!constraint.name().empty()) {
constraint_name_str = constraint.name().c_str();
highs.passRowName(c, constraint_name_str);
}
}
}

if (!model.general_constraint().empty()) {
Expand Down Expand Up @@ -220,6 +254,9 @@ absl::StatusOr<MPSolutionResponse> HighsSolveProto(
break;
default: {
// TODO(user): report feasible status.
const HighsInfo& info = highs.getInfo();
if (info.primal_solution_status == kSolutionStatusFeasible)
response.set_status(MPSOLVER_FEASIBLE);
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion ortools/math_opt/solver_tests/status_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ TEST_P(StatusTest, PrimalAndDualInfeasible) {
"with a primal-dual infeasible LP relaxation.";
}
if (GetParam().solver_type == SolverType::kHighs) {
GTEST_SKIP() << "Ignoring this test as Highs 1.7+ returns error.";
TEST_SKIP() << "Ignoring this test as Highs 1.7+ returns error.";
}

Model model;
Expand Down
File renamed without changes.

0 comments on commit 217594e

Please sign in to comment.