protected void fillInitialPopulation(List <Candidate> population, Problem p)
{
// use initial values provided by the user
population.First().values = p.currentValue().Clone();
population.First().cost = p.costFunction().value(population.First().values);
if (Double.IsNaN(population.First().cost))
{
population.First().cost = Double.MaxValue;
}
// rest of the initial population is random
for (int j = 1; j < population.Count; ++j)
{
for (int i = 0; i < p.currentValue().size(); ++i)
{
double l = lowerBound_[i], u = upperBound_[i];
population[j].values[i] = l + (u - l) * rng_.nextReal();
}
population[j].cost = p.costFunction().value(population[j].values);
if (Double.IsNaN(population[j].cost))
{
population[j].cost = Double.MaxValue;
}
}
}