15 #ifndef CORE_RANDOMIZED_RM_H_
16 #define CORE_RANDOMIZED_RM_H_
21 #include <parallel/algorithm>
32 template <
typename TBaseRm>
50 template <
typename TBaseRm>
52 : auto_randomize_(auto_randomize){};
55 template <
typename TBaseRm>
64 return std::numeric_limits<result_type>::max();
67 return random->
Integer(std::numeric_limits<result_type>::max());
71 template <
typename TBaseRm>
74 #pragma omp parallel for schedule(static, 1)
75 for (uint64_t n = 0; n < this->agents_.size(); ++n) {
77 __gnu_parallel::random_shuffle(this->agents_[n].begin(),
78 this->agents_[n].end());
81 std::shuffle(this->agents_[n].begin(), this->agents_[n].end(),
88 this->uid_ah_map_.Insert(a->
GetUid(), ah);
90 TBaseRm::ForEachAgentParallel(update_agent_map);
94 template <
typename TBaseRm>
96 TBaseRm::EndOfIteration();
97 if (auto_randomize_) {
98 RandomizeAgentsOrder();
Contains code required by all agents.
const AgentUid & GetUid() const
unsigned Integer(int max)
RandomizedRm(TRootIOCtor *r)
void RandomizeAgentsOrder()
void EndOfIteration() override
BDM_CLASS_DEF_NV(RandomizedRm, 1)
Random * GetRandom()
Returns a thread local random number generator.
static Simulation * GetActive()
This function returns the currently active Simulation simulation.
LambdaFunctor< decltype(&TLambda::operator())> L2F(const TLambda &l)
static constexpr result_type min()
static constexpr result_type max()