38 int rnd_int(
int lowerLimit,
int upperLimit );
40 float rnd_flt(
float min=0.0,
float max=1.0);
42 float rnd_dbl(
float min=0.0,
float max=1.0);
48 template <
class RandomAccessIterator>
49 void shuffle (RandomAccessIterator first, RandomAccessIterator last)
51 for (
auto i=(last-first)-1; i>0; --i)
53 std::uniform_int_distribution<
decltype(i)> d(0,i);
60 template<
typename Iter>
63 std::uniform_int_distribution<> dis(0, distance(start, end) - 1);
72 template<
typename Iter,
typename Iter2>
83 std::discrete_distribution<size_t> dis(wstart, wend);
104 &&
" attemping to return random choice from an empty map");
108 for (
const auto& [k, v]: m)
116 template<
class V,
class T>
123 &&
" attemping to return random choice from empty vector");
127 template<
template<
class,
class>
class C,
class T>
136 fmt::format(
"w size = {} and v size = {}, returning uniform random choice\n",
140 if(w.size() != v.size())
142 fmt::format(
"w ({}) != v size ({}), returning uniform random choice\n",
148 assert(v.size() == w.size());
149 std::discrete_distribution<size_t> dis(w.begin(), w.end());
163 vector<std::mt19937>
rg;
Defines a multi-core random number generator and its operators.
T random_choice(const map< T, float > &m)
T random_choice(const V &v)
void shuffle(RandomAccessIterator first, RandomAccessIterator last)
float rnd_flt(float min=0.0, float max=1.0)
vector< size_t > shuffled_index(size_t n)
returns a shuffled index vector of length n
Iter select_randomly(Iter start, Iter end, Iter2 wstart, Iter2 wend)
select randomly with weighted distribution.
void set_seed(unsigned int seed)
vector< std::mt19937 > rg
T random_choice(const C< T, std::allocator< T > > &v, const vector< float > &w)
Iter select_randomly(Iter start, Iter end)
float rnd_dbl(float min=0.0, float max=1.0)
int rnd_int(int lowerLimit, int upperLimit)
#define omp_get_thread_num()
namespace containing various utility functions
< nsga2 selection operator for getting the front
tree< Node >::pre_order_iterator Iter