add empty stubs for xpress for model_builder

This commit is contained in:
Laurent Perron
2023-12-11 14:03:14 +01:00
parent 0bb7d0c58b
commit d09c2ba849
5 changed files with 144 additions and 0 deletions

View File

@@ -167,3 +167,26 @@ cc_library(
"@com_google_absl//absl/status:statusor",
],
)
cc_library(
name = "xpress_proto_solver",
srcs = ["xpress_proto_solver.cc"],
hdrs = ["xpress_proto_solver.h"],
deps = [
"//ortools/base:timer",
"//ortools/xpress:environment",
"//ortools/linear_solver:linear_solver_cc_proto",
"//ortools/linear_solver:model_validator",
"//ortools/util:lazy_mutable_copy",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/cleanup",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:check",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
"@com_google_absl//absl/time",
"@com_google_absl//absl/types:optional",
],
)

View File

@@ -0,0 +1,56 @@
// 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 <algorithm>
#include <cmath>
#include <cstdint>
#include <limits>
#include <memory>
#include <numeric>
#include <string>
#include <vector>
#include "absl/base/attributes.h"
#include "absl/cleanup/cleanup.h"
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
#include "absl/strings/str_join.h"
#include "absl/strings/str_split.h"
#include "absl/strings/string_view.h"
#include "absl/time/clock.h"
#include "absl/time/time.h"
#include "absl/types/optional.h"
#include "ortools/base/logging.h"
#include "ortools/base/status_macros.h"
#include "ortools/base/timer.h"
#include "ortools/linear_solver/linear_solver.pb.h"
#include "ortools/linear_solver/model_validator.h"
#include "ortools/linear_solver/proto_solver/xpress_proto_solver.h"
#include "ortools/util/lazy_mutable_copy.h"
#include "ortools/xpress/environment.h"
namespace operations_research {
absl::StatusOr<MPSolutionResponse> XpressSolveProto(
const MPModelRequest& request) {
MPSolutionResponse response;
response.set_status(MPSOLVER_SOLVER_TYPE_UNAVAILABLE);
response.set_status_str(std::string("XPressMP not supported")); // NOLINT
return response;
}
} // namespace operations_research

View File

@@ -0,0 +1,32 @@
// 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_XPRESS_PROTO_SOLVER_H_
#define OR_TOOLS_LINEAR_SOLVER_PROTO_SOLVER_XPRESS_PROTO_SOLVER_H_
#include <string>
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/string_view.h"
#include "ortools/xpress/environment.h"
#include "ortools/linear_solver/linear_solver.pb.h"
namespace operations_research {
// Solves the input request.
absl::StatusOr<MPSolutionResponse> XpressSolveProto(
const MPModelRequest& request);
} // namespace operations_research
#endif // OR_TOOLS_LINEAR_SOLVER_PROTO_SOLVER_XPRESS_PROTO_SOLVER_H_

View File

@@ -45,8 +45,10 @@ cc_library(
"//ortools/linear_solver/proto_solver:pdlp_proto_solver",
"//ortools/linear_solver/proto_solver:sat_proto_solver",
"//ortools/linear_solver/proto_solver:scip_proto_solver",
"//ortools/linear_solver/proto_solver:xpress_proto_solver",
"//ortools/lp_data:lp_parser",
"//ortools/lp_data:mps_reader",
"//ortools/util:logging",
"//ortools/xpress:environment",
],
)

View File

@@ -26,11 +26,14 @@
#include "ortools/base/helpers.h"
#include "ortools/base/logging.h"
#include "ortools/base/options.h"
#include "ortools/gurobi/environment.h"
#include "ortools/linear_solver/linear_solver.h"
#include "ortools/linear_solver/linear_solver.pb.h"
#include "ortools/linear_solver/model_exporter.h"
#include "ortools/linear_solver/proto_solver/glop_proto_solver.h"
#include "ortools/linear_solver/proto_solver/gurobi_proto_solver.h"
#include "ortools/linear_solver/proto_solver/sat_proto_solver.h"
#include "ortools/linear_solver/proto_solver/xpress_proto_solver.h"
#include "ortools/linear_solver/solve_mp_model.h"
#if defined(USE_SCIP)
#include "ortools/linear_solver/proto_solver/scip_proto_solver.h"
@@ -42,6 +45,7 @@
#include "ortools/lp_data/lp_parser.h"
#endif // defined(USE_LP_PARSER)
#include "ortools/lp_data/mps_reader.h"
#include "ortools/xpress/environment.h"
namespace operations_research {
@@ -530,6 +534,16 @@ bool ModelSolverHelper::SolverIsSupported() const {
return true;
}
#endif // USE_SCIP
if (solver_type_.value() ==
MPModelRequest::GUROBI_MIXED_INTEGER_PROGRAMMING ||
solver_type_.value() == MPModelRequest::GUROBI_LINEAR_PROGRAMMING) {
return GurobiIsCorrectlyInstalled();
}
if (solver_type_.value() ==
MPModelRequest::XPRESS_MIXED_INTEGER_PROGRAMMING ||
solver_type_.value() == MPModelRequest::XPRESS_LINEAR_PROGRAMMING) {
return XpressIsCorrectlyInstalled();
}
return false;
}
@@ -581,6 +595,23 @@ void ModelSolverHelper::Solve(const ModelBuilderHelper& model) {
break;
}
#endif // defined(USE_PDLP)
case MPModelRequest::
GUROBI_LINEAR_PROGRAMMING: // ABSL_FALLTHROUGH_INTENDED
case MPModelRequest::GUROBI_MIXED_INTEGER_PROGRAMMING: {
const auto temp = GurobiSolveProto(request);
if (temp.ok()) {
response_ = std::move(temp.value());
}
}
case MPModelRequest::
XPRESS_LINEAR_PROGRAMMING: // ABSL_FALLTHROUGH_INTENDED
case MPModelRequest::XPRESS_MIXED_INTEGER_PROGRAMMING: {
const auto temp = XpressSolveProto(request);
if (temp.ok()) {
response_ = std::move(temp.value());
}
}
default: {
response_->set_status(
MPSolverResponseStatus::MPSOLVER_SOLVER_TYPE_UNAVAILABLE);