32 strategy_counter_ = 0;
33 strategy_change_conflicts_ =
34 parameters_.num_conflicts_before_strategy_changes();
35 conflicts_until_next_strategy_change_ = strategy_change_conflicts_;
38 conflicts_until_next_restart_ = parameters_.restart_period();
40 dl_running_average_.
Reset(parameters_.restart_running_window_size());
41 lbd_running_average_.
Reset(parameters_.restart_running_window_size());
42 trail_size_running_average_.
Reset(parameters_.blocking_restart_window_size());
49 for (
int i = 0;
i < parameters_.restart_algorithms_size(); ++
i) {
50 strategies_.push_back(parameters_.restart_algorithms(
i));
52 if (strategies_.empty()) {
53 const std::vector<std::string> string_values = absl::StrSplit(
54 parameters_.default_restart_algorithms(),
',', absl::SkipEmpty());
55 for (
const std::string& string_value : string_values) {
56 SatParameters::RestartAlgorithm tmp;
57#if defined(__PORTABLE_PLATFORM__)
58 if (string_value ==
"NO_RESTART") {
59 tmp = SatParameters::NO_RESTART;
60 }
else if (string_value ==
"LUBY_RESTART") {
61 tmp = SatParameters::LUBY_RESTART;
62 }
else if (string_value ==
"DL_MOVING_AVERAGE_RESTART") {
63 tmp = SatParameters::DL_MOVING_AVERAGE_RESTART;
64 }
else if (string_value ==
"LBD_MOVING_AVERAGE_RESTART") {
65 tmp = SatParameters::LBD_MOVING_AVERAGE_RESTART;
66 }
else if (string_value ==
"FIXED_RESTART") {
67 tmp = SatParameters::FIXED_RESTART;
69 LOG(WARNING) <<
"Couldn't parse the RestartAlgorithm name: '"
70 << string_value <<
"'.";
74 if (!SatParameters::RestartAlgorithm_Parse(string_value, &tmp)) {
75 LOG(WARNING) <<
"Couldn't parse the RestartAlgorithm name: '"
76 << string_value <<
"'.";
80 strategies_.push_back(tmp);
83 if (strategies_.empty()) {
84 strategies_.push_back(SatParameters::NO_RESTART);
89 bool should_restart =
false;
90 switch (strategies_[strategy_counter_ % strategies_.size()]) {
91 case SatParameters::NO_RESTART:
93 case SatParameters::LUBY_RESTART:
94 if (conflicts_until_next_restart_ == 0) {
96 should_restart =
true;
99 case SatParameters::DL_MOVING_AVERAGE_RESTART:
102 parameters_.restart_dl_average_ratio() *
104 should_restart =
true;
107 case SatParameters::LBD_MOVING_AVERAGE_RESTART:
110 parameters_.restart_lbd_average_ratio() *
112 should_restart =
true;
115 case SatParameters::FIXED_RESTART:
116 if (conflicts_until_next_restart_ == 0) {
117 should_restart =
true;
121 if (should_restart) {
125 if (conflicts_until_next_strategy_change_ == 0) {
127 strategy_change_conflicts_ +=
128 static_cast<int>(parameters_.strategy_change_increase_ratio() *
129 strategy_change_conflicts_);
130 conflicts_until_next_strategy_change_ = strategy_change_conflicts_;
135 strategies_[strategy_counter_ % strategies_.size()] ==
136 SatParameters::LUBY_RESTART);
142 conflicts_until_next_restart_ = parameters_.restart_period();
143 if (strategies_[strategy_counter_ % strategies_.size()] ==
144 SatParameters::LUBY_RESTART) {
145 conflicts_until_next_restart_ *=
SUniv(luby_count_ + 1);
148 return should_restart;
152 int conflict_decision_level,
int conflict_lbd) {
154 if (conflicts_until_next_restart_ > 0) {
155 --conflicts_until_next_restart_;
157 if (conflicts_until_next_strategy_change_ > 0) {
158 --conflicts_until_next_strategy_change_;
161 trail_size_running_average_.
Add(conflict_trail_index);
162 dl_running_average_.
Add(conflict_decision_level);
163 lbd_running_average_.
Add(conflict_lbd);
167 if (parameters_.use_blocking_restart()) {
171 conflict_trail_index >
172 parameters_.blocking_restart_multiplier() *