OR-Tools  8.2
model_validator.h
Go to the documentation of this file.
1 // Copyright 2010-2018 Google LLC
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
5 //
6 // http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13 
14 #ifndef OR_TOOLS_LINEAR_SOLVER_MODEL_VALIDATOR_H_
15 #define OR_TOOLS_LINEAR_SOLVER_MODEL_VALIDATOR_H_
16 
17 #include <string>
18 
19 #include "absl/types/optional.h"
20 #include "ortools/linear_solver/linear_solver.pb.h"
22 
23 namespace operations_research {
37 std::string FindErrorInMPModelProto(const MPModelProto& model,
38  double abs_value_threshold = 0.0);
39 
46 std::string FindErrorInMPModelDeltaProto(const MPModelDeltaProto& delta,
47  const MPModelProto& model);
48 
53 absl::optional<LazyMutableCopy<MPModelProto>>
54 ExtractValidMPModelOrPopulateResponseStatus(const MPModelRequest& request,
55  MPSolutionResponse* response);
56 
63  MPModelRequest* request, MPSolutionResponse* response);
64 
75 std::string FindFeasibilityErrorInSolutionHint(const MPModelProto& model,
76  double tolerance);
77 
78 // Partially merges a MPConstraintProto onto another, skipping only the
79 // repeated fields "var_index" and "coefficients". This is used within
80 // FindErrorInMPModelDeltaProto.
81 // See the unit test MergeMPConstraintProtoExceptTermsTest that explains why we
82 // need this.
83 void MergeMPConstraintProtoExceptTerms(const MPConstraintProto& from,
84  MPConstraintProto* to);
85 
86 // PUBLIC FOR TESTING ONLY.
87 // Applies the given model_delta to "model". Assumes that
88 // FindErrorInMPModelDeltaProto() found no error.
89 void ApplyVerifiedMPModelDelta(const MPModelDeltaProto& delta,
90  MPModelProto* model);
91 
92 } // namespace operations_research
93 
94 #endif // OR_TOOLS_LINEAR_SOLVER_MODEL_VALIDATOR_H_
SharedResponseManager * response
GRBmodel * model
The vehicle routing library lets one model and solve generic vehicle routing problems ranging from th...
bool ExtractValidMPModelInPlaceOrPopulateResponseStatus(MPModelRequest *request, MPSolutionResponse *response)
Like ExtractValidMPModelOrPopulateResponseStatus(), but works in-place: if the MPModel needed extract...
std::string FindErrorInMPModelDeltaProto(const MPModelDeltaProto &delta, const MPModelProto &model)
Like FindErrorInMPModelProto, but for a MPModelDeltaProto applied to a given baseline model (assumed ...
void ApplyVerifiedMPModelDelta(const MPModelDeltaProto &delta, MPModelProto *model)
absl::optional< LazyMutableCopy< MPModelProto > > ExtractValidMPModelOrPopulateResponseStatus(const MPModelRequest &request, MPSolutionResponse *response)
If the model is valid and non-empty, returns it (possibly after extracting the model_delta).
std::string FindErrorInMPModelProto(const MPModelProto &model, double abs_value_threshold)
Returns an empty string iff the model is valid and not trivially infeasible.
std::string FindFeasibilityErrorInSolutionHint(const MPModelProto &model, double tolerance)
Returns an empty string if the solution hint given in the model is a feasible solution.
void MergeMPConstraintProtoExceptTerms(const MPConstraintProto &from, MPConstraintProto *to)
int64 delta
Definition: resource.cc:1684