public BestOfSampling(ICandidateFactory <TSysConfig> innerSamplingFactory, int poolSize, int bestPoints,
                              IObjectiveEvaluator <TSysConfig> evaluator, IFitnessAssignment <double> fitAssignment = null)
        {
            if (fitAssignment == null)
            {
                fitAssignment = new DefaultFitnessAssignment();
            }
            if (poolSize < bestPoints)
            {
                throw new ArgumentOutOfRangeException("poolSize", poolSize, String.Format("poolSize must be >= bestPoints({0})", bestPoints));
            }
            this.HcFactory            = (IHyperCubeOperationsFactory)innerSamplingFactory;
            this.innerSamplingFactory = innerSamplingFactory;
            var tmp = new IObjectiveScores[poolSize];

            for (int i = 0; i < poolSize; i++)
            {
                tmp[i] = evaluator.EvaluateScore(innerSamplingFactory.CreateRandomCandidate());
            }
            var points = fitAssignment.AssignFitness(tmp);

            Array.Sort(points);
            candidates = new FitnessAssignedScores <double> [bestPoints];
            for (int i = 0; i < bestPoints; i++)
            {
                candidates[i] = points[i];
            }
        }
Beispiel #2
0
 private T[] initialisePopulation()
 {
     T[] result = new T[numShuffle];
     for (int i = 0; i < result.Length; i++)
     {
         result[i] = populationInitializer.CreateRandomCandidate();
     }
     return(result);
 }
 public TSysConfig CreateRandomCandidate()
 {
     if (this.seeds != null && (counterSeeds < this.seeds.Length))
     {
         counterSeeds++;
         return(this.seeds[counterSeeds - 1]);
     }
     else
     {
         return(uniformRandomSamplingFactory.CreateRandomCandidate());
     }
 }