Пример #1
0
        /** Updates the CMA-ES distribution given the current population, then
         *  replaces the population with new samples generated from the distribution.
         *  Returns the revised population. */

        public override Population BreedPopulation(IEvolutionState state)
        {
            Population pop = state.Population;

            for (int i = 0; i < pop.Subpops.Count; i++)
            {
                Subpopulation subpop = pop.Subpops[i];
                if (!(subpop.Species is CMAESSpecies)) // uh oh
                {
                    state.Output.Fatal("To use CMAESBreeder, subpopulation " + i +
                                       " must contain a CMAESSpecies.  But it contains a " + subpop.Species);
                }

                CMAESSpecies species = (CMAESSpecies)subpop.Species;

                // update distribution[i] for subpop
                species.UpdateDistribution(state, subpop);

                // overwrite individuals
                IList <Individual> inds = subpop.Individuals;
                for (int j = 0; j < inds.Count; j++)
                {
                    inds[j] = species.NewIndividual(state, 0);
                }
            }

            return(pop);
        }
Пример #2
0
        public override object Clone()
        {
            CMAESSpecies myobj = (CMAESSpecies)(base.Clone());

            // clone the distribution and other variables here
            myobj.c        = c.copy();
            myobj.b        = b.copy();
            myobj.d        = d.copy();
            myobj.bd       = (DMatrixRMaj)bd.copy();
            myobj.sbd      = (DMatrixRMaj)sbd.copy();
            myobj.invsqrtC = invsqrtC.copy();

            myobj.xmean = xmean.copy();
            myobj.ps    = ps.copy();
            myobj.pc    = pc.copy();

            return(myobj);
        }