OR-Tools
8.1
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
19
#include "
ortools/base/basictypes.h
"
20
#include "
ortools/base/integral_types.h
"
21
#include "
ortools/bop/bop_base.h
"
22
#include "
ortools/bop/bop_solution.h
"
23
#include "
ortools/sat/sat_solver.h
"
24
25
namespace
operations_research
{
26
namespace
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.
38
BopOptimizerBase::Status
LoadStateProblemToSatSolver
(
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".
44
void
ExtractLearnedInfoFromSatSolver
(sat::SatSolver* solver, LearnedInfo* info);
45
46
void
SatAssignmentToBopSolution
(
const
sat::VariablesAssignment& assignment,
47
BopSolution* solution);
48
49
class
AdaptiveParameterValue
{
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
65
class
LubyAdaptiveParameterValue
{
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_
integral_types.h
operations_research::bop::LubyAdaptiveParameterValue::LubyAdaptiveParameterValue
LubyAdaptiveParameterValue(double initial_value)
Definition:
bop_util.cc:158
operations_research::bop::AdaptiveParameterValue::Decrease
void Decrease()
Definition:
bop_util.cc:149
operations_research::bop::LubyAdaptiveParameterValue::BoostLuby
bool BoostLuby()
Definition:
bop_util.cc:190
operations_research::bop::LubyAdaptiveParameterValue
Definition:
bop_util.h:65
operations_research::bop::LubyAdaptiveParameterValue::UpdateLuby
void UpdateLuby()
Definition:
bop_util.cc:195
operations_research
The vehicle routing library lets one model and solve generic vehicle routing problems ranging from th...
Definition:
dense_doubly_linked_list.h:21
bop_solution.h
operations_research::bop::LoadStateProblemToSatSolver
BopOptimizerBase::Status LoadStateProblemToSatSolver(const ProblemState &problem_state, sat::SatSolver *sat_solver)
Definition:
bop_util.cc:87
operations_research::bop::LubyAdaptiveParameterValue::Reset
void Reset()
Definition:
bop_util.cc:166
operations_research::bop::AdaptiveParameterValue::Increase
void Increase()
Definition:
bop_util.cc:143
sat_solver.h
operations_research::bop::LubyAdaptiveParameterValue::luby_value
int luby_value() const
Definition:
bop_util.h:79
operations_research::bop::SatAssignmentToBopSolution
void SatAssignmentToBopSolution(const sat::VariablesAssignment &assignment, BopSolution *solution)
Definition:
bop_util.cc:121
operations_research::bop::LubyAdaptiveParameterValue::IncreaseParameter
void IncreaseParameter()
Definition:
bop_util.cc:175
operations_research::bop::ExtractLearnedInfoFromSatSolver
void ExtractLearnedInfoFromSatSolver(sat::SatSolver *solver, LearnedInfo *info)
Definition:
bop_util.cc:98
basictypes.h
operations_research::bop::LubyAdaptiveParameterValue::GetParameterValue
double GetParameterValue() const
Definition:
bop_util.cc:185
operations_research::bop::AdaptiveParameterValue
Definition:
bop_util.h:49
operations_research::bop::AdaptiveParameterValue::AdaptiveParameterValue
AdaptiveParameterValue(double initial_value)
Definition:
bop_util.cc:138
operations_research::bop::AdaptiveParameterValue::value
double value() const
Definition:
bop_util.h:58
bop_base.h
operations_research::bop::LubyAdaptiveParameterValue::DecreaseParameter
void DecreaseParameter()
Definition:
bop_util.cc:180
operations_research::bop::BopOptimizerBase::Status
Status
Definition:
bop_base.h:61
operations_research::bop::AdaptiveParameterValue::Reset
void Reset()
Definition:
bop_util.cc:141
ortools
bop
bop_util.h
Generated by
1.8.20