14 #ifndef OR_TOOLS_SAT_UTIL_H_
15 #define OR_TOOLS_SAT_UTIL_H_
20 #include "absl/random/bit_gen_ref.h"
21 #include "absl/random/random.h"
27 #if !defined(__PORTABLE_PLATFORM__)
28 #include "google/protobuf/descriptor.h"
47 :
absl::BitGenRef(deterministic_random_) {
48 const auto& params = *
model->GetOrCreate<SatParameters>();
49 deterministic_random_.seed(params.random_seed());
50 if (params.use_absl_random()) {
51 absl_random_ = absl::BitGen(absl::SeedSeq({params.random_seed()}));
52 absl::BitGenRef::operator=(absl::BitGenRef(absl_random_));
65 absl::BitGen absl_random_;
69 template <
typename URBG>
93 int relevant_prefix_size,
94 std::vector<Literal>* literals);
100 template <
typename URBG>
103 #if !defined(__PORTABLE_PLATFORM__)
105 const google::protobuf::EnumDescriptor* order_d =
106 SatParameters::VariableOrder_descriptor();
108 static_cast<SatParameters::VariableOrder
>(
109 order_d->value(absl::Uniform(*random, 0, order_d->value_count()))
113 const google::protobuf::EnumDescriptor* polarity_d =
114 SatParameters::Polarity_descriptor();
115 parameters->set_initial_polarity(
static_cast<SatParameters::Polarity
>(
116 polarity_d->value(absl::Uniform(*random, 0, polarity_d->value_count()))
120 parameters->set_use_phase_saving(absl::Bernoulli(*random, 0.5));
121 parameters->set_random_polarity_ratio(absl::Bernoulli(*random, 0.5) ? 0.01
123 parameters->set_random_branches_ratio(absl::Bernoulli(*random, 0.5) ? 0.01
132 : average_(initial_average) {}
136 void Reset(
double reset_value);
141 void AddData(
double new_record);
144 double average_ = 0.0;
145 int64_t num_records_ = 0;
155 : decaying_factor_(decaying_factor) {
166 void AddData(
double new_record);
169 double average_ = 0.0;
170 int64_t num_records_ = 0;
171 const double decaying_factor_;
184 explicit Percentile(
int record_limit) : record_limit_(record_limit) {}
195 std::deque<double> records_;
196 const int record_limit_;
206 void CompressTuples(absl::Span<const int64_t> domain_sizes, int64_t any_value,
207 std::vector<std::vector<int64_t>>* tuples);
#define DCHECK_LE(val1, val2)
#define DCHECK_GE(val1, val2)
void AddData(double new_record)
int64_t NumRecords() const
ExponentialMovingAverage(double decaying_factor)
double CurrentAverage() const
void AddData(double new_record)
int64_t NumRecords() const
IncrementalAverage(double initial_average)
double CurrentAverage() const
void Reset(double reset_value)
Class that owns everything related to a particular optimization model.
ModelRandomGenerator(Model *model)
double GetPercentile(double percent)
int64_t NumRecords() const
Percentile(int record_limit)
void AddRecord(double record)
int MoveOneUnprocessedLiteralLast(const std::set< LiteralIndex > &processed, int relevant_prefix_size, std::vector< Literal > *literals)
void CompressTuples(absl::Span< const int64_t > domain_sizes, int64_t any_value, std::vector< std::vector< int64_t >> *tuples)
void RandomizeDecisionHeuristic(URBG *random, SatParameters *parameters)
Collection of objects used to extend the Constraint Solver library.
std::mt19937 random_engine_t