10 Random(LocalRandom), ProbabilityFunction(myPF)
21 void SimpleSelect::DoInit()
24 const size_t popsize = probabilities.size();
25 size_t currentindex = 0;
27 std::vector<double> fraction(popsize, 0);
28 indices.assign(popsize, 0);
31 for (
size_t i = 0; i < popsize; ++i)
35 const double expected = probabilities(i) * popsize;
38 int assign = int(floor(expected));
42 fraction.at(i) = expected - assign;
48 indices.at(currentindex) = i;
55 size_t fractionindex = 0;
57 while (currentindex < popsize)
61 if (Random.
GetNumber() <= fraction.at(fractionindex))
63 indices.at(currentindex) = fractionindex;
65 fraction.at(fractionindex) -= 1.0;
69 if (fractionindex >= popsize)
70 fractionindex -= popsize;
74 size_t SimpleSelect::DoGetOne()
77 int result = indices.at(pick);
80 indices.at(pick) = indices.at(remain);
boost::function< const tprobabilityv &()> tProbabilityFunction
ublas::vector< double > tprobabilityv
virtual float GetNumber()=0
The base class for all random number generators, defines the basic interface.