コード例 #1
0
ファイル: Schwefel2_6.cs プロジェクト: krharrison/SwiftPSO-v1
        private void Initialize(int dimension)
        {
            _a       = MatrixGenerator.Random(dimension, -500, 500); //TODO: verify det(A) not 0.
            _b       = new Vector(dimension);
            _z       = new Vector(dimension);
            _optimum = BuildOptimum(dimension);

            MultiplyA(_optimum, _b);
        }
コード例 #2
0
        private void Initialize(int dimension)
        {
            //TODO: this could be simplified into only two loops!
            _a       = MatrixGenerator.Random(dimension, -100, 100);
            _b       = MatrixGenerator.Random(dimension, -100, 100);
            _aRow    = new Vector(dimension);
            _bRow    = new Vector(dimension);
            _optimum = new Vector(dimension);

            for (int i = 0; i < dimension; i++)
            {
                _optimum[i] = RandomProvider.NextDouble(_optimumBounds);
            }

            //initialize the sum for the a rows
            for (int i = 0; i < dimension; i++)
            {
                _aRow[i] = 0;
                for (int j = 0; j < dimension; j++)
                {
                    _aRow[i] += (_a[i, j] * Math.Sin(_optimum[j]) + _b[i, j] * Math.Cos(_optimum[j])); //TODO: ensure we are using i,j correctly.
                }
            }
        }