예제 #1
0
        public static Velocity Initialize(Position pos, SwarmSize swarmSize)
        {
            int d;

            var vel = new Velocity(Constants.DMax) {Size = pos.size};

            // Half-diff  0.5*(alea-x)

            for (d = 0; d < vel.Size; d++)
            {
                vel.V[d] = (Alea.NextDouble(swarmSize.min[d], swarmSize.max[d]) - pos.x[d]) / 2;
            }

            return vel;
        }
예제 #2
0
        public static Position Quantis(Position x, SwarmSize swarmSize)
        {
            /*
             Quantisatition of a position
             Only values like x+k*q (k integer) are admissible
             */
            Position quantx = x.Clone();

            for (int d = 0; d < x.size; d++)
            {
                if (swarmSize.q.Q[d] > Constants.Zero)	// Note that qd can't be < 0
                {
                    quantx.x[d] = swarmSize.q.Q[d] * Math.Floor(0.5 + x.x[d] / swarmSize.q.Q[d]);
                }
            }
            return quantx;
        }
예제 #3
0
        /// <summary>
        ///  Initialise a position
        /// Note: possible constraints are not checked here. 
        /// The position may be unfeasible	
        /// </summary>
        public static Position Initialize(SwarmSize swarmSize)
        {
            int d;
            var pos = new Position(Constants.DMax) {size = swarmSize.D};

            //  Random uniform
            for (d = 0; d < pos.size; d++)
            {
                pos.x[d] = Alea.NextDouble(swarmSize.min[d], swarmSize.max[d]);
            }
            if (swarmSize.valueNb > 0) // If only some values are acceptable
                pos = ValueAccept(pos, swarmSize.valueNb);

            return pos;
        }