Ejemplo n.º 1
0
        public override ISolution Copy()
        {
            Double[] copyParametersList = new Double[this.Parameters.Count];
            this.Parameters.CopyTo(copyParametersList);
            ISolution copy = new ClassicSolution(this.RunSolution, this.AuxData, this.MinimumParameterThreshold, this.MaximumParameterThreshold);

            copy.Parameters = copyParametersList.ToList();
            copy.Fitness    = this.Fitness;
            return(copy);
        }
Ejemplo n.º 2
0
        protected override List <IParticle> CreateParticles(SwarmCreationParameters parameters)
        {
            List <IParticle> particles = new List <IParticle>();

            for (UInt32 index = 0; index < parameters.NumberOfParameters; index++)
            {
                List <Double> newParameterList = new List <double>();
                List <Double> newSpeedsList    = new List <double>();
                this.CreateRandomsList(parameters.MaximumParameterValue, parameters.MinimumParameterValue, parameters.NumberOfParameters, ref newSpeedsList, ref newParameterList);
                ISolution newParticleSolution = new ClassicSolution(parameters.SolutionFunction, parameters.AuxData, parameters.MinimumParameterValue, parameters.MaximumParameterValue);
                newParticleSolution.Parameters = newParameterList;
                newParticleSolution.UpdateFitness();
                ClassicParticleCreationParameters creationParams = new ClassicParticleCreationParameters();
                creationParams.Speeds   = newSpeedsList;
                creationParams.Solution = newParticleSolution;
                particles.Add(new ClassicParticle(creationParams));
            }
            return(particles);
        }