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"
23 #include "ortools/sat/sat_parameters.pb.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_));
64 absl::BitGen absl_random_;
68 template <
typename URBG>
92 int relevant_prefix_size,
93 std::vector<Literal>* literals);
99 template <
typename URBG>
102 #if !defined(__PORTABLE_PLATFORM__)
104 const google::protobuf::EnumDescriptor* order_d =
105 SatParameters::VariableOrder_descriptor();
107 static_cast<SatParameters::VariableOrder
>(
108 order_d->value(absl::Uniform(*random, 0, order_d->value_count()))
112 const google::protobuf::EnumDescriptor* polarity_d =
113 SatParameters::Polarity_descriptor();
114 parameters->set_initial_polarity(
static_cast<SatParameters::Polarity
>(
115 polarity_d->value(absl::Uniform(*random, 0, polarity_d->value_count()))
119 parameters->set_use_phase_saving(absl::Bernoulli(*random, 0.5));
120 parameters->set_random_polarity_ratio(absl::Bernoulli(*random, 0.5) ? 0.01
122 parameters->set_random_branches_ratio(absl::Bernoulli(*random, 0.5) ? 0.01
131 : average_(initial_average) {}
135 void Reset(
double reset_value);
140 void AddData(
double new_record);
143 double average_ = 0.0;
144 int64 num_records_ = 0;
154 : decaying_factor_(decaying_factor) {
165 void AddData(
double new_record);
168 double average_ = 0.0;
169 int64 num_records_ = 0;
170 const double decaying_factor_;
183 explicit Percentile(
int record_limit) : record_limit_(record_limit) {}
194 std::deque<double> records_;
195 const int record_limit_;
206 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