28 static const int kMaxLubyIndex = 30;
29 static const int kMaxBoost = 30;
34 bool InternalLoadStateProblemToSatSolver(
const ProblemState& problem_state,
35 sat::SatSolver* sat_solver) {
36 const bool first_time = (sat_solver->NumVariables() == 0);
38 sat_solver->SetNumVariables(
39 problem_state.original_problem().num_variables());
42 sat_solver->Backtrack(0);
46 for (VariableIndex
var(0);
var < problem_state.is_fixed().size(); ++
var) {
47 if (problem_state.is_fixed()[
var]) {
48 if (!sat_solver->AddUnitClause(
49 sat::Literal(sat::BooleanVariable(
var.value()),
50 problem_state.fixed_values()[
var]))) {
69 sat::Coefficient(problem_state.lower_bound()),
71 sat::Coefficient(problem_state.upper_bound() - 1),
77 sat_solver->TrackBinaryClauses(
true);
78 if (!sat_solver->AddBinaryClauses(problem_state.NewlyAddedBinaryClauses())) {
81 sat_solver->ClearNewlyAddedBinaryClauses();
89 if (InternalLoadStateProblemToSatSolver(problem_state, sat_solver)) {
100 CHECK(
nullptr != solver);
101 CHECK(
nullptr != info);
110 ? propagation_trail.
Index()
111 : solver->
Decisions().front().trail_index;
112 for (
int trail_index = 0; trail_index < root_size; ++trail_index) {
123 CHECK(solution !=
nullptr);
127 for (sat::BooleanVariable
var(0);
var < solution->
Size(); ++
var) {
130 const VariableIndex bop_var_id(
var.value());
139 : value_(initial_value), num_changes_(0) {}
145 const double factor = 1.0 + 1.0 / (num_changes_ / 2.0 + 1);
146 value_ =
std::min(1.0 - (1.0 - value_) / factor, value_ * factor);
151 const double factor = 1.0 + 1.0 / (num_changes_ / 2.0 + 1);
152 value_ =
std::max(value_ / factor, 1.0 - (1.0 - value_) * factor);
170 for (
int i = 0; i < difficulties_.size(); ++i) {
171 difficulties_[i].Reset();
177 difficulties_[luby_msb].Increase();
182 difficulties_[luby_msb].Decrease();
187 return difficulties_[luby_msb].value();
192 return luby_boost_ >= kMaxBoost;
197 luby_value_ =
sat::SUniv(luby_id_) << luby_boost_;