14 #ifndef OR_TOOLS_SAT_SAT_DECISION_H_
15 #define OR_TOOLS_SAT_SAT_DECISION_H_
26 #include "ortools/sat/sat_parameters.pb.h"
72 void Untrail(
int target_trail_index);
88 maybe_enable_phase_saving_ = save_phase;
115 void InitializeVariableOrdering();
118 void RescaleVariableActivities(
double scaling_factor);
122 void ResetInitialPolarity(
int from,
bool inverted =
false);
126 void RephaseIfNeeded();
127 void UseLongestAssignmentAsInitialPolarity();
128 void FlipCurrentPolarity();
129 void RandomizeCurrentPolarity();
133 void PqInsertOrUpdate(BooleanVariable
var);
136 const SatParameters& parameters_;
146 struct WeightedVarQueueElement {
148 int Index()
const {
return var.value(); }
165 bool operator<(
const WeightedVarQueueElement& other)
const {
166 return weight < other.weight ||
167 (
weight == other.weight && (tie_breaker < other.tie_breaker));
178 static_assert(
sizeof(WeightedVarQueueElement) == 16,
179 "ERROR_WeightedVarQueueElement_is_not_well_compacted");
181 bool var_ordering_is_initialized_ =
false;
182 IntegerPriorityQueue<WeightedVarQueueElement> var_ordering_;
191 struct NumConflictsStackEntry {
195 int64_t num_conflicts_ = 0;
196 std::vector<NumConflictsStackEntry> num_conflicts_stack_;
204 BitQueue64 pq_need_update_for_var_at_trail_index_;
207 double variable_activity_increment_ = 1.0;
220 bool in_stable_phase_ =
false;
221 int target_length_ = 0;
229 bool maybe_enable_phase_saving_ =
true;
230 int64_t polarity_phase_ = 0;
231 int64_t num_conflicts_until_rephase_ = 1000;
234 std::vector<Literal> best_partial_assignment_;
240 std::vector<BooleanVariable> tmp_variables_;
BooleanVariable Variable() const
Class that owns everything related to a particular optimization model.
std::vector< std::pair< Literal, double > > AllPreferences() const
double Activity(Literal l) const
void IncreaseNumVariables(int num_variables)
void ResetDecisionHeuristic()
void UpdateVariableActivityIncrement()
void SetStablePhase(bool is_stable)
void SetAssignmentPreference(Literal literal, double weight)
void MaybeEnablePhaseSaving(bool save_phase)
void Untrail(int target_trail_index)
void BumpVariableActivities(const std::vector< Literal > &literals)
void BeforeConflict(int trail_index)
void UpdateWeightedSign(const std::vector< LiteralWithCoeff > &terms, Coefficient rhs)
SatDecisionPolicy(Model *model)
bool InStablePhase() const
std::tuple< int64_t, int64_t, const double > Coefficient
Collection of objects used to extend the Constraint Solver library.