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(); FrankensteinParticleCreationParameters creationParams = new FrankensteinParticleCreationParameters(); creationParams.Speeds = newSpeedsList; creationParams.Solution = newParticleSolution; creationParams.InertiaMax = this.InertiaMax; creationParams.InertiaMin = this.InertiaMin; creationParams.InertiaMaxTime = this.InertiaMaxTime; creationParams.FinalTopologyUpdate = this.FinalTopologyUpdate; creationParams.Particles = this.Particles; int[] connectedIds = new int[parameters.NumberOfParameters]; for (int i = 0; i < parameters.NumberOfParticles; i++) { connectedIds[i] = i; } creationParams.ConnectedIds = new LinkedList <int>(connectedIds); creationParams.RandomGenerator = this.RandomGenerator; particles.Add(new FrankensteinParticle(creationParams)); } return(particles); }
protected virtual void FillSwarmParameters(SwarmCreationParameters parameters) { parameters.VerifyValues(); this.FitnessThreshold = parameters.FitnessThreshold; this.MaxIterations = parameters.MaxIterations; this.RandomGenerator = parameters.RandomNumberGenerator; this.FitnessThreshold = parameters.FitnessThreshold; this.GlobalBestBias = parameters.GlobalBestBias; this.PersonalBestBias = parameters.PersonalBestBias; }
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); }
protected abstract List <IParticle> CreateParticles(SwarmCreationParameters parameters);
public ClassicSwarm(SwarmCreationParameters parameters) { this.FillSwarmParameters(parameters); this.Particles = this.CreateParticles(parameters); this.SplitParticlesInSets(parameters.NumberOfParticleSets); }