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;
109 void InitializeVariableOrdering();
112 void RescaleVariableActivities(
double scaling_factor);
116 void ResetInitialPolarity(
int from,
bool inverted =
false);
120 void RephaseIfNeeded();
121 void UseLongestAssignmentAsInitialPolarity();
122 void FlipCurrentPolarity();
123 void RandomizeCurrentPolarity();
127 void PqInsertOrUpdate(BooleanVariable
var);
130 const SatParameters& parameters_;
140 struct WeightedVarQueueElement {
142 int Index()
const {
return var.value(); }
159 bool operator<(
const WeightedVarQueueElement& other)
const {
160 return weight < other.weight ||
161 (
weight == other.weight && (tie_breaker < other.tie_breaker));
172 static_assert(
sizeof(WeightedVarQueueElement) == 16,
173 "ERROR_WeightedVarQueueElement_is_not_well_compacted");
175 bool var_ordering_is_initialized_ =
false;
176 IntegerPriorityQueue<WeightedVarQueueElement> var_ordering_;
185 struct NumConflictsStackEntry {
189 int64_t num_conflicts_ = 0;
190 std::vector<NumConflictsStackEntry> num_conflicts_stack_;
198 BitQueue64 pq_need_update_for_var_at_trail_index_;
201 double variable_activity_increment_ = 1.0;
214 bool in_stable_phase_ =
false;
215 int target_length_ = 0;
223 bool maybe_enable_phase_saving_ =
true;
224 int64_t polarity_phase_ = 0;
225 int64_t num_conflicts_until_rephase_ = 1000;
228 std::vector<Literal> best_partial_assignment_;
234 std::vector<BooleanVariable> tmp_variables_;
Class that owns everything related to a particular optimization model.
std::vector< std::pair< Literal, double > > AllPreferences() 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.