remove model_builder support for xpress as it is not implemented; move gurobi_util to linear_solver

This commit is contained in:
Laurent Perron
2025-06-17 13:41:54 +02:00
parent 8049f0387d
commit e995b1ad7a
18 changed files with 19 additions and 56 deletions

View File

@@ -35,17 +35,6 @@ cc_library(
],
)
cc_library(
name = "gurobi_util",
srcs = ["gurobi_util.cc"],
hdrs = ["gurobi_util.h"],
deps = [
":environment",
"@abseil-cpp//absl/strings",
"@abseil-cpp//absl/strings:str_format",
],
)
cc_library(
name = "gurobi_stdout_matchers",
testonly = True,

View File

@@ -12,7 +12,7 @@
# limitations under the License.
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
# load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
load("@protobuf//bazel:cc_proto_library.bzl", "cc_proto_library")
load("@protobuf//bazel:proto_library.bzl", "proto_library")
load("@protobuf//bazel:py_proto_library.bzl", "py_proto_library")
@@ -171,6 +171,7 @@ cc_library(
name = "linear_solver",
srcs = [
"gurobi_interface.cc",
"gurobi_util.cc",
"linear_expr.cc",
"linear_solver.cc",
"linear_solver_callback.cc",
@@ -211,6 +212,7 @@ cc_library(
"//conditions:default": [],
}),
hdrs = [
"gurobi_util.h",
"linear_expr.h",
"linear_solver.h",
"linear_solver_callback.h",
@@ -266,7 +268,6 @@ cc_library(
"//ortools/base:stl_util",
"//ortools/base:timer",
"//ortools/gurobi:environment",
"//ortools/gurobi:gurobi_util",
"//ortools/linear_solver/proto_solver:gurobi_proto_solver",
"//ortools/linear_solver/proto_solver:sat_proto_solver",
"//ortools/port:file",

View File

@@ -67,7 +67,7 @@
#include "ortools/base/logging.h"
#include "ortools/base/timer.h"
#include "ortools/gurobi/environment.h"
#include "ortools/gurobi/gurobi_util.h"
#include "ortools/linear_solver/gurobi_util.h"
#include "ortools/linear_solver/linear_solver.h"
#include "ortools/linear_solver/linear_solver_callback.h"
#include "ortools/linear_solver/proto_solver/gurobi_proto_solver.h"

View File

@@ -11,7 +11,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "ortools/gurobi/gurobi_util.h"
#include "ortools/linear_solver/gurobi_util.h"
#include <cstring>
#include <string>

View File

@@ -11,8 +11,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef OR_TOOLS_GUROBI_GUROBI_UTIL_H_
#define OR_TOOLS_GUROBI_GUROBI_UTIL_H_
#ifndef OR_TOOLS_LINEAR_SOLVER_GUROBI_UTIL_H_
#define OR_TOOLS_LINEAR_SOLVER_GUROBI_UTIL_H_
#include <string>
@@ -28,4 +28,4 @@ std::string GurobiParamInfoForLogging(GRBenv* grb,
bool one_liner_output = false);
} // namespace operations_research
#endif // OR_TOOLS_GUROBI_GUROBI_UTIL_H_
#endif // OR_TOOLS_LINEAR_SOLVER_GUROBI_UTIL_H_

View File

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

View File

@@ -18,6 +18,7 @@
import math
from ortools.linear_solver.python import model_builder
# [END import]

View File

@@ -16,6 +16,7 @@
# [START program]
# [START import]
from ortools.linear_solver import pywraplp
# [END import]

View File

@@ -16,6 +16,7 @@
# [START program]
# [START import]
from ortools.linear_solver import pywraplp
# [END import]

View File

@@ -17,6 +17,7 @@
# [START program]
# [START import]
from ortools.linear_solver import pywraplp
# [END import]
@@ -37,6 +38,7 @@ def create_data_model():
data["num_constraints"] = 4
return data
# [END data_model]

View File

@@ -16,6 +16,7 @@
"""Solve a multiple knapsack problem using a MIP solver."""
# [START import]
from ortools.linear_solver import pywraplp
# [END import]

View File

@@ -16,6 +16,7 @@
# [START program]
# [START import]
from ortools.linear_solver import pywraplp
# [END import]

View File

@@ -18,6 +18,7 @@
import math
from ortools.linear_solver.python import model_builder
# [END import]

View File

@@ -16,6 +16,7 @@
# [START program]
# [START import]
from ortools.linear_solver import pywraplp
# [END import]

View File

@@ -18,6 +18,7 @@
import math
from ortools.linear_solver.python import model_builder
# [END import]

View File

@@ -20,6 +20,7 @@ https://en.wikipedia.org/wiki/Stigler_diet.
"""
# [START import]
from ortools.linear_solver import pywraplp
# [END import]

View File

@@ -46,10 +46,8 @@ 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

@@ -37,7 +37,6 @@
#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"
@@ -50,7 +49,6 @@
#endif // defined(USE_PDLP)
#include "ortools/lp_data/lp_parser.h"
#include "ortools/lp_data/mps_reader.h"
#include "ortools/xpress/environment.h"
namespace operations_research {
namespace mb {
@@ -557,11 +555,6 @@ bool ModelSolverHelper::SolverIsSupported() const {
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;
}
@@ -635,12 +628,6 @@ void ModelSolverHelper::Solve(const ModelBuilderHelper& model) {
break;
}
#endif // defined(USE_HIGHS)
case MPModelRequest::
XPRESS_LINEAR_PROGRAMMING: // ABSL_FALLTHROUGH_INTENDED
case MPModelRequest::XPRESS_MIXED_INTEGER_PROGRAMMING: {
response_ = XPressSolveProto(request);
break;
}
default: {
response_->set_status(
MPSolverResponseStatus::MPSOLVER_SOLVER_TYPE_UNAVAILABLE);