Google OR-Tools v9.9
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
bop_util.h
Go to the documentation of this file.
1// Copyright 2010-2024 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
23
24namespace operations_research {
25namespace bop {
26// Loads the problem state into the sat_solver. If the problem has already been
27// loaded in the sat_solver, fixed variables and objective bounds are updated.
28// Returns the status of the load:
29// - CONTINUE: State problem successfully loaded.
30// - OPTIMAL_SOLUTION_FOUND: Solution is proved optimal.
31// If a feasible solution exists, this load function imposes the solution
32// to be strictly better. Then when SAT proves the problem is UNSAT, that
33// actually means that the current solution is optimal.
34// - INFEASIBLE: The problem is proved to be infeasible.
35// Note that the sat_solver will be backtracked to the root level in order
36// to add new constraints.
38 const ProblemState& problem_state, sat::SatSolver* sat_solver);
39
40// Extracts from the sat solver any new information about the problem. Note that
41// the solver is not const because this function clears what is considered
42// "new".
43void ExtractLearnedInfoFromSatSolver(sat::SatSolver* solver, LearnedInfo* info);
44
45void SatAssignmentToBopSolution(const sat::VariablesAssignment& assignment,
46 BopSolution* solution);
47
49 public:
50 // Initial value is in [0..1].
51 explicit AdaptiveParameterValue(double initial_value);
52
53 void Reset();
54 void Increase();
55 void Decrease();
56
57 double value() const { return value_; }
58
59 private:
60 double value_;
61 int num_changes_;
62};
63
65 public:
66 // Initial value is in [0..1].
67 explicit LubyAdaptiveParameterValue(double initial_value);
68
69 void Reset();
70
71 void IncreaseParameter();
72 void DecreaseParameter();
73
74 double GetParameterValue() const;
75
76 void UpdateLuby();
77 bool BoostLuby();
78 int luby_value() const { return luby_value_; }
79
80 private:
81 int luby_id_;
82 int luby_boost_;
83 int luby_value_;
84
85 std::vector<AdaptiveParameterValue> difficulties_;
86};
87} // namespace bop
88} // namespace operations_research
89#endif // OR_TOOLS_BOP_BOP_UTIL_H_
AdaptiveParameterValue(double initial_value)
Initial value is in [0..1].
Definition bop_util.cc:151
LubyAdaptiveParameterValue(double initial_value)
Initial value is in [0..1].
Definition bop_util.cc:173
double solution
BopOptimizerBase::Status LoadStateProblemToSatSolver(const ProblemState &problem_state, sat::SatSolver *sat_solver)
Definition bop_util.cc:98
void SatAssignmentToBopSolution(const sat::VariablesAssignment &assignment, BopSolution *solution)
Definition bop_util.cc:132
void ExtractLearnedInfoFromSatSolver(sat::SatSolver *solver, LearnedInfo *info)
Definition bop_util.cc:109
In SWIG mode, we don't want anything besides these top-level includes.