lp_data: remove model_reader

This commit is contained in:
Corentin Le Molgat
2025-08-21 09:24:48 +02:00
parent d9756ddc61
commit 0d2c2e6782
4 changed files with 0 additions and 122 deletions

View File

@@ -404,7 +404,6 @@ cc_binary(
"//ortools/base",
"//ortools/base:file",
"//ortools/lp_data:lp_parser",
"//ortools/lp_data:model_reader",
"//ortools/lp_data:mps_reader",
"//ortools/lp_data:sol_reader",
"@abseil-cpp//absl/status",

View File

@@ -323,22 +323,6 @@ cc_library(
],
)
cc_library(
name = "model_reader",
srcs = ["model_reader.cc"],
hdrs = ["model_reader.h"],
deps = [
":lp_data",
":mps_reader",
":proto_utils",
# "//net/proto2/util/public:differencer",
"//ortools/base",
"//ortools/base:file",
"//ortools/linear_solver:linear_solver_cc_proto",
"//ortools/util:file_util",
],
)
cc_library(
name = "lp_decomposer",
srcs = ["lp_decomposer.cc"],

View File

@@ -1,70 +0,0 @@
// Copyright 2010-2025 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/lp_data/model_reader.h"
#include <string>
#include "absl/log/log.h"
#include "ortools/linear_solver/linear_solver.pb.h"
#include "ortools/lp_data/lp_data.h"
#include "ortools/lp_data/proto_utils.h"
#include "ortools/util/file_util.h"
namespace operations_research {
namespace glop {
bool LoadMPModelProtoFromModelOrRequest(const std::string& input_file_path,
MPModelProto* model) {
MPModelProto model_proto;
MPModelRequest request_proto;
ReadFileToProto(input_file_path, &model_proto).IgnoreError();
ReadFileToProto(input_file_path, &request_proto).IgnoreError();
// If the input proto is in binary format, both ReadFileToProto could return
// true. Instead use the actual number of variables found to test the
// correct format of the input.
const bool is_model_proto = model_proto.variable_size() > 0;
const bool is_request_proto = request_proto.model().variable_size() > 0;
if (!is_model_proto && !is_request_proto) {
LOG(ERROR) << "Failed to parse '" << input_file_path
<< "' as an MPModelProto or an MPModelRequest.";
return false;
} else {
if (is_model_proto && is_request_proto) {
LOG(ERROR) << input_file_path
<< " is parsing as both MPModelProto and MPModelRequest";
return false;
}
if (is_request_proto) {
VLOG(1) << "Read input proto as an MPModelRequest.";
model_proto.Swap(request_proto.mutable_model());
} else {
VLOG(1) << "Read input proto as an MPModelProto.";
}
}
model->Swap(&model_proto);
return true;
}
bool LoadLinearProgramFromModelOrRequest(const std::string& input_file_path,
LinearProgram* linear_program) {
MPModelProto model_proto;
if (LoadMPModelProtoFromModelOrRequest(input_file_path, &model_proto)) {
MPModelProtoToLinearProgram(model_proto, linear_program);
return true;
}
return false;
}
} // namespace glop
} // namespace operations_research

View File

@@ -1,35 +0,0 @@
// Copyright 2010-2025 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_LP_DATA_MODEL_READER_H_
#define OR_TOOLS_LP_DATA_MODEL_READER_H_
#include <string>
#include "ortools/linear_solver/linear_solver.pb.h"
#include "ortools/lp_data/lp_data.h"
namespace operations_research {
namespace glop {
// Helper function to read data from model files into MPModelProto and
// LinearProgram.
bool LoadMPModelProtoFromModelOrRequest(const std::string& input_file_path,
MPModelProto* model);
bool LoadLinearProgramFromModelOrRequest(const std::string& input_file_path,
LinearProgram* linear_program);
} // namespace glop
} // namespace operations_research
#endif // OR_TOOLS_LP_DATA_MODEL_READER_H_