Exemplo n.º 1
0
        private static void RunFireworks2010()
        {
            // 1. Define a problem to solve
            Problem problem = Sphere.Create();

            // 2. Setup algorithm stop condition
            CounterStopCondition stopCondition = new CounterStopCondition(10000);

            problem.QualityCalculated += stopCondition.IncrementCounter;

            // 3. Initialize algorithm run settings
            FireworksAlgorithmSettings settings = new FireworksAlgorithmSettings
            {
                LocationsNumber = 5,
                ExplosionSparksNumberModifier    = 50.0,
                ExplosionSparksNumberLowerBound  = 0.04,
                ExplosionSparksNumberUpperBound  = 0.8,
                ExplosionSparksMaximumAmplitude  = 40.0,
                SpecificSparksNumber             = 5,
                SpecificSparksPerExplosionNumber = 1
            };

            // 4. Instantiate desired implementation of the algorithm (per 2010 paper in this case)
            IFireworksAlgorithm fwa2010 = new FireworksAlgorithm(problem, stopCondition, settings);

            // 5. Finally, find a solution
            Solution solution = fwa2010.Solve();
        }
Exemplo n.º 2
0
        public void Solve_Calculation_PositiveExpected(double expectedValue, int precision)
        {
            FireworksAlgorithm fireworksAlgorithm = this.GetFireworksAlgorithm();
            double             value = fireworksAlgorithm.Solve().Quality;

            Assert.Equal(expectedValue, value, precision);

            testProblem.QualityCalculated -= ((CounterStopCondition)fireworksAlgorithm.StopCondition).IncrementCounter;
        }