OR-Tools  8.2
bop_util.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_BOP_BOP_UTIL_H_
15#define OR_TOOLS_BOP_BOP_UTIL_H_
16
17#include <vector>
18
24
25namespace operations_research {
26namespace bop {
27// Loads the problem state into the sat_solver. If the problem has already been
28// loaded in the sat_solver, fixed variables and objective bounds are updated.
29// Returns the status of the load:
30// - CONTINUE: State problem successfully loaded.
31// - OPTIMAL_SOLUTION_FOUND: Solution is proved optimal.
32// If a feasible solution exists, this load function imposes the solution
33// to be strictly better. Then when SAT proves the problem is UNSAT, that
34// actually means that the current solution is optimal.
35// - INFEASIBLE: The problem is proved to be infeasible.
36// Note that the sat_solver will be backtracked to the root level in order
37// to add new constraints.
39 const ProblemState& problem_state, sat::SatSolver* sat_solver);
40
41// Extracts from the sat solver any new information about the problem. Note that
42// the solver is not const because this function clears what is considered
43// "new".
44void ExtractLearnedInfoFromSatSolver(sat::SatSolver* solver, LearnedInfo* info);
45
46void SatAssignmentToBopSolution(const sat::VariablesAssignment& assignment,
47 BopSolution* solution);
48
50 public:
51 // Initial value is in [0..1].
52 explicit AdaptiveParameterValue(double initial_value);
53
54 void Reset();
55 void Increase();
56 void Decrease();
57
58 double value() const { return value_; }
59
60 private:
61 double value_;
62 int num_changes_;
63};
64
66 public:
67 // Initial value is in [0..1].
68 explicit LubyAdaptiveParameterValue(double initial_value);
69
70 void Reset();
71
72 void IncreaseParameter();
73 void DecreaseParameter();
74
75 double GetParameterValue() const;
76
77 void UpdateLuby();
78 bool BoostLuby();
79 int luby_value() const { return luby_value_; }
80
81 private:
82 int luby_id_;
83 int luby_boost_;
84 int luby_value_;
85
86 std::vector<AdaptiveParameterValue> difficulties_;
87};
88} // namespace bop
89} // namespace operations_research
90#endif // OR_TOOLS_BOP_BOP_UTIL_H_
BopOptimizerBase::Status LoadStateProblemToSatSolver(const ProblemState &problem_state, sat::SatSolver *sat_solver)
Definition: bop_util.cc:88
void SatAssignmentToBopSolution(const sat::VariablesAssignment &assignment, BopSolution *solution)
Definition: bop_util.cc:122
void ExtractLearnedInfoFromSatSolver(sat::SatSolver *solver, LearnedInfo *info)
Definition: bop_util.cc:99
The vehicle routing library lets one model and solve generic vehicle routing problems ranging from th...