Example #1
0
        protected override IEvaluation <bool>[] GenerateProblems()
        {
            int[] max3Satblocks           = { 5, 10, 20, 30, 40, 50 };
            int[] isgGenes                = { 25, 49, 100, 484 };
            int[] nkLandscapeGenes        = { 10, 50, 100 };
            int[] standardDeceptiveBlocks = { 10, 50, 100 };

            int nProblems = max3Satblocks.Length +          //Max3Sat problem
                            isgGenes.Length +               //Ising Sping Glass
                            nkLandscapeGenes.Length +       //NK fitness landscapes
                            standardDeceptiveBlocks.Length; //Standard Deceptive problem with length 3

            int iterator = 0;

            IEvaluation <bool>[] problems = new IEvaluation <bool> [nProblems];

            //Max3Sat problem
            foreach (var genes in max3Satblocks)
            {
                problems[iterator] = new CBinaryMax3SatEvaluation(genes);
                iterator++;
            }

            //Ising Sping Glass
            foreach (var genes in isgGenes)
            {
                problems[iterator] = new CBinaryIsingSpinGlassEvaluation(genes);
                iterator++;
            }

            //NK fitness landscapes
            foreach (var genes in nkLandscapeGenes)
            {
                problems[iterator] = new CBinaryNKLandscapesEvaluation(genes);
                iterator++;
            }

            //Standard Deceptive problem with length 3
            foreach (var functions in standardDeceptiveBlocks)
            {
                problems[iterator] = new CBinaryStandardDeceptiveConcatenationEvaluation(3, functions);
                iterator++;
            }

            return(problems);
        }
Example #2
0
        private static Experiment <bool> PrepareExperiment6(int evaluationType, int algorithm, int selectionMethod, int crossoverMethod, double crossoverProb, double mutationProb, int populationSize, int?seed = null)
        {
            IEvaluation <bool>          evaluation;
            Dictionary <string, string> info = new Dictionary <string, string>();

            switch (evaluationType)
            {
            case 0:
                evaluation        = new CBinaryMax3SatEvaluation(100);
                info["problem"]   = "Max3Sat";
                info["variables"] = "100";
                break;

            case 1:
                evaluation        = new CBinaryIsingSpinGlassEvaluation(100);
                info["problem"]   = "ISG";
                info["variables"] = "100";
                break;

            case 2:
                evaluation        = new CBinaryNKLandscapesEvaluation(100);
                info["problem"]   = "NKLandscapes";
                info["variables"] = "100";
                break;

            case 3:
                evaluation        = new CBinaryStandardDeceptiveConcatenationEvaluation(3, 10);
                info["problem"]   = "Deceptive";
                info["variables"] = "10";
                break;

            case 4:
                evaluation        = new CBinaryStandardDeceptiveConcatenationEvaluation(3, 50);
                info["problem"]   = "Deceptive";
                info["variables"] = "50";
                break;

            case 5:
                evaluation        = new CBinaryStandardDeceptiveConcatenationEvaluation(3, 100);
                info["problem"]   = "Deceptive";
                info["variables"] = "100";
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            RunningTimeStopCondition stopCondition = new RunningTimeStopCondition(evaluation.dMaxValue, 30);
            BinaryRandomGenerator    generator     = new BinaryRandomGenerator(evaluation.pcConstraint, seed);
            ASelection selection;

            switch (selectionMethod)
            {
            case 0:
                selection = new RouletteWheelSelection(seed);
                info["selection_method"] = "roulette";
                break;

            case 1:
                selection = new TournamentSelection(2, seed);
                info["selection_method"] = "tournament";
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            ACrossover crossover;

            info["crossover_prob"] = crossoverProb.ToString();
            switch (crossoverMethod)
            {
            case 0:
                crossover = new OnePointCrossover(crossoverProb, seed);
                info["crossover_method"] = "OnePoint";
                break;

            case 1:
                crossover = new UniformCrossover(crossoverProb, seed);
                info["crossover_method"] = "uniform";
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            mutationProb          = mutationProb / evaluation.iSize;
            info["mutation_prob"] = mutationProb.ToString();
            BinaryBitFlipMutation mutation = new BinaryBitFlipMutation(mutationProb, evaluation, seed);

            info["population"] = populationSize.ToString();
            GeneticAlgorithm <bool> ga;

            switch (algorithm)
            {
            case 0:
                ga = new GeneticAlgorithm <bool>(evaluation, stopCondition, generator, selection, crossover, mutation, populationSize);
                info["algorithm"] = "GA";
                break;

            case 1:
                ga = new ResettingGA <bool>(evaluation, stopCondition, generator, selection, crossover, mutation, populationSize, 10, seed);
                info["algorithm"] = "resetting";
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            Experiment <bool> experiment = new Experiment <bool>(ga, info, ExperimentFinished);

            return(experiment);
        }
        protected override IEvaluation <bool>[] GenerateProblems()
        {
            int[] genes            = { 5, 10, 20, 30, 40, 50 };
            int[] standardBlocks   = { 1, 2, 4, 6, 8, 10 };
            int[] bimodalBlocks    = { 1, 2, 3, 4, 5 };
            int[] isgGenes         = { 25, 49, 100, 484 };
            int[] nkLandscapeGenes = { 10, 50, 100, 200 };
            int   nProblems        = genes.Length +           //OneMax
                                     standardBlocks.Length +  //Order-5 deceptive concatenation
                                     bimodalBlocks.Length +   //Bimodal-10 deceptive concatenation
                                     isgGenes.Length +        //Ising Sping Glass
                                     nkLandscapeGenes.Length; //NK fitness landscapes

            //int[] genes = { 5 };
            //int[] standardBlocks = { 1 };
            //int[] bimodalBlocks = { 1 };
            //int[] isgGenes = { 25 };
            //int[] nkLandscapeGenes = { 10 };
            //int nProblems = genes.Length +  //OneMax
            //    standardBlocks.Length +  //Order-5 deceptive concatenation
            //    bimodalBlocks.Length + //Bimodal-10 deceptive concatenation
            //    isgGenes.Length +   //Ising Sping Glass
            //    nkLandscapeGenes.Length;    //NK fitness landscapes

            int iterator = 0;

            IEvaluation <bool>[] problems = new IEvaluation <bool> [nProblems];

            //OneMax
            foreach (int gene in genes)
            {
                problems[iterator] = new CBinaryOneMaxEvaluation(gene);
                iterator++;
            }

            //Order-5 deceptive concatenation
            foreach (int block in standardBlocks)
            {
                problems[iterator] = new CBinaryStandardDeceptiveConcatenationEvaluation(5, block);
                iterator++;
            }

            //Bimodal-10 deceptive concatenation
            foreach (int block in bimodalBlocks)
            {
                problems[iterator] = new CBinaryBimodalDeceptiveConcatenationEvaluation(10, block);
                iterator++;
            }

            //Ising Sping Glass
            foreach (int gene in isgGenes)
            {
                problems[iterator] = new CBinaryIsingSpinGlassEvaluation(gene);
                iterator++;
            }

            //NK fitness landscapes
            foreach (int gene in nkLandscapeGenes)
            {
                problems[iterator] = new CBinaryNKLandscapesEvaluation(gene);
                iterator++;
            }

            return(problems);
        }