OR-Tools  9.0
cp_model_checker.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_SAT_CP_MODEL_CHECKER_H_
15 #define OR_TOOLS_SAT_CP_MODEL_CHECKER_H_
16 
17 #include <cstdint>
18 #include <string>
19 #include <vector>
20 
23 
24 namespace operations_research {
25 namespace sat {
26 
27 // Verifies that the given model satisfies all the properties described in the
28 // proto comments. Returns an empty string if it is the case, otherwise fails at
29 // the first error and returns a human-readable description of the issue.
30 //
31 // TODO(user): Add any needed overflow validation because we are far from
32 // exhaustive. We could also run a small presolve that tighten variable bounds
33 // before the overflow check to facilitate the lives of our users, but it is a
34 // some work to put in place.
35 std::string ValidateCpModel(const CpModelProto& model);
36 
37 // Verifies that the given variable assignment is a feasible solution of the
38 // given model. The values vector should be in one to one correspondence with
39 // the model.variables() list of variables.
40 //
41 // The last two arguments are optional and help debugging a failing constraint
42 // due to presolve.
43 bool SolutionIsFeasible(const CpModelProto& model,
44  const std::vector<int64_t>& variable_values,
45  const CpModelProto* mapping_proto = nullptr,
46  const std::vector<int>* postsolve_mapping = nullptr);
47 
48 } // namespace sat
49 } // namespace operations_research
50 
51 #endif // OR_TOOLS_SAT_CP_MODEL_CHECKER_H_
GRBmodel * model
bool SolutionIsFeasible(const CpModelProto &model, const std::vector< int64_t > &variable_values, const CpModelProto *mapping_proto, const std::vector< int > *postsolve_mapping)
std::string ValidateCpModel(const CpModelProto &model)
Collection of objects used to extend the Constraint Solver library.