Ejemplo n.º 1
0
        public void Reset()
        {
            if (_params.PopulationSize == -1)
            {
                _params.PopulationSize = (int)(4.0 + Math.Floor(3.0 * Math.Log(_numParams)));
            }
            if (_params.NumParents == -1)
            {
                _params.NumParents = _params.PopulationSize / 2;
            }
            _mutationPower = _params.MutationPower;

            _weights = MathNet.Numerics.LinearAlgebra.
                       Vector <double> .Build.Dense(_params.NumParents);

            for (int i = 0; i < _params.NumParents; i++)
            {
                _weights[i] = Math.Log(_params.NumParents + 0.5) - Math.Log(i + 1);
            }
            _weights /= _weights.Sum();
            double sum_weights = _weights.Sum();
            double sum_squares = _weights.Sum(x => x * x);

            _mueff = sum_weights * sum_weights / sum_squares;

            _mean = LA.Vector <double> .Build.Dense(_numParams);

            if (_bestIndividual != null)
            {
                for (int i = 0; i < _numParams; i++)
                {
                    _mean[i] = _bestIndividual.ParamVector[i];
                }
            }
            Console.WriteLine("RESET");
            Console.WriteLine(_mean);

            _cc  = (4 + _mueff / _numParams) / (_numParams + 4 + 2 * _mueff / _numParams);
            _cs  = (_mueff + 2) / (_numParams + _mueff + 5);
            _c1  = 2 / (Math.Pow(_numParams + 1.3, 2) + _mueff);
            _cmu = Math.Min(1 - _c1,
                            2 * (_mueff - 2 + 1 / _mueff) / (Math.Pow(_numParams + 2, 2) + _mueff));
            _damps = 1 + 2 * Math.Max(0, Math.Sqrt((_mueff - 1) / (_numParams + 1)) - 1) + _cs;
            _chiN  = Math.Sqrt(_numParams) *
                     (1.0 - 1.0 / (4.0 * _numParams) + 1.0 / (21.0 * Math.Pow(_numParams, 2)));

            _pc = LA.Vector <double> .Build.Dense(_numParams);

            _ps = LA.Vector <double> .Build.Dense(_numParams);

            _C = new DecompMatrix(_numParams);

            _individualsEvaluated = 0;
        }
        public static MathNet.Numerics.LinearAlgebra.Vector <Complex> GenerateTransmissionVector(int size, bool align_to_x)
        {
            MathNet.Numerics.LinearAlgebra.Vector <Complex> t_vector = GenerateTransmissionVector(size);
            Complex align_multiplier = t_vector.Sum().Conjugate();

            align_multiplier /= align_multiplier.Magnitude;
            return(t_vector * align_multiplier);
        }