Ejemplo n.º 1
0
    public Replacer() {
      Parameters.Add(new ValueLookupParameter<ISelector>("ReplacedSelector", "The selection operator to select those scopes that are to be replaced. If no selection operator is defined, random selection will be applied."));
      Parameters.Add(new ValueLookupParameter<ISelector>("SelectedSelector", "The selection operator to select those scopes that are replacing the others. If no selection operator is defined, random selection will be applied."));

      SubScopesProcessor ssp = new SubScopesProcessor();

      Placeholder replacedSelector = new Placeholder();
      replacedSelector.OperatorParameter.ActualName = ReplacedSelectorParameter.Name;

      LeftReducer leftReducer = new LeftReducer();

      Placeholder selectedSelector = new Placeholder();
      selectedSelector.OperatorParameter.ActualName = SelectedSelectorParameter.Name;

      RightReducer rightReducer = new RightReducer();

      MergingReducer merger = new MergingReducer();

      OperatorGraph.InitialOperator = ssp;
      ssp.Operators.Add(replacedSelector);
      ssp.Operators.Add(selectedSelector);
      ssp.Successor = merger;
      replacedSelector.Successor = leftReducer;
      leftReducer.Successor = null;
      selectedSelector.Successor = rightReducer;
      rightReducer.Successor = null;
      merger.Successor = null;
    }
Ejemplo n.º 2
0
        public Replacer()
        {
            Parameters.Add(new ValueLookupParameter <ISelector>("ReplacedSelector", "The selection operator to select those scopes that are to be replaced. If no selection operator is defined, random selection will be applied."));
            Parameters.Add(new ValueLookupParameter <ISelector>("SelectedSelector", "The selection operator to select those scopes that are replacing the others. If no selection operator is defined, random selection will be applied."));

            SubScopesProcessor ssp = new SubScopesProcessor();

            Placeholder replacedSelector = new Placeholder();

            replacedSelector.OperatorParameter.ActualName = ReplacedSelectorParameter.Name;

            LeftReducer leftReducer = new LeftReducer();

            Placeholder selectedSelector = new Placeholder();

            selectedSelector.OperatorParameter.ActualName = SelectedSelectorParameter.Name;

            RightReducer rightReducer = new RightReducer();

            MergingReducer merger = new MergingReducer();

            OperatorGraph.InitialOperator = ssp;
            ssp.Operators.Add(replacedSelector);
            ssp.Operators.Add(selectedSelector);
            ssp.Successor = merger;
            replacedSelector.Successor = leftReducer;
            leftReducer.Successor      = null;
            selectedSelector.Successor = rightReducer;
            rightReducer.Successor     = null;
            merger.Successor           = null;
        }
    private void Initialize() {
      #region Create parameters
      Parameters.Add(new ValueLookupParameter<IRandom>("Random", "A pseudo random number generator."));
      Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem, otherwise false."));
      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The value which represents the quality of a solution."));
      Parameters.Add(new ValueLookupParameter<IOperator>("Selector", "The operator used to select solutions for reproduction."));
      Parameters.Add(new ValueLookupParameter<IOperator>("Crossover", "The operator used to cross solutions."));
      Parameters.Add(new ValueLookupParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution."));
      Parameters.Add(new ValueLookupParameter<IOperator>("Mutator", "The operator used to mutate solutions."));
      Parameters.Add(new ValueLookupParameter<IOperator>("Evaluator", "The operator used to evaluate solutions. This operator is executed in parallel, if an engine is used which supports parallelization."));
      Parameters.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "The number of evaluated solutions."));
      Parameters.Add(new ValueLookupParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation."));
      Parameters.Add(new ValueLookupParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)"));
      Parameters.Add(new LookupParameter<DoubleValue>("ComparisonFactor", "The comparison factor is used to determine whether the offspring should be compared to the better parent, the worse parent or a quality value linearly interpolated between them. It is in the range [0;1]."));
      Parameters.Add(new LookupParameter<DoubleValue>("CurrentSuccessRatio", "The current success ratio."));
      Parameters.Add(new ValueLookupParameter<DoubleValue>("SuccessRatio", "The ratio of successful to total children that should be achieved."));
      Parameters.Add(new LookupParameter<DoubleValue>("SelectionPressure", "The actual selection pressure."));
      Parameters.Add(new ValueLookupParameter<DoubleValue>("MaximumSelectionPressure", "The maximum selection pressure that terminates the algorithm."));
      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."));
      Parameters.Add(new ValueLookupParameter<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."));
      #endregion

      #region Create operators
      Placeholder selector = new Placeholder();
      SubScopesProcessor subScopesProcessor1 = new SubScopesProcessor();
      ChildrenCreator childrenCreator = new ChildrenCreator();
      ConditionalBranch osBeforeMutationBranch = new ConditionalBranch();
      UniformSubScopesProcessor uniformSubScopesProcessor1 = new UniformSubScopesProcessor();
      Placeholder crossover1 = new Placeholder();
      UniformSubScopesProcessor uniformSubScopesProcessor2 = new UniformSubScopesProcessor();
      Placeholder evaluator1 = new Placeholder();
      SubScopesCounter subScopesCounter1 = new SubScopesCounter();
      WeightedParentsQualityComparator qualityComparer1 = new WeightedParentsQualityComparator();
      SubScopesRemover subScopesRemover1 = new SubScopesRemover();
      UniformSubScopesProcessor uniformSubScopesProcessor3 = new UniformSubScopesProcessor();
      StochasticBranch mutationBranch1 = new StochasticBranch();
      Placeholder mutator1 = new Placeholder();
      VariableCreator variableCreator1 = new VariableCreator();
      VariableCreator variableCreator2 = new VariableCreator();
      ConditionalSelector conditionalSelector = new ConditionalSelector();
      SubScopesProcessor subScopesProcessor2 = new SubScopesProcessor();
      UniformSubScopesProcessor uniformSubScopesProcessor4 = new UniformSubScopesProcessor();
      Placeholder evaluator2 = new Placeholder();
      SubScopesCounter subScopesCounter2 = new SubScopesCounter();
      MergingReducer mergingReducer1 = new MergingReducer();
      UniformSubScopesProcessor uniformSubScopesProcessor5 = new UniformSubScopesProcessor();
      Placeholder crossover2 = new Placeholder();
      StochasticBranch mutationBranch2 = new StochasticBranch();
      Placeholder mutator2 = new Placeholder();
      UniformSubScopesProcessor uniformSubScopesProcessor6 = new UniformSubScopesProcessor();
      Placeholder evaluator3 = new Placeholder();
      SubScopesCounter subScopesCounter3 = new SubScopesCounter();
      WeightedParentsQualityComparator qualityComparer2 = new WeightedParentsQualityComparator();
      SubScopesRemover subScopesRemover2 = new SubScopesRemover();
      OffspringSelector offspringSelector = new OffspringSelector();
      SubScopesProcessor subScopesProcessor3 = new SubScopesProcessor();
      BestSelector bestSelector = new BestSelector();
      WorstSelector worstSelector = new WorstSelector();
      RightReducer rightReducer = new RightReducer();
      LeftReducer leftReducer = new LeftReducer();
      MergingReducer mergingReducer2 = new MergingReducer();
      ConditionalBranch reevaluateElitesBranch = new ConditionalBranch();
      UniformSubScopesProcessor uniformSubScopesProcessor7 = new UniformSubScopesProcessor();
      Placeholder evaluator4 = new Placeholder();
      SubScopesCounter subScopesCounter4 = new SubScopesCounter();

      selector.Name = "Selector (placeholder)";
      selector.OperatorParameter.ActualName = SelectorParameter.Name;

      childrenCreator.ParentsPerChild = new IntValue(2);

      osBeforeMutationBranch.Name = "Apply OS before mutation?";
      osBeforeMutationBranch.ConditionParameter.ActualName = OffspringSelectionBeforeMutationParameter.Name;

      crossover1.Name = "Crossover (placeholder)";
      crossover1.OperatorParameter.ActualName = CrossoverParameter.Name;

      uniformSubScopesProcessor2.Parallel.Value = true;

      evaluator1.Name = "Evaluator (placeholder)";
      evaluator1.OperatorParameter.ActualName = EvaluatorParameter.Name;

      subScopesCounter1.Name = "Increment EvaluatedSolutions";
      subScopesCounter1.ValueParameter.ActualName = EvaluatedSolutionsParameter.Name;

      qualityComparer1.ComparisonFactorParameter.ActualName = ComparisonFactorParameter.Name;
      qualityComparer1.LeftSideParameter.ActualName = QualityParameter.Name;
      qualityComparer1.MaximizationParameter.ActualName = MaximizationParameter.Name;
      qualityComparer1.RightSideParameter.ActualName = QualityParameter.Name;
      qualityComparer1.ResultParameter.ActualName = "SuccessfulOffspring";

      subScopesRemover1.RemoveAllSubScopes = true;

      mutationBranch1.ProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
      mutationBranch1.RandomParameter.ActualName = RandomParameter.Name;

      mutator1.Name = "Mutator (placeholder)";
      mutator1.OperatorParameter.ActualName = MutatorParameter.Name;

      variableCreator1.Name = "MutatedOffspring = true";
      variableCreator1.CollectedValues.Add(new ValueParameter<BoolValue>("MutatedOffspring", null, new BoolValue(true), false));

      variableCreator2.Name = "MutatedOffspring = false";
      variableCreator2.CollectedValues.Add(new ValueParameter<BoolValue>("MutatedOffspring", null, new BoolValue(false), false));

      conditionalSelector.ConditionParameter.ActualName = "MutatedOffspring";
      conditionalSelector.ConditionParameter.Depth = 1;
      conditionalSelector.CopySelected.Value = false;

      uniformSubScopesProcessor4.Parallel.Value = true;

      evaluator2.Name = "Evaluator (placeholder)";
      evaluator2.OperatorParameter.ActualName = EvaluatorParameter.Name;

      subScopesCounter2.Name = "Increment EvaluatedSolutions";
      subScopesCounter2.ValueParameter.ActualName = EvaluatedSolutionsParameter.Name;

      crossover2.Name = "Crossover (placeholder)";
      crossover2.OperatorParameter.ActualName = CrossoverParameter.Name;

      mutationBranch2.ProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
      mutationBranch2.RandomParameter.ActualName = RandomParameter.Name;

      mutator2.Name = "Mutator (placeholder)";
      mutator2.OperatorParameter.ActualName = MutatorParameter.Name;

      uniformSubScopesProcessor6.Parallel.Value = true;

      evaluator3.Name = "Evaluator (placeholder)";
      evaluator3.OperatorParameter.ActualName = EvaluatorParameter.Name;

      subScopesCounter3.Name = "Increment EvaluatedSolutions";
      subScopesCounter3.ValueParameter.ActualName = EvaluatedSolutionsParameter.Name;

      qualityComparer2.ComparisonFactorParameter.ActualName = ComparisonFactorParameter.Name;
      qualityComparer2.LeftSideParameter.ActualName = QualityParameter.Name;
      qualityComparer2.MaximizationParameter.ActualName = MaximizationParameter.Name;
      qualityComparer2.RightSideParameter.ActualName = QualityParameter.Name;
      qualityComparer2.ResultParameter.ActualName = "SuccessfulOffspring";

      subScopesRemover2.RemoveAllSubScopes = true;

      offspringSelector.CurrentSuccessRatioParameter.ActualName = CurrentSuccessRatioParameter.Name;
      offspringSelector.MaximumSelectionPressureParameter.ActualName = MaximumSelectionPressureParameter.Name;
      offspringSelector.SelectionPressureParameter.ActualName = SelectionPressureParameter.Name;
      offspringSelector.SuccessRatioParameter.ActualName = SuccessRatioParameter.Name;
      offspringSelector.OffspringPopulationParameter.ActualName = "OffspringPopulation";
      offspringSelector.OffspringPopulationWinnersParameter.ActualName = "OffspringPopulationWinners";
      offspringSelector.SuccessfulOffspringParameter.ActualName = "SuccessfulOffspring";
      offspringSelector.FillPopulationWithParentsParameter.ActualName = FillPopulationWithParentsParameter.Name;

      bestSelector.CopySelected = new BoolValue(false);
      bestSelector.MaximizationParameter.ActualName = MaximizationParameter.Name;
      bestSelector.NumberOfSelectedSubScopesParameter.ActualName = ElitesParameter.Name;
      bestSelector.QualityParameter.ActualName = QualityParameter.Name;

      worstSelector.CopySelected = new BoolValue(false);
      worstSelector.MaximizationParameter.ActualName = MaximizationParameter.Name;
      worstSelector.NumberOfSelectedSubScopesParameter.ActualName = ElitesParameter.Name;
      worstSelector.QualityParameter.ActualName = QualityParameter.Name;

      reevaluateElitesBranch.ConditionParameter.ActualName = "ReevaluateElites";
      reevaluateElitesBranch.Name = "Reevaluate elites ?";

      uniformSubScopesProcessor7.Parallel.Value = true;

      evaluator4.Name = "Evaluator (placeholder)";
      evaluator4.OperatorParameter.ActualName = EvaluatorParameter.Name;

      subScopesCounter4.Name = "Increment EvaluatedSolutions";
      subScopesCounter4.ValueParameter.ActualName = EvaluatedSolutionsParameter.Name;
      #endregion

      #region Create operator graph
      OperatorGraph.InitialOperator = selector;
      selector.Successor = subScopesProcessor1;
      subScopesProcessor1.Operators.Add(new EmptyOperator());
      subScopesProcessor1.Operators.Add(childrenCreator);
      subScopesProcessor1.Successor = offspringSelector;
      childrenCreator.Successor = osBeforeMutationBranch;
      osBeforeMutationBranch.TrueBranch = uniformSubScopesProcessor1;
      osBeforeMutationBranch.FalseBranch = uniformSubScopesProcessor5;
      osBeforeMutationBranch.Successor = null;
      uniformSubScopesProcessor1.Operator = crossover1;
      uniformSubScopesProcessor1.Successor = uniformSubScopesProcessor2;
      crossover1.Successor = null;
      uniformSubScopesProcessor2.Operator = evaluator1;
      uniformSubScopesProcessor2.Successor = subScopesCounter1;
      evaluator1.Successor = qualityComparer1;
      qualityComparer1.Successor = subScopesRemover1;
      subScopesRemover1.Successor = null;
      subScopesCounter1.Successor = uniformSubScopesProcessor3;
      uniformSubScopesProcessor3.Operator = mutationBranch1;
      uniformSubScopesProcessor3.Successor = conditionalSelector;
      mutationBranch1.FirstBranch = mutator1;
      mutationBranch1.SecondBranch = variableCreator2;
      mutationBranch1.Successor = null;
      mutator1.Successor = variableCreator1;
      variableCreator1.Successor = null;
      variableCreator2.Successor = null;
      conditionalSelector.Successor = subScopesProcessor2;
      subScopesProcessor2.Operators.Add(new EmptyOperator());
      subScopesProcessor2.Operators.Add(uniformSubScopesProcessor4);
      subScopesProcessor2.Successor = mergingReducer1;
      uniformSubScopesProcessor4.Operator = evaluator2;
      uniformSubScopesProcessor4.Successor = subScopesCounter2;
      evaluator2.Successor = null;
      subScopesCounter2.Successor = null;
      mergingReducer1.Successor = null;
      uniformSubScopesProcessor5.Operator = crossover2;
      uniformSubScopesProcessor5.Successor = uniformSubScopesProcessor6;
      crossover2.Successor = mutationBranch2;
      mutationBranch2.FirstBranch = mutator2;
      mutationBranch2.SecondBranch = null;
      mutationBranch2.Successor = null;
      mutator2.Successor = null;
      uniformSubScopesProcessor6.Operator = evaluator3;
      uniformSubScopesProcessor6.Successor = subScopesCounter3;
      evaluator3.Successor = qualityComparer2;
      qualityComparer2.Successor = subScopesRemover2;
      subScopesRemover2.Successor = null;
      subScopesCounter3.Successor = null;
      offspringSelector.OffspringCreator = selector;
      offspringSelector.Successor = subScopesProcessor3;
      subScopesProcessor3.Operators.Add(bestSelector);
      subScopesProcessor3.Operators.Add(worstSelector);
      subScopesProcessor3.Successor = mergingReducer2;
      bestSelector.Successor = rightReducer;
      rightReducer.Successor = reevaluateElitesBranch;
      reevaluateElitesBranch.TrueBranch = uniformSubScopesProcessor7;
      uniformSubScopesProcessor7.Operator = evaluator4;
      uniformSubScopesProcessor7.Successor = subScopesCounter4;
      subScopesCounter4.Successor = null;
      reevaluateElitesBranch.FalseBranch = null;
      reevaluateElitesBranch.Successor = null;
      worstSelector.Successor = leftReducer;
      leftReducer.Successor = null;
      mergingReducer2.Successor = null;
      #endregion
    }
Ejemplo n.º 4
0
 private LeftReducer(LeftReducer original, Cloner cloner) : base(original, cloner)
 {
 }
Ejemplo n.º 5
0
    private void Initialize() {
      #region Create parameters
      Parameters.Add(new ValueLookupParameter<IRandom>("Random", "A pseudo random number generator."));
      Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem, otherwise false."));
      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The value which represents the quality of a solution."));
      Parameters.Add(new ValueLookupParameter<IOperator>("Selector", "The operator used to select solutions for reproduction."));
      Parameters.Add(new ValueLookupParameter<IOperator>("Crossover", "The operator used to cross solutions."));
      Parameters.Add(new ValueLookupParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution."));
      Parameters.Add(new ValueLookupParameter<IOperator>("Mutator", "The operator used to mutate solutions."));
      Parameters.Add(new ValueLookupParameter<IOperator>("Evaluator", "The operator used to evaluate solutions. This operator is executed in parallel, if an engine is used which supports parallelization."));
      Parameters.Add(new ValueLookupParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation."));
      Parameters.Add(new ValueLookupParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)"));
      Parameters.Add(new ValueLookupParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed."));
      Parameters.Add(new ValueLookupParameter<VariableCollection>("Results", "The variable collection where results should be stored."));
      Parameters.Add(new ValueLookupParameter<IOperator>("Analyzer", "The operator used to analyze each generation."));
      Parameters.Add(new ValueLookupParameter<IntValue>("EvaluatedSolutions", "The number of times solutions have been evaluated."));
      Parameters.Add(new ValueLookupParameter<IntValue>("PopulationSize", "The size of the population."));
      Parameters.Add(new ValueLookupParameter<IntValue>("MinimumPopulationSize", "The minimum size of the population of solutions."));
      Parameters.Add(new ValueLookupParameter<IntValue>("MaximumPopulationSize", "The maximum size of the population of solutions."));
      Parameters.Add(new ValueLookupParameter<DoubleValue>("ComparisonFactor", "The comparison factor."));
      Parameters.Add(new ValueLookupParameter<IntValue>("Effort", "The maximum number of offspring created in each generation."));
      Parameters.Add(new ValueLookupParameter<IntValue>("BatchSize", "The number of children that should be created during one iteration of the offspring creation process."));
      Parameters.Add(new ValueLookupParameter<ISolutionSimilarityCalculator>("SimilarityCalculator", "The operator used to calculate the similarity between two solutions."));
      Parameters.Add(new ScopeParameter("CurrentScope", "The current scope which represents a population of solutions on which the genetic algorithm should be applied."));
      #endregion

      #region Create operators
      VariableCreator variableCreator = new VariableCreator();
      Assigner assigner1 = new Assigner();
      ResultsCollector resultsCollector = new ResultsCollector();
      Placeholder analyzer1 = new Placeholder();
      Placeholder selector = new Placeholder();
      SubScopesProcessor subScopesProcessor1 = new SubScopesProcessor();
      ChildrenCreator childrenCreator = new ChildrenCreator();
      UniformSubScopesProcessor uniformSubScopesProcessor = new UniformSubScopesProcessor();
      Placeholder crossover = new Placeholder();
      StochasticBranch stochasticBranch = new StochasticBranch();
      Placeholder mutator = new Placeholder();
      Placeholder evaluator = new Placeholder();
      WeightedParentsQualityComparator weightedParentsQualityComparator = new WeightedParentsQualityComparator();
      SubScopesRemover subScopesRemover = new SubScopesRemover();
      IntCounter intCounter1 = new IntCounter();
      IntCounter intCounter2 = new IntCounter();
      ConditionalSelector conditionalSelector = new ConditionalSelector();
      RightReducer rightReducer1 = new RightReducer();
      DuplicatesSelector duplicateSelector = new DuplicatesSelector();
      LeftReducer leftReducer1 = new LeftReducer();
      ProgressiveOffspringPreserver progressiveOffspringSelector = new ProgressiveOffspringPreserver();
      SubScopesCounter subScopesCounter2 = new SubScopesCounter();
      ExpressionCalculator calculator1 = new ExpressionCalculator();
      ConditionalBranch conditionalBranch1 = new ConditionalBranch();
      Comparator comparator1 = new Comparator();
      ConditionalBranch conditionalBranch2 = new ConditionalBranch();
      LeftReducer leftReducer2 = new LeftReducer();
      SubScopesProcessor subScopesProcessor2 = new SubScopesProcessor();
      BestSelector bestSelector = new BestSelector();
      RightReducer rightReducer2 = new RightReducer();
      ScopeCleaner scopeCleaner = new ScopeCleaner();
      ScopeRestorer scopeRestorer = new ScopeRestorer();
      MergingReducer mergingReducer = new MergingReducer();
      IntCounter intCounter3 = new IntCounter();
      SubScopesCounter subScopesCounter3 = new SubScopesCounter();
      ExpressionCalculator calculator2 = new ExpressionCalculator();
      Comparator comparator2 = new Comparator();
      ConditionalBranch conditionalBranch3 = new ConditionalBranch();
      Placeholder analyzer2 = new Placeholder();
      Comparator comparator3 = new Comparator();
      ConditionalBranch conditionalBranch4 = new ConditionalBranch();
      Comparator comparator4 = new Comparator();
      ConditionalBranch conditionalBranch5 = new ConditionalBranch();
      Assigner assigner3 = new Assigner();
      Assigner assigner4 = new Assigner();
      Assigner assigner5 = new Assigner();
      ConditionalBranch reevaluateElitesBranch = new ConditionalBranch();
      UniformSubScopesProcessor uniformSubScopesProcessor2 = new UniformSubScopesProcessor();
      Placeholder evaluator2 = new Placeholder();
      SubScopesCounter subScopesCounter4 = new SubScopesCounter();

      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0))); // Class RAPGA expects this to be called Generations
      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("CurrentPopulationSize", new IntValue(0)));
      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("NumberOfCreatedOffspring", new IntValue(0)));
      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("NumberOfSuccessfulOffspring", new IntValue(0)));
      variableCreator.CollectedValues.Add(new ValueParameter<ScopeList>("OffspringList", new ScopeList()));

      assigner1.Name = "Initialize CurrentPopulationSize";
      assigner1.LeftSideParameter.ActualName = "CurrentPopulationSize";
      assigner1.RightSideParameter.ActualName = PopulationSizeParameter.Name;

      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Generations"));
      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("CurrentPopulationSize"));
      resultsCollector.ResultsParameter.ActualName = "Results";

      analyzer1.Name = "Analyzer";
      analyzer1.OperatorParameter.ActualName = "Analyzer";

      selector.Name = "Selector";
      selector.OperatorParameter.ActualName = "Selector";

      childrenCreator.ParentsPerChild = new IntValue(2);

      uniformSubScopesProcessor.Parallel.Value = true;

      crossover.Name = "Crossover";
      crossover.OperatorParameter.ActualName = "Crossover";

      stochasticBranch.ProbabilityParameter.ActualName = "MutationProbability";
      stochasticBranch.RandomParameter.ActualName = "Random";

      mutator.Name = "Mutator";
      mutator.OperatorParameter.ActualName = "Mutator";

      evaluator.Name = "Evaluator";
      evaluator.OperatorParameter.ActualName = "Evaluator";

      weightedParentsQualityComparator.ComparisonFactorParameter.ActualName = ComparisonFactorParameter.Name;
      weightedParentsQualityComparator.LeftSideParameter.ActualName = QualityParameter.Name;
      weightedParentsQualityComparator.MaximizationParameter.ActualName = MaximizationParameter.Name;
      weightedParentsQualityComparator.RightSideParameter.ActualName = QualityParameter.Name;
      weightedParentsQualityComparator.ResultParameter.ActualName = "SuccessfulOffspring";

      subScopesRemover.RemoveAllSubScopes = true;

      intCounter1.Name = "Increment NumberOfCreatedOffspring";
      intCounter1.ValueParameter.ActualName = "NumberOfCreatedOffspring";
      intCounter1.Increment = null;
      intCounter1.IncrementParameter.ActualName = BatchSizeParameter.Name;

      intCounter2.Name = "Increment EvaluatedSolutions";
      intCounter2.ValueParameter.ActualName = EvaluatedSolutionsParameter.Name;
      intCounter2.Increment = null;
      intCounter2.IncrementParameter.ActualName = BatchSizeParameter.Name;

      conditionalSelector.ConditionParameter.ActualName = "SuccessfulOffspring";
      conditionalSelector.ConditionParameter.Depth = 1;
      conditionalSelector.CopySelected.Value = false;

      duplicateSelector.CopySelected.Value = false;

      progressiveOffspringSelector.OffspringListParameter.ActualName = "OffspringList";
      progressiveOffspringSelector.ElitesParameter.ActualName = ElitesParameter.Name;
      progressiveOffspringSelector.MaximumPopulationSizeParameter.ActualName = MaximumPopulationSizeParameter.Name;

      subScopesCounter2.Name = "Count Successful Offspring";
      subScopesCounter2.ValueParameter.ActualName = "NumberOfSuccessfulOffspring";

      calculator1.Name = "NumberOfSuccessfulOffspring == MaximumPopulationSize - Elites";
      calculator1.CollectedValues.Add(new ValueLookupParameter<IntValue>("NumberOfSuccessfulOffspring"));
      calculator1.CollectedValues.Add(new ValueLookupParameter<IntValue>("MaximumPopulationSize"));
      calculator1.CollectedValues.Add(new ValueLookupParameter<IntValue>("Elites"));
      calculator1.ExpressionParameter.Value = new StringValue("NumberOfSuccessfulOffspring MaximumPopulationSize Elites - ==");
      calculator1.ExpressionResultParameter.ActualName = "Break";

      conditionalBranch1.Name = "Break?";
      conditionalBranch1.ConditionParameter.ActualName = "Break";

      comparator1.Name = "NumberOfCreatedOffspring >= Effort";
      comparator1.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
      comparator1.LeftSideParameter.ActualName = "NumberOfCreatedOffspring";
      comparator1.RightSideParameter.ActualName = EffortParameter.Name;
      comparator1.ResultParameter.ActualName = "Break";

      conditionalBranch2.Name = "Break?";
      conditionalBranch2.ConditionParameter.ActualName = "Break";

      bestSelector.CopySelected = new BoolValue(false);
      bestSelector.MaximizationParameter.ActualName = MaximizationParameter.Name;
      bestSelector.NumberOfSelectedSubScopesParameter.ActualName = "Elites";
      bestSelector.QualityParameter.ActualName = QualityParameter.Name;

      intCounter3.Name = "Increment Generations";
      intCounter3.Increment = new IntValue(1);
      intCounter3.ValueParameter.ActualName = "Generations";

      subScopesCounter3.Name = "Update CurrentPopulationSize";
      subScopesCounter3.ValueParameter.ActualName = "CurrentPopulationSize";
      subScopesCounter3.AccumulateParameter.Value = new BoolValue(false);

      calculator2.Name = "Evaluate ActualSelectionPressure";
      calculator2.CollectedValues.Add(new ValueLookupParameter<IntValue>("NumberOfCreatedOffspring"));
      calculator2.CollectedValues.Add(new ValueLookupParameter<IntValue>("Elites"));
      calculator2.CollectedValues.Add(new ValueLookupParameter<IntValue>("CurrentPopulationSize"));
      calculator2.ExpressionParameter.Value = new StringValue("NumberOfCreatedOffspring Elites + CurrentPopulationSize /");
      calculator2.ExpressionResultParameter.ActualName = "ActualSelectionPressure";

      comparator2.Name = "CurrentPopulationSize < 1";
      comparator2.Comparison = new Comparison(ComparisonType.Less);
      comparator2.LeftSideParameter.ActualName = "CurrentPopulationSize";
      comparator2.RightSideParameter.Value = new IntValue(1);
      comparator2.ResultParameter.ActualName = "Terminate";

      conditionalBranch3.Name = "Terminate?";
      conditionalBranch3.ConditionParameter.ActualName = "Terminate";

      analyzer2.Name = "Analyzer";
      analyzer2.OperatorParameter.ActualName = "Analyzer";

      comparator3.Name = "Generations >= MaximumGenerations";
      comparator3.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
      comparator3.LeftSideParameter.ActualName = "Generations";
      comparator3.ResultParameter.ActualName = "Terminate";
      comparator3.RightSideParameter.ActualName = MaximumGenerationsParameter.Name;

      conditionalBranch4.Name = "Terminate?";
      conditionalBranch4.ConditionParameter.ActualName = "Terminate";

      comparator4.Name = "CurrentPopulationSize < MinimumPopulationSize";
      comparator4.Comparison = new Comparison(ComparisonType.Less);
      comparator4.LeftSideParameter.ActualName = "CurrentPopulationSize";
      comparator4.RightSideParameter.ActualName = MinimumPopulationSizeParameter.Name;
      comparator4.ResultParameter.ActualName = "Terminate";

      conditionalBranch5.Name = "Terminate?";
      conditionalBranch5.ConditionParameter.ActualName = "Terminate";

      assigner3.Name = "Reset NumberOfCreatedOffspring";
      assigner3.LeftSideParameter.ActualName = "NumberOfCreatedOffspring";
      assigner3.RightSideParameter.Value = new IntValue(0);

      assigner4.Name = "Reset NumberOfSuccessfulOffspring";
      assigner4.LeftSideParameter.ActualName = "NumberOfSuccessfulOffspring";
      assigner4.RightSideParameter.Value = new IntValue(0);

      assigner5.Name = "Reset OffspringList";
      assigner5.LeftSideParameter.ActualName = "OffspringList";
      assigner5.RightSideParameter.Value = new ScopeList();

      reevaluateElitesBranch.ConditionParameter.ActualName = "ReevaluateElites";
      reevaluateElitesBranch.Name = "Reevaluate elites ?";

      uniformSubScopesProcessor2.Parallel.Value = true;

      evaluator2.Name = "Evaluator (placeholder)";
      evaluator2.OperatorParameter.ActualName = EvaluatorParameter.Name;

      subScopesCounter4.Name = "Increment EvaluatedSolutions";
      subScopesCounter4.ValueParameter.ActualName = EvaluatedSolutionsParameter.Name;
      #endregion

      #region Create operator graph
      OperatorGraph.InitialOperator = variableCreator;
      variableCreator.Successor = assigner1;
      assigner1.Successor = resultsCollector;
      resultsCollector.Successor = analyzer1;
      analyzer1.Successor = selector;
      selector.Successor = subScopesProcessor1;
      subScopesProcessor1.Operators.Add(new EmptyOperator());
      subScopesProcessor1.Operators.Add(childrenCreator);
      subScopesProcessor1.Successor = calculator1;
      childrenCreator.Successor = uniformSubScopesProcessor;
      uniformSubScopesProcessor.Operator = crossover;
      uniformSubScopesProcessor.Successor = intCounter1;
      crossover.Successor = stochasticBranch;
      stochasticBranch.FirstBranch = mutator;
      stochasticBranch.SecondBranch = null;
      mutator.Successor = null;
      stochasticBranch.Successor = evaluator;
      evaluator.Successor = weightedParentsQualityComparator;
      weightedParentsQualityComparator.Successor = subScopesRemover;
      intCounter1.Successor = intCounter2;
      intCounter2.Successor = conditionalSelector;
      conditionalSelector.Successor = rightReducer1;
      rightReducer1.Successor = duplicateSelector;
      duplicateSelector.Successor = leftReducer1;
      leftReducer1.Successor = progressiveOffspringSelector;
      progressiveOffspringSelector.Successor = subScopesCounter2;
      calculator1.Successor = conditionalBranch1;
      conditionalBranch1.FalseBranch = comparator1;
      conditionalBranch1.TrueBranch = subScopesProcessor2;
      comparator1.Successor = conditionalBranch2;
      conditionalBranch2.FalseBranch = leftReducer2;
      conditionalBranch2.TrueBranch = subScopesProcessor2;
      leftReducer2.Successor = selector;
      subScopesProcessor2.Operators.Add(bestSelector);
      subScopesProcessor2.Operators.Add(scopeCleaner);
      subScopesProcessor2.Successor = mergingReducer;
      bestSelector.Successor = rightReducer2;
      rightReducer2.Successor = reevaluateElitesBranch;
      reevaluateElitesBranch.TrueBranch = uniformSubScopesProcessor2;
      uniformSubScopesProcessor2.Operator = evaluator2;
      uniformSubScopesProcessor2.Successor = subScopesCounter4;
      evaluator2.Successor = null;
      subScopesCounter4.Successor = null;
      reevaluateElitesBranch.FalseBranch = null;
      reevaluateElitesBranch.Successor = null;
      scopeCleaner.Successor = scopeRestorer;
      mergingReducer.Successor = intCounter3;
      intCounter3.Successor = subScopesCounter3;
      subScopesCounter3.Successor = calculator2;
      calculator2.Successor = comparator2;
      comparator2.Successor = conditionalBranch3;
      conditionalBranch3.FalseBranch = analyzer2;
      conditionalBranch3.TrueBranch = null;
      analyzer2.Successor = comparator3;
      comparator3.Successor = conditionalBranch4;
      conditionalBranch4.FalseBranch = comparator4;
      conditionalBranch4.TrueBranch = null;
      conditionalBranch4.Successor = null;
      comparator4.Successor = conditionalBranch5;
      conditionalBranch5.FalseBranch = assigner3;
      conditionalBranch5.TrueBranch = null;
      conditionalBranch5.Successor = null;
      assigner3.Successor = assigner4;
      assigner4.Successor = assigner5;
      assigner5.Successor = selector;

      #endregion
    }
Ejemplo n.º 6
0
 private LeftReducer(LeftReducer original, Cloner cloner) : base(original, cloner) { }