public IslandOffspringSelectionGeneticAlgorithm() : base() { Parameters.Add(new ValueParameter <IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0))); Parameters.Add(new ValueParameter <BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true))); Parameters.Add(new ValueParameter <IntValue>("NumberOfIslands", "The number of islands.", new IntValue(5))); Parameters.Add(new ValueParameter <IntValue>("MigrationInterval", "The number of generations that should pass between migration phases.", new IntValue(20))); Parameters.Add(new ValueParameter <PercentValue>("MigrationRate", "The proportion of individuals that should migrate between the islands.", new PercentValue(0.15))); Parameters.Add(new ConstrainedValueParameter <IMigrator>("Migrator", "The migration strategy.")); Parameters.Add(new ConstrainedValueParameter <ISelector>("EmigrantsSelector", "Selects the individuals that will be migrated.")); Parameters.Add(new ConstrainedValueParameter <IReplacer>("ImmigrationReplacer", "Replaces part of the original population with the immigrants.")); Parameters.Add(new ValueParameter <IntValue>("PopulationSize", "The size of the population of solutions of each island.", new IntValue(100))); Parameters.Add(new ValueParameter <IntValue>("MaximumGenerations", "The maximum number of generations that should be processed.", new IntValue(100))); Parameters.Add(new ConstrainedValueParameter <ISelector>("Selector", "The operator used to select solutions for reproduction.")); Parameters.Add(new ConstrainedValueParameter <ICrossover>("Crossover", "The operator used to cross solutions.")); Parameters.Add(new ValueParameter <PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new PercentValue(0.05))); Parameters.Add(new ConstrainedValueParameter <IManipulator>("Mutator", "The operator used to mutate solutions.")); Parameters.Add(new ValueParameter <IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1))); Parameters.Add(new FixedValueParameter <BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)", new BoolValue(false)) { Hidden = true }); Parameters.Add(new ValueLookupParameter <DoubleValue>("SuccessRatio", "The ratio of successful to total children that should be achieved.", new DoubleValue(1))); Parameters.Add(new ValueLookupParameter <DoubleValue>("ComparisonFactorLowerBound", "The lower bound of the comparison factor (start).", new DoubleValue(0))); Parameters.Add(new ValueLookupParameter <DoubleValue>("ComparisonFactorUpperBound", "The upper bound of the comparison factor (end).", new DoubleValue(1))); Parameters.Add(new OptionalConstrainedValueParameter <IDiscreteDoubleValueModifier>("ComparisonFactorModifier", "The operator used to modify the comparison factor.", new ItemSet <IDiscreteDoubleValueModifier>(new IDiscreteDoubleValueModifier[] { new LinearDiscreteDoubleValueModifier() }), new LinearDiscreteDoubleValueModifier())); Parameters.Add(new ValueLookupParameter <DoubleValue>("MaximumSelectionPressure", "The maximum selection pressure that terminates the algorithm.", new DoubleValue(100))); Parameters.Add(new ValueLookupParameter <BoolValue>("OffspringSelectionBeforeMutation", "True if the offspring selection step should be applied before mutation, false if it should be applied after mutation.", new BoolValue(false))); Parameters.Add(new ValueLookupParameter <IntValue>("SelectedParents", "How much parents should be selected each time the offspring selection step is performed until the population is filled. This parameter should be about the same or twice the size of PopulationSize for smaller problems, and less for large problems.", new IntValue(200))); Parameters.Add(new ValueParameter <MultiAnalyzer>("Analyzer", "The operator used to analyze the islands.", new MultiAnalyzer())); Parameters.Add(new ValueParameter <MultiAnalyzer>("IslandAnalyzer", "The operator used to analyze each island.", new MultiAnalyzer())); Parameters.Add(new ValueParameter <IntValue>("MaximumEvaluatedSolutions", "The maximum number of evaluated solutions (approximately).", new IntValue(int.MaxValue))); Parameters.Add(new FixedValueParameter <BoolValue>("FillPopulationWithParents", "True if the population should be filled with parent individual or false if worse children should be used when the maximum selection pressure is exceeded.", new BoolValue(true)) { Hidden = true }); RandomCreator randomCreator = new RandomCreator(); SubScopesCreator populationCreator = new SubScopesCreator(); UniformSubScopesProcessor ussp1 = new UniformSubScopesProcessor(); SolutionsCreator solutionsCreator = new SolutionsCreator(); VariableCreator variableCreator = new VariableCreator(); UniformSubScopesProcessor ussp2 = new UniformSubScopesProcessor(); SubScopesCounter subScopesCounter = new SubScopesCounter(); ResultsCollector resultsCollector = new ResultsCollector(); IslandOffspringSelectionGeneticAlgorithmMainLoop mainLoop = new IslandOffspringSelectionGeneticAlgorithmMainLoop(); OperatorGraph.InitialOperator = randomCreator; randomCreator.RandomParameter.ActualName = "Random"; randomCreator.SeedParameter.ActualName = SeedParameter.Name; randomCreator.SeedParameter.Value = null; randomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameter.Name; randomCreator.SetSeedRandomlyParameter.Value = null; randomCreator.Successor = populationCreator; populationCreator.NumberOfSubScopesParameter.ActualName = NumberOfIslandsParameter.Name; populationCreator.Successor = ussp1; ussp1.Operator = solutionsCreator; ussp1.Successor = variableCreator; solutionsCreator.NumberOfSolutionsParameter.ActualName = PopulationSizeParameter.Name; solutionsCreator.Successor = null; variableCreator.Name = "Initialize EvaluatedSolutions"; variableCreator.CollectedValues.Add(new ValueParameter <IntValue>("EvaluatedSolutions", new IntValue())); variableCreator.Successor = ussp2; ussp2.Operator = subScopesCounter; ussp2.Successor = resultsCollector; subScopesCounter.Name = "Increment EvaluatedSolutions"; subScopesCounter.ValueParameter.ActualName = "EvaluatedSolutions"; resultsCollector.CollectedValues.Add(new LookupParameter <IntValue>("Evaluated Solutions", "", "EvaluatedSolutions")); resultsCollector.ResultsParameter.ActualName = "Results"; resultsCollector.Successor = mainLoop; mainLoop.EmigrantsSelectorParameter.ActualName = EmigrantsSelectorParameter.Name; mainLoop.ImmigrationReplacerParameter.ActualName = ImmigrationReplacerParameter.Name; mainLoop.MaximumGenerationsParameter.ActualName = MaximumGenerationsParameter.Name; mainLoop.MigrationIntervalParameter.ActualName = MigrationIntervalParameter.Name; mainLoop.MigrationRateParameter.ActualName = MigrationRateParameter.Name; mainLoop.MigratorParameter.ActualName = MigratorParameter.Name; mainLoop.NumberOfIslandsParameter.ActualName = NumberOfIslandsParameter.Name; mainLoop.SelectorParameter.ActualName = SelectorParameter.Name; mainLoop.CrossoverParameter.ActualName = CrossoverParameter.Name; mainLoop.ElitesParameter.ActualName = ElitesParameter.Name; mainLoop.ReevaluateElitesParameter.ActualName = ReevaluateElitesParameter.Name; mainLoop.MutatorParameter.ActualName = MutatorParameter.Name; mainLoop.MutationProbabilityParameter.ActualName = MutationProbabilityParameter.Name; mainLoop.RandomParameter.ActualName = randomCreator.RandomParameter.ActualName; mainLoop.ResultsParameter.ActualName = "Results"; mainLoop.SuccessRatioParameter.ActualName = SuccessRatioParameter.Name; mainLoop.ComparisonFactorParameter.ActualName = "ComparisonFactor"; mainLoop.ComparisonFactorStartParameter.ActualName = ComparisonFactorLowerBoundParameter.Name; mainLoop.ComparisonFactorModifierParameter.ActualName = ComparisonFactorModifierParameter.Name; mainLoop.MaximumSelectionPressureParameter.ActualName = MaximumSelectionPressureParameter.Name; mainLoop.OffspringSelectionBeforeMutationParameter.ActualName = OffspringSelectionBeforeMutationParameter.Name; mainLoop.EvaluatedSolutionsParameter.ActualName = "EvaluatedSolutions"; mainLoop.FillPopulationWithParentsParameter.ActualName = FillPopulationWithParentsParameter.Name; mainLoop.Successor = null; foreach (ISelector selector in ApplicationManager.Manager.GetInstances <ISelector>().Where(x => !(x is IMultiObjectiveSelector)).OrderBy(x => x.Name)) { SelectorParameter.ValidValues.Add(selector); } ISelector proportionalSelector = SelectorParameter.ValidValues.FirstOrDefault(x => x.GetType().Name.Equals("ProportionalSelector")); if (proportionalSelector != null) { SelectorParameter.Value = proportionalSelector; } foreach (ISelector selector in ApplicationManager.Manager.GetInstances <ISelector>().Where(x => !(x is IMultiObjectiveSelector)).OrderBy(x => x.Name)) { EmigrantsSelectorParameter.ValidValues.Add(selector); } foreach (IReplacer replacer in ApplicationManager.Manager.GetInstances <IReplacer>().OrderBy(x => x.Name)) { ImmigrationReplacerParameter.ValidValues.Add(replacer); } ParameterizeSelectors(); foreach (IMigrator migrator in ApplicationManager.Manager.GetInstances <IMigrator>().OrderBy(x => x.Name)) { // BackwardsCompatibility3.3 // Set the migration direction to counterclockwise var unidirectionalRing = migrator as UnidirectionalRingMigrator; if (unidirectionalRing != null) { unidirectionalRing.ClockwiseMigrationParameter.Value = new BoolValue(false); } MigratorParameter.ValidValues.Add(migrator); } foreach (IDiscreteDoubleValueModifier modifier in ApplicationManager.Manager.GetInstances <IDiscreteDoubleValueModifier>().OrderBy(x => x.Name)) { ComparisonFactorModifierParameter.ValidValues.Add(modifier); } IDiscreteDoubleValueModifier linearModifier = ComparisonFactorModifierParameter.ValidValues.FirstOrDefault(x => x.GetType().Name.Equals("LinearDiscreteDoubleValueModifier")); if (linearModifier != null) { ComparisonFactorModifierParameter.Value = linearModifier; } ParameterizeComparisonFactorModifiers(); qualityAnalyzer = new BestAverageWorstQualityAnalyzer(); islandQualityAnalyzer = new BestAverageWorstQualityAnalyzer(); selectionPressureAnalyzer = new ValueAnalyzer(); islandSelectionPressureAnalyzer = new ValueAnalyzer(); successfulOffspringAnalyzer = new SuccessfulOffspringAnalyzer(); ParameterizeAnalyzers(); UpdateAnalyzers(); Initialize(); }
private IslandOffspringSelectionGeneticAlgorithmMainLoop(IslandOffspringSelectionGeneticAlgorithmMainLoop original, Cloner cloner) : base(original, cloner) { }
private IslandOffspringSelectionGeneticAlgorithmMainLoop(IslandOffspringSelectionGeneticAlgorithmMainLoop original, Cloner cloner) : base(original, cloner) { }
public IslandOffspringSelectionGeneticAlgorithm() : base() { Parameters.Add(new ValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0))); Parameters.Add(new ValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true))); Parameters.Add(new ValueParameter<IntValue>("NumberOfIslands", "The number of islands.", new IntValue(5))); Parameters.Add(new ValueParameter<IntValue>("MigrationInterval", "The number of generations that should pass between migration phases.", new IntValue(20))); Parameters.Add(new ValueParameter<PercentValue>("MigrationRate", "The proportion of individuals that should migrate between the islands.", new PercentValue(0.15))); Parameters.Add(new ConstrainedValueParameter<IMigrator>("Migrator", "The migration strategy.")); Parameters.Add(new ConstrainedValueParameter<ISelector>("EmigrantsSelector", "Selects the individuals that will be migrated.")); Parameters.Add(new ConstrainedValueParameter<IReplacer>("ImmigrationReplacer", "Replaces part of the original population with the immigrants.")); Parameters.Add(new ValueParameter<IntValue>("PopulationSize", "The size of the population of solutions of each island.", new IntValue(100))); Parameters.Add(new ValueParameter<IntValue>("MaximumGenerations", "The maximum number of generations that should be processed.", new IntValue(100))); Parameters.Add(new ConstrainedValueParameter<ISelector>("Selector", "The operator used to select solutions for reproduction.")); Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions.")); Parameters.Add(new ValueParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new PercentValue(0.05))); Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions.")); Parameters.Add(new ValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1))); Parameters.Add(new FixedValueParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)", new BoolValue(false)) { Hidden = true }); Parameters.Add(new ValueLookupParameter<DoubleValue>("SuccessRatio", "The ratio of successful to total children that should be achieved.", new DoubleValue(1))); Parameters.Add(new ValueLookupParameter<DoubleValue>("ComparisonFactorLowerBound", "The lower bound of the comparison factor (start).", new DoubleValue(0))); Parameters.Add(new ValueLookupParameter<DoubleValue>("ComparisonFactorUpperBound", "The upper bound of the comparison factor (end).", new DoubleValue(1))); Parameters.Add(new OptionalConstrainedValueParameter<IDiscreteDoubleValueModifier>("ComparisonFactorModifier", "The operator used to modify the comparison factor.", new ItemSet<IDiscreteDoubleValueModifier>(new IDiscreteDoubleValueModifier[] { new LinearDiscreteDoubleValueModifier() }), new LinearDiscreteDoubleValueModifier())); Parameters.Add(new ValueLookupParameter<DoubleValue>("MaximumSelectionPressure", "The maximum selection pressure that terminates the algorithm.", new DoubleValue(100))); Parameters.Add(new ValueLookupParameter<BoolValue>("OffspringSelectionBeforeMutation", "True if the offspring selection step should be applied before mutation, false if it should be applied after mutation.", new BoolValue(false))); Parameters.Add(new ValueLookupParameter<IntValue>("SelectedParents", "How much parents should be selected each time the offspring selection step is performed until the population is filled. This parameter should be about the same or twice the size of PopulationSize for smaller problems, and less for large problems.", new IntValue(200))); Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze the islands.", new MultiAnalyzer())); Parameters.Add(new ValueParameter<MultiAnalyzer>("IslandAnalyzer", "The operator used to analyze each island.", new MultiAnalyzer())); Parameters.Add(new ValueParameter<IntValue>("MaximumEvaluatedSolutions", "The maximum number of evaluated solutions (approximately).", new IntValue(int.MaxValue))); Parameters.Add(new FixedValueParameter<BoolValue>("FillPopulationWithParents", "True if the population should be filled with parent individual or false if worse children should be used when the maximum selection pressure is exceeded.", new BoolValue(true)) { Hidden = true }); RandomCreator randomCreator = new RandomCreator(); SubScopesCreator populationCreator = new SubScopesCreator(); UniformSubScopesProcessor ussp1 = new UniformSubScopesProcessor(); SolutionsCreator solutionsCreator = new SolutionsCreator(); VariableCreator variableCreator = new VariableCreator(); UniformSubScopesProcessor ussp2 = new UniformSubScopesProcessor(); SubScopesCounter subScopesCounter = new SubScopesCounter(); ResultsCollector resultsCollector = new ResultsCollector(); IslandOffspringSelectionGeneticAlgorithmMainLoop mainLoop = new IslandOffspringSelectionGeneticAlgorithmMainLoop(); OperatorGraph.InitialOperator = randomCreator; randomCreator.RandomParameter.ActualName = "Random"; randomCreator.SeedParameter.ActualName = SeedParameter.Name; randomCreator.SeedParameter.Value = null; randomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameter.Name; randomCreator.SetSeedRandomlyParameter.Value = null; randomCreator.Successor = populationCreator; populationCreator.NumberOfSubScopesParameter.ActualName = NumberOfIslandsParameter.Name; populationCreator.Successor = ussp1; ussp1.Operator = solutionsCreator; ussp1.Successor = variableCreator; solutionsCreator.NumberOfSolutionsParameter.ActualName = PopulationSizeParameter.Name; solutionsCreator.Successor = null; variableCreator.Name = "Initialize EvaluatedSolutions"; variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedSolutions", new IntValue())); variableCreator.Successor = ussp2; ussp2.Operator = subScopesCounter; ussp2.Successor = resultsCollector; subScopesCounter.Name = "Increment EvaluatedSolutions"; subScopesCounter.ValueParameter.ActualName = "EvaluatedSolutions"; resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Solutions", "", "EvaluatedSolutions")); resultsCollector.ResultsParameter.ActualName = "Results"; resultsCollector.Successor = mainLoop; mainLoop.EmigrantsSelectorParameter.ActualName = EmigrantsSelectorParameter.Name; mainLoop.ImmigrationReplacerParameter.ActualName = ImmigrationReplacerParameter.Name; mainLoop.MaximumGenerationsParameter.ActualName = MaximumGenerationsParameter.Name; mainLoop.MigrationIntervalParameter.ActualName = MigrationIntervalParameter.Name; mainLoop.MigrationRateParameter.ActualName = MigrationRateParameter.Name; mainLoop.MigratorParameter.ActualName = MigratorParameter.Name; mainLoop.NumberOfIslandsParameter.ActualName = NumberOfIslandsParameter.Name; mainLoop.SelectorParameter.ActualName = SelectorParameter.Name; mainLoop.CrossoverParameter.ActualName = CrossoverParameter.Name; mainLoop.ElitesParameter.ActualName = ElitesParameter.Name; mainLoop.ReevaluateElitesParameter.ActualName = ReevaluateElitesParameter.Name; mainLoop.MutatorParameter.ActualName = MutatorParameter.Name; mainLoop.MutationProbabilityParameter.ActualName = MutationProbabilityParameter.Name; mainLoop.RandomParameter.ActualName = randomCreator.RandomParameter.ActualName; mainLoop.ResultsParameter.ActualName = "Results"; mainLoop.SuccessRatioParameter.ActualName = SuccessRatioParameter.Name; mainLoop.ComparisonFactorParameter.ActualName = "ComparisonFactor"; mainLoop.ComparisonFactorStartParameter.ActualName = ComparisonFactorLowerBoundParameter.Name; mainLoop.ComparisonFactorModifierParameter.ActualName = ComparisonFactorModifierParameter.Name; mainLoop.MaximumSelectionPressureParameter.ActualName = MaximumSelectionPressureParameter.Name; mainLoop.OffspringSelectionBeforeMutationParameter.ActualName = OffspringSelectionBeforeMutationParameter.Name; mainLoop.EvaluatedSolutionsParameter.ActualName = "EvaluatedSolutions"; mainLoop.FillPopulationWithParentsParameter.ActualName = FillPopulationWithParentsParameter.Name; mainLoop.Successor = null; foreach (ISelector selector in ApplicationManager.Manager.GetInstances<ISelector>().Where(x => !(x is IMultiObjectiveSelector)).OrderBy(x => x.Name)) SelectorParameter.ValidValues.Add(selector); ISelector proportionalSelector = SelectorParameter.ValidValues.FirstOrDefault(x => x.GetType().Name.Equals("ProportionalSelector")); if (proportionalSelector != null) SelectorParameter.Value = proportionalSelector; foreach (ISelector selector in ApplicationManager.Manager.GetInstances<ISelector>().Where(x => !(x is IMultiObjectiveSelector)).OrderBy(x => x.Name)) EmigrantsSelectorParameter.ValidValues.Add(selector); foreach (IReplacer replacer in ApplicationManager.Manager.GetInstances<IReplacer>().OrderBy(x => x.Name)) ImmigrationReplacerParameter.ValidValues.Add(replacer); ParameterizeSelectors(); foreach (IMigrator migrator in ApplicationManager.Manager.GetInstances<IMigrator>().OrderBy(x => x.Name)) { // BackwardsCompatibility3.3 // Set the migration direction to counterclockwise var unidirectionalRing = migrator as UnidirectionalRingMigrator; if (unidirectionalRing != null) unidirectionalRing.ClockwiseMigrationParameter.Value = new BoolValue(false); MigratorParameter.ValidValues.Add(migrator); } foreach (IDiscreteDoubleValueModifier modifier in ApplicationManager.Manager.GetInstances<IDiscreteDoubleValueModifier>().OrderBy(x => x.Name)) ComparisonFactorModifierParameter.ValidValues.Add(modifier); IDiscreteDoubleValueModifier linearModifier = ComparisonFactorModifierParameter.ValidValues.FirstOrDefault(x => x.GetType().Name.Equals("LinearDiscreteDoubleValueModifier")); if (linearModifier != null) ComparisonFactorModifierParameter.Value = linearModifier; ParameterizeComparisonFactorModifiers(); qualityAnalyzer = new BestAverageWorstQualityAnalyzer(); islandQualityAnalyzer = new BestAverageWorstQualityAnalyzer(); selectionPressureAnalyzer = new ValueAnalyzer(); islandSelectionPressureAnalyzer = new ValueAnalyzer(); successfulOffspringAnalyzer = new SuccessfulOffspringAnalyzer(); ParameterizeAnalyzers(); UpdateAnalyzers(); Initialize(); }