C++ Reference

C++ Reference: Linear solver

model_validator.h
Go to the documentation of this file.
1// Copyright 2010-2021 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"
21#include "ortools/util/lazy_mutable_copy.h"
22
23namespace operations_research {
38 const MPModelProto& model, double abs_value_threshold = 0.0,
39 // If false, variable and constraint bounds like [lb=1.2, ub=0.7] yield an
40 // error, and also integer variable bounds like [0.7, 0.8].
41 bool accept_trivially_infeasible_bounds = false);
42
50 const MPModelProto& model);
51
56absl::optional<LazyMutableCopy<MPModelProto>>
58 MPSolutionResponse* response);
59
66 MPModelRequest* request, MPSolutionResponse* response);
67
79 double tolerance);
80
81// Partially merges a MPConstraintProto onto another, skipping only the
82// repeated fields "var_index" and "coefficients". This is used within
83// FindErrorInMPModelDeltaProto.
84// See the unit test MergeMPConstraintProtoExceptTermsTest that explains why we
85// need this.
88
89// Applies the given model_delta to "model". Assumes that
90// FindErrorInMPModelDeltaProto() found no error. For full error checking,
91// please use ExtractValidMPModelOrPopulateResponseStatus() instead.
93 MPModelProto* model);
94
95} // namespace operations_research
96
97#endif // OR_TOOLS_LINEAR_SOLVER_MODEL_VALIDATOR_H_
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)
bool ExtractValidMPModelInPlaceOrPopulateResponseStatus(MPModelRequest *request, MPSolutionResponse *response)
Like ExtractValidMPModelOrPopulateResponseStatus(), but works in-place: if the MPModel needed extract...
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=0.0, bool accept_trivially_infeasible_bounds=false)
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)