Add empty stubs for Highs support, #3116
This commit is contained in:
@@ -199,10 +199,12 @@ class MPSolver {
|
||||
// gradient method. Sometimes faster than Glop for medium-size problems and
|
||||
// scales to much larger problems than Glop.
|
||||
PDLP_LINEAR_PROGRAMMING = 8,
|
||||
HIGHS_LINEAR_PROGRAMMING = 15,
|
||||
|
||||
// Integer programming problems.
|
||||
// -----------------------------
|
||||
SCIP_MIXED_INTEGER_PROGRAMMING = 3, // Recommended default value.
|
||||
// Recommended default value for MIP problems.
|
||||
SCIP_MIXED_INTEGER_PROGRAMMING = 3,
|
||||
GLPK_MIXED_INTEGER_PROGRAMMING = 4,
|
||||
CBC_MIXED_INTEGER_PROGRAMMING = 5,
|
||||
|
||||
@@ -214,6 +216,8 @@ class MPSolver {
|
||||
XPRESS_LINEAR_PROGRAMMING = 101,
|
||||
XPRESS_MIXED_INTEGER_PROGRAMMING = 102,
|
||||
|
||||
HIGHS_MIXED_INTEGER_PROGRAMMING = 16,
|
||||
|
||||
// Boolean optimization problem (requires only integer variables and works
|
||||
// best with only Boolean variables).
|
||||
BOP_INTEGER_PROGRAMMING = 12,
|
||||
@@ -221,6 +225,8 @@ class MPSolver {
|
||||
// SAT based solver (requires only integer and Boolean variables).
|
||||
// If you pass it mixed integer problems, it will scale coefficients to
|
||||
// integer values, and solver continuous variables as integral variables.
|
||||
//
|
||||
// Recommended default value for pure integral problems problems.
|
||||
SAT_INTEGER_PROGRAMMING = 14,
|
||||
|
||||
// Dedicated knapsack solvers.
|
||||
|
||||
@@ -425,6 +425,7 @@ message MPModelRequest {
|
||||
XPRESS_LINEAR_PROGRAMMING =
|
||||
101; // Commercial, needs a valid license. NOLINT
|
||||
CPLEX_LINEAR_PROGRAMMING = 10; // Commercial, needs a valid license. NOLINT
|
||||
HIGHS_LINEAR_PROGRAMMING = 15;
|
||||
|
||||
SCIP_MIXED_INTEGER_PROGRAMMING = 3; // Recommended default for MIP models.
|
||||
GLPK_MIXED_INTEGER_PROGRAMMING = 4;
|
||||
@@ -434,13 +435,14 @@ message MPModelRequest {
|
||||
102; // Commercial, needs a valid license. NOLINT
|
||||
CPLEX_MIXED_INTEGER_PROGRAMMING =
|
||||
11; // Commercial, needs a valid license. NOLINT
|
||||
HIGHS_MIXED_INTEGER_PROGRAMMING = 16;
|
||||
BOP_INTEGER_PROGRAMMING = 12;
|
||||
|
||||
// WARNING: This solver will currently interpret all variables as integer,
|
||||
// so any solution you get will be valid, but the optimal might be far away
|
||||
// for the real one (when you authorise non-integer value for continuous
|
||||
// variables).
|
||||
SAT_INTEGER_PROGRAMMING = 14;
|
||||
SAT_INTEGER_PROGRAMMING = 14; // Recommended for pure integer problems.
|
||||
|
||||
// In-house linear programming solver based on the primal-dual hybrid
|
||||
// gradient method. Sometimes faster than Glop for medium-size problems and
|
||||
|
||||
@@ -19,6 +19,7 @@ cc_library(
|
||||
name = "proto_solver",
|
||||
srcs = [
|
||||
"gurobi_proto_solver.cc",
|
||||
"highs_proto_solver.cc",
|
||||
"pdlp_proto_solver.cc",
|
||||
"sat_proto_solver.cc",
|
||||
"sat_solver_utils.cc",
|
||||
@@ -26,6 +27,7 @@ cc_library(
|
||||
],
|
||||
hdrs = [
|
||||
"gurobi_proto_solver.h",
|
||||
"highs_proto_solver.h",
|
||||
"pdlp_proto_solver.h",
|
||||
"sat_proto_solver.h",
|
||||
"sat_solver_utils.h",
|
||||
@@ -34,6 +36,7 @@ cc_library(
|
||||
copts = [
|
||||
"-DUSE_PDLP",
|
||||
"-DUSE_SCIP",
|
||||
"-DUSE_HIGHS",
|
||||
],
|
||||
deps = [
|
||||
"//ortools/base",
|
||||
|
||||
37
ortools/linear_solver/proto_solver/highs_proto_solver.cc
Normal file
37
ortools/linear_solver/proto_solver/highs_proto_solver.cc
Normal file
@@ -0,0 +1,37 @@
|
||||
// Copyright 2010-2022 Google LLC
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "ortools/linear_solver/proto_solver/highs_proto_solver.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/status/statusor.h"
|
||||
#include "ortools/linear_solver/linear_solver.pb.h"
|
||||
#include "ortools/linear_solver/model_validator.h"
|
||||
#include "ortools/port/proto_utils.h"
|
||||
|
||||
namespace operations_research {
|
||||
|
||||
absl::StatusOr<MPSolutionResponse> HighsSolveProto(MPModelRequest request,
|
||||
bool solve_as_a_mip) {
|
||||
return absl::UnimplementedError("Highs support is not yet implemented");
|
||||
}
|
||||
|
||||
} // namespace operations_research
|
||||
31
ortools/linear_solver/proto_solver/highs_proto_solver.h
Normal file
31
ortools/linear_solver/proto_solver/highs_proto_solver.h
Normal file
@@ -0,0 +1,31 @@
|
||||
// Copyright 2010-2022 Google LLC
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef OR_TOOLS_LINEAR_SOLVER_PROTO_SOLVER_HIGHS_PROTO_SOLVER_H_
|
||||
#define OR_TOOLS_LINEAR_SOLVER_PROTO_SOLVER_HIGHS_PROTO_SOLVER_H_
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
#include "absl/status/statusor.h"
|
||||
#include "ortools/linear_solver/linear_solver.pb.h"
|
||||
|
||||
namespace operations_research {
|
||||
|
||||
// Solve the input MIP model with the HIGHS solver.
|
||||
absl::StatusOr<MPSolutionResponse> HighsSolveProto(MPModelRequest request,
|
||||
bool solve_as_a_mip = true);
|
||||
|
||||
} // namespace operations_research
|
||||
|
||||
#endif // OR_TOOLS_LINEAR_SOLVER_PROTO_SOLVER_HIGHS_PROTO_SOLVER_H_
|
||||
@@ -30,8 +30,9 @@ cc_library(
|
||||
srcs = ["model_builder_helper.cc"],
|
||||
hdrs = ["model_builder_helper.h"],
|
||||
copts = [
|
||||
"-DUSE_SCIP",
|
||||
],
|
||||
"-DUSE_HIGHS",
|
||||
"-DUSE_PDLP",
|
||||
"-DUSE_SCIP", ],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//ortools/linear_solver",
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "ortools/linear_solver/linear_solver.h"
|
||||
#include "ortools/linear_solver/linear_solver.pb.h"
|
||||
#include "ortools/linear_solver/proto_solver/highs_proto_solver.h"
|
||||
#include "ortools/linear_solver/proto_solver/sat_proto_solver.h"
|
||||
#if defined(USE_SCIP)
|
||||
#include "ortools/linear_solver/proto_solver/scip_proto_solver.h"
|
||||
@@ -324,6 +325,22 @@ void ModelSolverHelper::Solve(const ModelBuilderHelper& model) {
|
||||
break;
|
||||
}
|
||||
#endif // defined(USE_SCIP)
|
||||
#if defined(USE_HIGHS)
|
||||
case MPModelRequest::HIGHS_MIXED_INTEGER_PROGRAMMING: {
|
||||
const auto temp = HighsSolveProto(request, true);
|
||||
if (temp.ok()) {
|
||||
response_ = std::move(temp.value());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MPModelRequest::HIGHS_LINEAR_PROGRAMMING: {
|
||||
const auto temp = HighsSolveProto(request, false);
|
||||
if (temp.ok()) {
|
||||
response_ = std::move(temp.value());
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif // defined(USE_HIGHS)
|
||||
default: {
|
||||
response_->set_status(
|
||||
MPSolverResponseStatus::MPSOLVER_SOLVER_TYPE_UNAVAILABLE);
|
||||
|
||||
@@ -177,7 +177,7 @@ class XpressInterface : public MPSolverInterface {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
// TODO(user,user): Not yet working.
|
||||
// TODO(user): Not yet working.
|
||||
LOG(DFATAL) << "ComputeExactConditionNumber not implemented for"
|
||||
<< " XPRESS_LINEAR_PROGRAMMING";
|
||||
return 0.0;
|
||||
|
||||
Reference in New Issue
Block a user