Example #1
0
 public virtual void FillParameters(InertiaParticleCreationParameters parameters)
 {
     base._FillParameters(parameters);
     this.InertiaMax     = parameters.InertiaMax;
     this.InertiaMin     = parameters.InertiaMin;
     this.InertiaMaxTime = parameters.InertiaMaxTime;
 }
Example #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();
                InertiaParticleCreationParameters creationParams = new InertiaParticleCreationParameters();
                creationParams.Speeds         = newSpeedsList;
                creationParams.Solution       = newParticleSolution;
                creationParams.InertiaMax     = this.InertiaMax;
                creationParams.InertiaMin     = this.InertiaMin;
                creationParams.InertiaMaxTime = this.InertiaMaxTime;
                particles.Add(new InertiaParticle(creationParams));
            }
            return(particles);
        }
Example #3
0
        public void PrepareInertiaParticlesTests()
        {
            var mockedSolution = new Mock<ISolution>();
            mockedSolution.Name = "original";
            var copySolution = new Mock<ISolution>();
            copySolution.Name = "copy";
            mockedSolution.Setup(s => s.Fitness).Returns(1.0);
            copySolution.Setup(s => s.Fitness).Returns(2.0);
            mockedSolution.Setup(s => s.Copy()).Returns(copySolution.Object);
            mockedSolution.Setup(s => s.Parameters).Returns(new List<Double>(new Double[3] { 2.0, 3.0, 4.0 }));

            this.MockedSolution = mockedSolution;
            this.CopySolution = copySolution;
            this.Speeds = new List<Double>(new Double[3] { 1.0, 1.0, 1.0 });

            InertiaParticleCreationParameters creationParams = new InertiaParticleCreationParameters();
            creationParams.Speeds = this.Speeds;
            creationParams.Solution = mockedSolution.Object;
            creationParams.InertiaMax = 1.0;
            creationParams.InertiaMin = 0.0;
            creationParams.InertiaMaxTime = 10;

            this.Particle = new InertiaParticle(creationParams);
        }
Example #4
0
 public InertiaParticle(InertiaParticleCreationParameters parameters)
 {
     this.Id = Particle.CurrentId;
     this.CurrentIteration = 0;
     this.FillParameters(parameters);
 }