14 #ifndef OR_TOOLS_SAT_UTIL_H_
15 #define OR_TOOLS_SAT_UTIL_H_
19 #include "absl/random/bit_gen_ref.h"
20 #include "absl/random/random.h"
26 #if !defined(__PORTABLE_PLATFORM__)
27 #include "google/protobuf/descriptor.h"
46 :
absl::BitGenRef(deterministic_random_) {
47 const auto& params = *
model->GetOrCreate<SatParameters>();
48 deterministic_random_.seed(params.random_seed());
49 if (params.use_absl_random()) {
50 absl_random_ = absl::BitGen(absl::SeedSeq({params.random_seed()}));
51 absl::BitGenRef::operator=(absl::BitGenRef(absl_random_));
67 absl::BitGen absl_random_;
71 template <
typename URBG>
95 int relevant_prefix_size,
96 std::vector<Literal>* literals);
102 template <
typename URBG>
105 #if !defined(__PORTABLE_PLATFORM__)
107 const google::protobuf::EnumDescriptor* order_d =
108 SatParameters::VariableOrder_descriptor();
110 static_cast<SatParameters::VariableOrder
>(
111 order_d->value(absl::Uniform(*random, 0, order_d->value_count()))
115 const google::protobuf::EnumDescriptor* polarity_d =
116 SatParameters::Polarity_descriptor();
117 parameters->set_initial_polarity(
static_cast<SatParameters::Polarity
>(
118 polarity_d->value(absl::Uniform(*random, 0, polarity_d->value_count()))
122 parameters->set_use_phase_saving(absl::Bernoulli(*random, 0.5));
123 parameters->set_random_polarity_ratio(absl::Bernoulli(*random, 0.5) ? 0.01
125 parameters->set_random_branches_ratio(absl::Bernoulli(*random, 0.5) ? 0.01
134 : average_(initial_average) {}
138 void Reset(
double reset_value);
143 void AddData(
double new_record);
146 double average_ = 0.0;
147 int64 num_records_ = 0;
157 : decaying_factor_(decaying_factor) {
168 void AddData(
double new_record);
171 double average_ = 0.0;
172 int64 num_records_ = 0;
173 const double decaying_factor_;
186 explicit Percentile(
int record_limit) : record_limit_(record_limit) {}
197 std::deque<double> records_;
198 const int record_limit_;
209 std::vector<std::vector<int64>>* tuples);
#define DCHECK_LE(val1, val2)
#define DCHECK_GE(val1, val2)
void AddData(double new_record)
ExponentialMovingAverage(double decaying_factor)
double CurrentAverage() const
void AddData(double new_record)
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)
Percentile(int record_limit)
void AddRecord(double record)
int MoveOneUnprocessedLiteralLast(const std::set< LiteralIndex > &processed, int relevant_prefix_size, std::vector< Literal > *literals)
void RandomizeDecisionHeuristic(URBG *random, SatParameters *parameters)
void CompressTuples(absl::Span< const int64 > domain_sizes, int64 any_value, std::vector< std::vector< int64 >> *tuples)
The vehicle routing library lets one model and solve generic vehicle routing problems ranging from th...
std::mt19937 random_engine_t