示例#1
0
        public static IParticle Create(PsoParticleType type,
            int locationDim,
            int fitnessDim,
            IFitnessFunction<double[], double[]> function,
            double restartEpsilon = double.MaxValue,
            int iterationsToRestart = int.MaxValue,
            DimensionBound[] bounds = null,
            double[] initVelocity = null
            )
        {
            IParticle particle = null;
            var rand = RandomGenerator.GetInstance();
            switch (type)
            {
                case PsoParticleType.Standard:
                case PsoParticleType.FullyInformed:
                    particle = new StandardParticle(restartEpsilon, iterationsToRestart);
                    break;
                case PsoParticleType.ChargedParticle:
                    particle = new ChargedParticle();
                    break;
                case PsoParticleType.DummyParticle:
                    particle = new DummyParticle();
                    break;
            }

            var x = bounds != null ? rand.RandomVector(locationDim, bounds) : rand.RandomVector(locationDim);
            particle.Init(new ParticleState(x, function.Evaluate(x)),
                initVelocity ?? rand.RandomVector(locationDim, MinInitialVelocity, MaxInitialVelocity), bounds);
            return particle;
        }
示例#2
0
        public static IParticle Create(PsoParticleType type,
                                       int locationDim,
                                       int fitnessDim,
                                       IFitnessFunction <double[], double[]> function,
                                       double restartEpsilon   = double.MaxValue,
                                       int iterationsToRestart = int.MaxValue,
                                       DimensionBound[] bounds = null,
                                       double[] initVelocity   = null
                                       )
        {
            IParticle particle = null;
            var       rand     = RandomGenerator.GetInstance();

            switch (type)
            {
            case PsoParticleType.Standard:
            case PsoParticleType.FullyInformed:
                particle = new StandardParticle(restartEpsilon, iterationsToRestart);
                break;

            case PsoParticleType.ChargedParticle:
                particle = new ChargedParticle();
                break;

            case PsoParticleType.DummyParticle:
                particle = new DummyParticle();
                break;
            }

            var x = bounds != null?rand.RandomVector(locationDim, bounds) : rand.RandomVector(locationDim);

            particle.Init(new ParticleState(x, function.Evaluate(x)),
                          initVelocity ?? rand.RandomVector(locationDim, MinInitialVelocity, MaxInitialVelocity), bounds);
            return(particle);
        }
示例#3
0
 public ParticlesCount(PsoParticleType psoParticleType, int p)
 {
     // TODO: Complete member initialization
     ParticleType = psoParticleType;
     Count        = p;
 }
示例#4
0
 public ParticlesCount()
 {
     Count        = 0;
     ParticleType = PsoParticleType.Standard;
 }
示例#5
0
 public ParticlesCount()
 {
     Count = 0;
     ParticleType = PsoParticleType.Standard;
 }
示例#6
0
 public ParticlesCount(PsoParticleType psoParticleType, int p)
 {
     // TODO: Complete member initialization
     ParticleType = psoParticleType;
     Count = p;
 }