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); }
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); }