OR-Tools  8.2
cp_model_search.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_SAT_CP_MODEL_SEARCH_H_
15#define OR_TOOLS_SAT_CP_MODEL_SEARCH_H_
16
17#include <functional>
18#include <vector>
19
21#include "ortools/sat/cp_model.pb.h"
22#include "ortools/sat/integer.h"
24#include "ortools/sat/model.h"
25
26namespace operations_research {
27namespace sat {
28
29// Constructs the search strategy specified in the given CpModelProto. A
30// positive variable ref in the proto is mapped to variable_mapping[ref] in the
31// model. All the variables referred in the search strategy must be correctly
32// mapped, the other entries can be set to kNoIntegerVariable.
33std::function<BooleanOrIntegerLiteral()> ConstructSearchStrategy(
34 const CpModelProto& cp_model_proto,
35 const std::vector<IntegerVariable>& variable_mapping,
36 IntegerVariable objective_var, Model* model);
37
38// For debugging fixed-search: display information about the named variables
39// domain before taking each decision. Note that we copy the instrumented
40// stategy so it doesn't have to outlive the returned functions like the other
41// arguments.
42std::function<BooleanOrIntegerLiteral()> InstrumentSearchStrategy(
43 const CpModelProto& cp_model_proto,
44 const std::vector<IntegerVariable>& variable_mapping,
45 const std::function<BooleanOrIntegerLiteral()>& instrumented_strategy,
46 Model* model);
47
48// Returns up to "num_workers" different parameters. We do not always return
49// num_worker parameters to leave room for strategies like LNS that do not
50// consume a full worker and can always be interleaved.
51std::vector<SatParameters> GetDiverseSetOfParameters(
52 const SatParameters& base_params, const CpModelProto& cp_model,
53 const int num_workers);
54
55} // namespace sat
56} // namespace operations_research
57
58#endif // OR_TOOLS_SAT_CP_MODEL_SEARCH_H_
GRBmodel * model
std::vector< SatParameters > GetDiverseSetOfParameters(const SatParameters &base_params, const CpModelProto &cp_model, const int num_workers)
std::function< BooleanOrIntegerLiteral()> ConstructSearchStrategy(const CpModelProto &cp_model_proto, const std::vector< IntegerVariable > &variable_mapping, IntegerVariable objective_var, Model *model)
std::function< BooleanOrIntegerLiteral()> InstrumentSearchStrategy(const CpModelProto &cp_model_proto, const std::vector< IntegerVariable > &variable_mapping, const std::function< BooleanOrIntegerLiteral()> &instrumented_strategy, Model *model)
The vehicle routing library lets one model and solve generic vehicle routing problems ranging from th...