Exemple #1
0
        public override double[] RunExperiment()
        {
            AntColonyOptimiser aco = new AntColonyOptimiser(Problem)
            {
                EvaporationRate       = EvaporationRate,
                ProbBest              = ProbBest,
                PheromoneWeight       = PheromoneWeight,
                FitnessWeight         = FitnessWeight,
                GlobalBestDepositFreq = GlobalBestDepositFreq
            };

            switch (Algorithm)
            {
            case AllPerformanceTest.TestAlgorithm.Sequential:
                aco.PheromoneWeight       = 1;
                aco.FitnessWeight         = 3;
                aco.GlobalBestDepositFreq = 16;
                aco.EvaporationRate       = 0.5;
                aco.ProbBest = 0.1;
                AntCount     = 5;
                break;

            case AllPerformanceTest.TestAlgorithm.Replicated4:
                aco.PheromoneWeight       = 1;
                aco.FitnessWeight         = 3;
                aco.GlobalBestDepositFreq = 12;
                aco.EvaporationRate       = 0.6;
                aco.ProbBest = 0.06;
                AntCount     = 5;
                break;

            case AllPerformanceTest.TestAlgorithm.Synchronous4:
                aco.PheromoneWeight       = 1;
                aco.FitnessWeight         = 3;
                aco.GlobalBestDepositFreq = 14;
                aco.EvaporationRate       = 0.7;
                aco.ProbBest = 0.08;
                AntCount     = 5;
                break;

            case AllPerformanceTest.TestAlgorithm.Cooperative4:
                aco.PheromoneWeight       = 1;
                aco.FitnessWeight         = 3;
                aco.GlobalBestDepositFreq = 14;
                aco.EvaporationRate       = 0.3;
                aco.ProbBest = 0.08;
                AntCount     = 5;
                break;
            }

#pragma warning disable 8509
            return(Algorithm switch
#pragma warning restore 8509
            {
                AllPerformanceTest.TestAlgorithm.Sequential =>
                aco.SequentialSearch(5, Utils.ProblemTimeDictionary[Problem], 1).Solutions
                .Select(s => (double)s.Fitness)
                .ToArray(),
                AllPerformanceTest.TestAlgorithm.Replicated4 =>
                aco.ReplicatedSearch(5, Utils.ProblemTimeDictionary[Problem], 4, 1).Solutions
                .Select(s => (double)s.Fitness)
                .ToArray(),
                AllPerformanceTest.TestAlgorithm.Synchronous4 =>
                aco.SynchronousSearch(5, Utils.ProblemTimeDictionary[Problem], 4, 1).Solutions
                .Select(s => (double)s.Fitness)
                .ToArray(),
                AllPerformanceTest.TestAlgorithm.Cooperative4 =>
                aco.CooperativeSearch(5, Utils.ProblemTimeDictionary[Problem], 10, 4, 1).Solutions
                .Select(s => (double)s.Fitness).ToArray()
            });