Ejemplo n.º 1
0
        private void InitializeOperators()
        {
            prunedNodesReducer = new DataReducer();
            prunedNodesReducer.ParameterToReduce.ActualName = PruningOperator.PrunedNodesParameter.ActualName;
            prunedNodesReducer.ReductionOperation.Value     = new ReductionOperation(ReductionOperations.Sum);    // sum all the pruned subtrees parameter values
            prunedNodesReducer.TargetOperation.Value        = new ReductionOperation(ReductionOperations.Assign); // asign the sum to the target parameter
            prunedNodesReducer.TargetParameter.ActualName   = TotalNumberOfPrunedNodesParameterName;

            prunedSubtreesReducer = new DataReducer();
            prunedSubtreesReducer.ParameterToReduce.ActualName = PruningOperator.PrunedSubtreesParameter.ActualName;
            prunedSubtreesReducer.ReductionOperation.Value     = new ReductionOperation(ReductionOperations.Sum);    // sum all the pruned subtrees parameter values
            prunedSubtreesReducer.TargetOperation.Value        = new ReductionOperation(ReductionOperations.Assign); // asign the sum to the target parameter
            prunedSubtreesReducer.TargetParameter.ActualName   = TotalNumberOfPrunedSubtreesParameterName;

            prunedTreesReducer = new DataReducer();
            prunedTreesReducer.ParameterToReduce.ActualName = PruningOperator.PrunedTreesParameter.ActualName;
            prunedTreesReducer.ReductionOperation.Value     = new ReductionOperation(ReductionOperations.Sum);
            prunedTreesReducer.TargetOperation.Value        = new ReductionOperation(ReductionOperations.Assign);
            prunedTreesReducer.TargetParameter.ActualName   = TotalNumberOfPrunedTreesParameterName;

            valuesCollector = new DataTableValuesCollector();
            valuesCollector.CollectedValues.Add(new LookupParameter <IntValue>(TotalNumberOfPrunedNodesParameterName));
            valuesCollector.CollectedValues.Add(new LookupParameter <IntValue>(TotalNumberOfPrunedSubtreesParameterName));
            valuesCollector.CollectedValues.Add(new LookupParameter <IntValue>(TotalNumberOfPrunedTreesParameterName));
            valuesCollector.DataTableParameter.ActualName = "Population pruning";

            resultsCollector = new ResultsCollector();
            resultsCollector.CollectedValues.Add(new LookupParameter <DataTable>("Population pruning"));
            resultsCollector.ResultsParameter.ActualName = ResultsParameterName;
        }
Ejemplo n.º 2
0
        private IQueryable <TDataModel> QuerySearch(DataReducer <TDataModel> reducer)
        {
            Checker.NotNullArgument(reducer, nameof(reducer));

            var reducerList = reducer.GetReducer();

            Checker.NotNullObject(reducerList, $"reducer.{nameof(reducer.GetReducer)}()");

            return(reducerList.Aggregate(Query, (q, w) => q.Where(w)));
        }
Ejemplo n.º 3
0
        public DataLimiterResult <TDataModel> LimitedSearch(DataReducer <TDataModel> reducer,
                                                            DataLimiter <TDataModel> limiter)
        {
            Checker.NotNullArgument(reducer, nameof(reducer));
            Checker.NotNullArgument(limiter, nameof(limiter));

            var result = QuerySearch(reducer);

            return(QueryLimitResult(limiter, result));
        }
Ejemplo n.º 4
0
        public AppStoreContainer()
        {
            var reducer = new CompositeReducer <AppState>()
                          .Part(s => s.SearchState, SearchReducer.GetReducer())
                          .Part(s => s.DiscoverState, DiscoverReducer.GetReducer())
                          .Part(s => s.AuthenticationState, AuthenticationReducer.GetReducer())
                          .Part(s => s.FavoriteState, FavouriteReducer.GetReducer())
                          .Part(s => s.DataState, DataReducer.GetReducer())
                          .Part(s => s.MovieDetailsState, MovieDetailsReducer.GetReducer())
                          .Part(s => s.ReviewsState, ReviewsReducer.GetReducer());

            Store = new Store <AppState>(reducer);
        }
Ejemplo n.º 5
0
 protected SymbolicDataAnalysisSingleObjectivePruningAnalyzer(SymbolicDataAnalysisSingleObjectivePruningAnalyzer original, Cloner cloner)
     : base(original, cloner)
 {
     if (original.prunedNodesReducer != null)
     {
         this.prunedNodesReducer = (DataReducer)original.prunedNodesReducer.Clone();
     }
     if (original.prunedSubtreesReducer != null)
     {
         this.prunedSubtreesReducer = (DataReducer)original.prunedSubtreesReducer.Clone();
     }
     if (original.prunedTreesReducer != null)
     {
         this.prunedTreesReducer = (DataReducer)original.prunedTreesReducer.Clone();
     }
     if (original.valuesCollector != null)
     {
         this.valuesCollector = (DataTableValuesCollector)original.valuesCollector.Clone();
     }
     if (original.resultsCollector != null)
     {
         this.resultsCollector = (ResultsCollector)original.resultsCollector.Clone();
     }
 }
 protected SymbolicDataAnalysisSingleObjectivePruningAnalyzer(SymbolicDataAnalysisSingleObjectivePruningAnalyzer original, Cloner cloner)
   : base(original, cloner) {
   if (original.prunedNodesReducer != null)
     this.prunedNodesReducer = (DataReducer)original.prunedNodesReducer.Clone();
   if (original.prunedSubtreesReducer != null)
     this.prunedSubtreesReducer = (DataReducer)original.prunedSubtreesReducer.Clone();
   if (original.prunedTreesReducer != null)
     this.prunedTreesReducer = (DataReducer)original.prunedTreesReducer.Clone();
   if (original.valuesCollector != null)
     this.valuesCollector = (DataTableValuesCollector)original.valuesCollector.Clone();
   if (original.resultsCollector != null)
     this.resultsCollector = (ResultsCollector)original.resultsCollector.Clone();
 }
    public AlpsOffspringSelectionGeneticAlgorithmMainLoop()
      : base() {
      Parameters.Add(new ValueLookupParameter<IRandom>("GlobalRandom", "A pseudo random number generator."));
      Parameters.Add(new ValueLookupParameter<IRandom>("LocalRandom", "A pseudo random number generator."));

      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>("EvaluatedSolutions", "The number of times solutions have been evaluated."));
      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The value which represents the quality of a solution."));
      Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem, otherwise false."));

      Parameters.Add(new ValueLookupParameter<IOperator>("Analyzer", "The operator used to analyze all individuals from all layers combined."));
      Parameters.Add(new ValueLookupParameter<IOperator>("LayerAnalyzer", "The operator used to analyze each layer."));

      Parameters.Add(new ValueLookupParameter<IntValue>("NumberOfLayers", "The number of layers."));
      Parameters.Add(new ValueLookupParameter<IntValue>("PopulationSize", "The size of the population of solutions in each layer."));
      Parameters.Add(new LookupParameter<IntValue>("CurrentPopulationSize", "The current size of the population."));

      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<IOperator>("Mutator", "The operator used to mutate solutions."));
      Parameters.Add(new ValueLookupParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution."));
      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<DoubleValue>("SuccessRatio", "The ratio of successful to total children that should be achieved."));
      Parameters.Add(new ValueLookupParameter<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 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."));

      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Age", "The age of individuals."));
      Parameters.Add(new ValueLookupParameter<IntValue>("AgeGap", "The frequency of reseeding the lowest layer and scaling factor for the age-limits for the layers."));
      Parameters.Add(new ValueLookupParameter<DoubleValue>("AgeInheritance", "A weight that determines the age of a child after crossover based on the older (1.0) and younger (0.0) parent."));
      Parameters.Add(new ValueLookupParameter<IntArray>("AgeLimits", "The maximum age an individual is allowed to reach in a certain layer."));

      Parameters.Add(new ValueLookupParameter<IntValue>("MatingPoolRange", "The range of sub - populations used for creating a mating pool. (1 = current + previous sub-population)"));
      Parameters.Add(new ValueLookupParameter<BoolValue>("ReduceToPopulationSize", "Reduce the CurrentPopulationSize after elder migration to PopulationSize"));

      Parameters.Add(new ValueLookupParameter<IOperator>("Terminator", "The termination criteria that defines if the algorithm should continue or stop"));


      var variableCreator = new VariableCreator() { Name = "Initialize" };
      var initLayerAnalyzerProcessor = new SubScopesProcessor();
      var layerVariableCreator = new VariableCreator() { Name = "Initialize Layer" };
      var initLayerAnalyzerPlaceholder = new Placeholder() { Name = "LayerAnalyzer (Placeholder)" };
      var layerResultCollector = new ResultsCollector() { Name = "Collect layer results" };
      var initAnalyzerPlaceholder = new Placeholder() { Name = "Analyzer (Placeholder)" };
      var resultsCollector = new ResultsCollector();
      var matingPoolCreator = new MatingPoolCreator() { Name = "Create Mating Pools" };
      var matingPoolProcessor = new UniformSubScopesProcessor() { Name = "Process Mating Pools" };
      var initializeLayer = new Assigner() { Name = "Reset LayerEvaluatedSolutions" };
      var mainOperator = new AlpsOffspringSelectionGeneticAlgorithmMainOperator();
      var generationsIcrementor = new IntCounter() { Name = "Increment Generations" };
      var evaluatedSolutionsReducer = new DataReducer() { Name = "Increment EvaluatedSolutions" };
      var eldersEmigrator = CreateEldersEmigrator();
      var layerOpener = CreateLayerOpener();
      var layerReseeder = CreateReseeder();
      var layerAnalyzerProcessor = new UniformSubScopesProcessor();
      var layerAnalyzerPlaceholder = new Placeholder() { Name = "LayerAnalyzer (Placeholder)" };
      var analyzerPlaceholder = new Placeholder() { Name = "Analyzer (Placeholder)" };
      var termination = new TerminationOperator();

      OperatorGraph.InitialOperator = variableCreator;

      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0)));
      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("OpenLayers", new IntValue(1)));
      variableCreator.Successor = initLayerAnalyzerProcessor;

      initLayerAnalyzerProcessor.Operators.Add(layerVariableCreator);
      initLayerAnalyzerProcessor.Successor = initAnalyzerPlaceholder;

      layerVariableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Layer", new IntValue(0)));
      layerVariableCreator.CollectedValues.Add(new ValueParameter<ResultCollection>("LayerResults"));
      layerVariableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("SelectionPressure", new DoubleValue(0)));
      layerVariableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("CurrentSuccessRatio", new DoubleValue(0)));
      layerVariableCreator.Successor = initLayerAnalyzerPlaceholder;

      initLayerAnalyzerPlaceholder.OperatorParameter.ActualName = LayerAnalyzerParameter.Name;
      initLayerAnalyzerPlaceholder.Successor = layerResultCollector;

      layerResultCollector.ResultsParameter.ActualName = "LayerResults";
      layerResultCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Selection Pressure", "Displays the rising selection pressure during a generation.", "SelectionPressure"));
      layerResultCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Success Ratio", "Indicates how many successful children were already found during a generation (relative to the population size).", "CurrentSuccessRatio"));
      layerResultCollector.Successor = null;

      initAnalyzerPlaceholder.OperatorParameter.ActualName = AnalyzerParameter.Name;
      initAnalyzerPlaceholder.Successor = resultsCollector;

      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Generations"));
      resultsCollector.CollectedValues.Add(new ScopeTreeLookupParameter<ResultCollection>("LayerResults", "Result set for each Layer", "LayerResults"));
      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("OpenLayers"));
      resultsCollector.CopyValue = new BoolValue(false);
      resultsCollector.Successor = matingPoolCreator;

      matingPoolCreator.MatingPoolRangeParameter.Value = null;
      matingPoolCreator.MatingPoolRangeParameter.ActualName = MatingPoolRangeParameter.Name;
      matingPoolCreator.Successor = matingPoolProcessor;

      matingPoolProcessor.Parallel.Value = true;
      matingPoolProcessor.Operator = initializeLayer;
      matingPoolProcessor.Successor = generationsIcrementor;

      initializeLayer.LeftSideParameter.ActualName = "LayerEvaluatedSolutions";
      initializeLayer.RightSideParameter.Value = new IntValue(0);
      initializeLayer.Successor = mainOperator;

      mainOperator.RandomParameter.ActualName = LocalRandomParameter.Name;
      mainOperator.EvaluatorParameter.ActualName = EvaluatorParameter.Name;
      mainOperator.EvaluatedSolutionsParameter.ActualName = "LayerEvaluatedSolutions";
      mainOperator.QualityParameter.ActualName = QualityParameter.Name;
      mainOperator.MaximizationParameter.ActualName = MaximizationParameter.Name;
      mainOperator.PopulationSizeParameter.ActualName = PopulationSizeParameter.Name;
      mainOperator.SelectorParameter.ActualName = SelectorParameter.Name;
      mainOperator.CrossoverParameter.ActualName = CrossoverParameter.Name;
      mainOperator.MutatorParameter.ActualName = MutatorParameter.ActualName;
      mainOperator.MutationProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
      mainOperator.ElitesParameter.ActualName = ElitesParameter.Name;
      mainOperator.ReevaluateElitesParameter.ActualName = ReevaluateElitesParameter.Name;
      mainOperator.ComparisonFactorParameter.ActualName = ComparisonFactorParameter.Name;
      mainOperator.SuccessRatioParameter.ActualName = SuccessRatioParameter.Name;
      mainOperator.CurrentSuccessRatioParameter.ActualName = "CurrentSuccessRatio";
      mainOperator.SelectionPressureParameter.ActualName = "SelectionPressure";
      mainOperator.MaximumSelectionPressureParameter.ActualName = MaximumSelectionPressureParameter.Name;
      mainOperator.OffspringSelectionBeforeMutationParameter.ActualName = OffspringSelectionBeforeMutationParameter.Name;
      mainOperator.FillPopulationWithParentsParameter.ActualName = FillPopulationWithParentsParameter.Name;
      mainOperator.AgeParameter.ActualName = AgeParameter.Name;
      mainOperator.AgeInheritanceParameter.ActualName = AgeInheritanceParameter.Name;
      mainOperator.AgeIncrementParameter.Value = new DoubleValue(1.0);
      mainOperator.Successor = null;

      generationsIcrementor.ValueParameter.ActualName = "Generations";
      generationsIcrementor.Increment = new IntValue(1);
      generationsIcrementor.Successor = evaluatedSolutionsReducer;

      evaluatedSolutionsReducer.ParameterToReduce.ActualName = "LayerEvaluatedSolutions";
      evaluatedSolutionsReducer.TargetParameter.ActualName = EvaluatedSolutionsParameter.Name;
      evaluatedSolutionsReducer.ReductionOperation.Value = new ReductionOperation(ReductionOperations.Sum);
      evaluatedSolutionsReducer.TargetOperation.Value = new ReductionOperation(ReductionOperations.Sum);
      evaluatedSolutionsReducer.Successor = eldersEmigrator;

      eldersEmigrator.Successor = layerOpener;

      layerOpener.Successor = layerReseeder;

      layerReseeder.Successor = layerAnalyzerProcessor;

      layerAnalyzerProcessor.Operator = layerAnalyzerPlaceholder;
      layerAnalyzerProcessor.Successor = analyzerPlaceholder;

      layerAnalyzerPlaceholder.OperatorParameter.ActualName = LayerAnalyzerParameter.Name;

      analyzerPlaceholder.OperatorParameter.ActualName = AnalyzerParameter.Name;
      analyzerPlaceholder.Successor = termination;

      termination.TerminatorParameter.ActualName = TerminatorParameter.Name;
      termination.ContinueBranch = matingPoolCreator;
    }
    public AlpsGeneticAlgorithm()
      : base() {
      #region Add parameters
      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 FixedValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze all individuals from all layers combined.", new MultiAnalyzer()));
      Parameters.Add(new FixedValueParameter<MultiAnalyzer>("LayerAnalyzer", "The operator used to analyze each layer.", new MultiAnalyzer()));

      Parameters.Add(new ValueParameter<IntValue>("NumberOfLayers", "The number of layers.", new IntValue(10)));
      Parameters.Add(new ValueParameter<IntValue>("PopulationSize", "The size of the population of solutions in each layer.", 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 OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate 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 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 ValueParameter<BoolValue>("PlusSelection", "Include the parents in the selection of the invividuals for the next generation.", new BoolValue(false)));

      Parameters.Add(new ValueParameter<EnumValue<AgingScheme>>("AgingScheme", "The aging scheme for setting the age-limits for the layers.", new EnumValue<AgingScheme>(ALPS.AgingScheme.Polynomial)));
      Parameters.Add(new ValueParameter<IntValue>("AgeGap", "The frequency of reseeding the lowest layer and scaling factor for the age-limits for the layers.", new IntValue(20)));
      Parameters.Add(new ValueParameter<DoubleValue>("AgeInheritance", "A weight that determines the age of a child after crossover based on the older (1.0) and younger (0.0) parent.", new DoubleValue(1.0)) { Hidden = true });
      Parameters.Add(new ValueParameter<IntArray>("AgeLimits", "The maximum age an individual is allowed to reach in a certain layer.", new IntArray(new int[0])) { Hidden = true });

      Parameters.Add(new ValueParameter<IntValue>("MatingPoolRange", "The range of layers used for creating a mating pool. (1 = current + previous layer)", new IntValue(1)) { Hidden = true });
      Parameters.Add(new ValueParameter<BoolValue>("ReduceToPopulationSize", "Reduce the CurrentPopulationSize after elder migration to PopulationSize", new BoolValue(true)) { Hidden = true });

      Parameters.Add(new ValueParameter<MultiTerminator>("Terminator", "The termination criteria that defines if the algorithm should continue or stop.", new MultiTerminator()));
      #endregion

      #region Create operators
      var globalRandomCreator = new RandomCreator();
      var layer0Creator = new SubScopesCreator() { Name = "Create Layer Zero" };
      var layer0Processor = new SubScopesProcessor();
      var localRandomCreator = new LocalRandomCreator();
      var layerSolutionsCreator = new SolutionsCreator();
      var initializeAgeProcessor = new UniformSubScopesProcessor();
      var initializeAge = new VariableCreator() { Name = "Initialize Age" };
      var initializeCurrentPopulationSize = new SubScopesCounter() { Name = "Initialize CurrentPopulationCounter" };
      var initializeLocalEvaluatedSolutions = new Assigner() { Name = "Initialize LayerEvaluatedSolutions" };
      var initializeGlobalEvaluatedSolutions = new DataReducer() { Name = "Initialize EvaluatedSolutions" };
      var resultsCollector = new ResultsCollector();
      var mainLoop = new AlpsGeneticAlgorithmMainLoop();
      #endregion

      #region Create and parameterize operator graph
      OperatorGraph.InitialOperator = globalRandomCreator;

      globalRandomCreator.RandomParameter.ActualName = "GlobalRandom";
      globalRandomCreator.SeedParameter.Value = null;
      globalRandomCreator.SeedParameter.ActualName = SeedParameter.Name;
      globalRandomCreator.SetSeedRandomlyParameter.Value = null;
      globalRandomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameter.Name;
      globalRandomCreator.Successor = layer0Creator;

      layer0Creator.NumberOfSubScopesParameter.Value = new IntValue(1);
      layer0Creator.Successor = layer0Processor;

      layer0Processor.Operators.Add(localRandomCreator);
      layer0Processor.Successor = initializeGlobalEvaluatedSolutions;

      localRandomCreator.Successor = layerSolutionsCreator;

      layerSolutionsCreator.NumberOfSolutionsParameter.ActualName = PopulationSizeParameter.Name;
      layerSolutionsCreator.Successor = initializeAgeProcessor;

      initializeAgeProcessor.Operator = initializeAge;
      initializeAgeProcessor.Successor = initializeCurrentPopulationSize;

      initializeCurrentPopulationSize.ValueParameter.ActualName = "CurrentPopulationSize";
      initializeCurrentPopulationSize.Successor = initializeLocalEvaluatedSolutions;

      initializeAge.CollectedValues.Add(new ValueParameter<DoubleValue>("Age", new DoubleValue(0)));
      initializeAge.Successor = null;

      initializeLocalEvaluatedSolutions.LeftSideParameter.ActualName = "LayerEvaluatedSolutions";
      initializeLocalEvaluatedSolutions.RightSideParameter.ActualName = "CurrentPopulationSize";
      initializeLocalEvaluatedSolutions.Successor = null;

      initializeGlobalEvaluatedSolutions.ReductionOperation.Value.Value = ReductionOperations.Sum;
      initializeGlobalEvaluatedSolutions.TargetOperation.Value.Value = ReductionOperations.Assign;
      initializeGlobalEvaluatedSolutions.ParameterToReduce.ActualName = "LayerEvaluatedSolutions";
      initializeGlobalEvaluatedSolutions.TargetParameter.ActualName = "EvaluatedSolutions";
      initializeGlobalEvaluatedSolutions.Successor = resultsCollector;

      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Solutions", null, "EvaluatedSolutions"));
      resultsCollector.Successor = mainLoop;

      mainLoop.GlobalRandomParameter.ActualName = "GlobalRandom";
      mainLoop.LocalRandomParameter.ActualName = localRandomCreator.LocalRandomParameter.Name;
      mainLoop.EvaluatedSolutionsParameter.ActualName = "EvaluatedSolutions";
      mainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name;
      mainLoop.LayerAnalyzerParameter.ActualName = LayerAnalyzerParameter.Name;
      mainLoop.NumberOfLayersParameter.ActualName = NumberOfLayersParameter.Name;
      mainLoop.PopulationSizeParameter.ActualName = PopulationSizeParameter.Name;
      mainLoop.CurrentPopulationSizeParameter.ActualName = "CurrentPopulationSize";
      mainLoop.SelectorParameter.ActualName = SelectorParameter.Name;
      mainLoop.CrossoverParameter.ActualName = CrossoverParameter.Name;
      mainLoop.MutatorParameter.ActualName = MutatorParameter.Name;
      mainLoop.MutationProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
      mainLoop.ElitesParameter.ActualName = ElitesParameter.Name;
      mainLoop.ReevaluateElitesParameter.ActualName = ReevaluateElitesParameter.Name;
      mainLoop.PlusSelectionParameter.ActualName = PlusSelectionParameter.Name;
      mainLoop.AgeParameter.ActualName = "Age";
      mainLoop.AgeGapParameter.ActualName = AgeGapParameter.Name;
      mainLoop.AgeInheritanceParameter.ActualName = AgeInheritanceParameter.Name;
      mainLoop.AgeLimitsParameter.ActualName = AgeLimitsParameter.Name;
      mainLoop.MatingPoolRangeParameter.ActualName = MatingPoolRangeParameter.Name;
      mainLoop.ReduceToPopulationSizeParameter.ActualName = ReduceToPopulationSizeParameter.Name;
      mainLoop.TerminatorParameter.ActualName = TerminatorParameter.Name;
      #endregion

      #region Set selectors
      foreach (var selector in ApplicationManager.Manager.GetInstances<ISelector>().Where(s => !(s is IMultiObjectiveSelector)).OrderBy(s => Name))
        SelectorParameter.ValidValues.Add(selector);
      var defaultSelector = SelectorParameter.ValidValues.OfType<GeneralizedRankSelector>().FirstOrDefault();
      if (defaultSelector != null) {
        defaultSelector.PressureParameter.Value = new DoubleValue(4.0);
        SelectorParameter.Value = defaultSelector;
      }
      #endregion

      #region Create analyzers
      qualityAnalyzer = new BestAverageWorstQualityAnalyzer();
      layerQualityAnalyzer = new BestAverageWorstQualityAnalyzer();
      ageAnalyzer = new OldestAverageYoungestAgeAnalyzer();
      layerAgeAnalyzer = new OldestAverageYoungestAgeAnalyzer();
      ageDistributionAnalyzer = new AgeDistributionAnalyzer();
      layerAgeDistributionAnalyzer = new AgeDistributionAnalyzer();
      #endregion

      #region Create terminators
      generationsTerminator = new ComparisonTerminator<IntValue>("Generations", ComparisonType.Less, new IntValue(1000)) { Name = "Generations" };
      evaluationsTerminator = new ComparisonTerminator<IntValue>("EvaluatedSolutions", ComparisonType.Less, new IntValue(int.MaxValue)) { Name = "Evaluations" };
      qualityTerminator = new SingleObjectiveQualityTerminator() { Name = "Quality" };
      executionTimeTerminator = new ExecutionTimeTerminator(this, new TimeSpanValue(TimeSpan.FromMinutes(5)));
      #endregion

      #region Parameterize
      UpdateAnalyzers();
      ParameterizeAnalyzers();

      ParameterizeSelectors();

      UpdateTerminators();

      ParameterizeAgeLimits();
      #endregion

      Initialize();
    }
Ejemplo n.º 9
0
 public DataLimiterResult <TDataModel> LimitedSearch(DataReducer <TDataModel> reducer,
                                                     DataLimiter <TDataModel> limiter) => _base.LimitedSearch(reducer, limiter);
Ejemplo n.º 10
0
 public void BulkRemoveFromSearch(DataReducer <TDataModel> reducer) =>
 _base.BulkRemoveFromSearch(reducer);
Ejemplo n.º 11
0
        public ScatterSearch()
            : base()
        {
            #region Create parameters
            Parameters.Add(new ValueParameter <MultiAnalyzer>("Analyzer", "The analyzer used to analyze each iteration.", new MultiAnalyzer()));
            Parameters.Add(new ConstrainedValueParameter <ICrossover>("Crossover", "The operator used to cross solutions."));
            Parameters.Add(new ValueParameter <BoolValue>("ExecutePathRelinking", "True if path relinking should be executed instead of crossover, otherwise false.", new BoolValue(false)));
            Parameters.Add(new ConstrainedValueParameter <IImprovementOperator>("Improver", "The operator used to improve solutions."));
            Parameters.Add(new ValueParameter <IntValue>("MaximumIterations", "The maximum number of iterations which should be processed.", new IntValue(100)));
            Parameters.Add(new ValueParameter <IntValue>("NumberOfHighQualitySolutions", "The number of high quality solutions in the reference set.", new IntValue(5)));
            Parameters.Add(new ConstrainedValueParameter <IPathRelinker>("PathRelinker", "The operator used to execute path relinking."));
            Parameters.Add(new ValueParameter <IntValue>("PopulationSize", "The size of the population of solutions.", new IntValue(50)));
            Parameters.Add(new ValueParameter <IntValue>("ReferenceSetSize", "The size of the reference set.", new IntValue(20)));
            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 ConstrainedValueParameter <ISolutionSimilarityCalculator>("SimilarityCalculator", "The operator used to calculate the similarity between two solutions."));
            #endregion

            #region Create operators
            RandomCreator             randomCreator             = new RandomCreator();
            SolutionsCreator          solutionsCreator          = new SolutionsCreator();
            UniformSubScopesProcessor uniformSubScopesProcessor = new UniformSubScopesProcessor();
            Placeholder           solutionEvaluator             = new Placeholder();
            Placeholder           solutionImprover = new Placeholder();
            VariableCreator       variableCreator  = new VariableCreator();
            DataReducer           dataReducer      = new DataReducer();
            ResultsCollector      resultsCollector = new ResultsCollector();
            BestSelector          bestSelector     = new BestSelector();
            ScatterSearchMainLoop mainLoop         = new ScatterSearchMainLoop();
            #endregion

            #region Create operator graph
            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 = solutionsCreator;

            solutionsCreator.Name = "DiversificationGenerationMethod";
            solutionsCreator.NumberOfSolutionsParameter.ActualName = "PopulationSize";
            solutionsCreator.Successor = uniformSubScopesProcessor;

            uniformSubScopesProcessor.Operator = solutionImprover;
            uniformSubScopesProcessor.ParallelParameter.Value = new BoolValue(true);
            uniformSubScopesProcessor.Successor = variableCreator;

            solutionImprover.Name = "SolutionImprover";
            solutionImprover.OperatorParameter.ActualName = "Improver";
            solutionImprover.Successor = solutionEvaluator;

            solutionEvaluator.Name = "SolutionEvaluator";
            solutionEvaluator.OperatorParameter.ActualName = "Evaluator";
            solutionEvaluator.Successor = null;

            variableCreator.Name = "Initialize EvaluatedSolutions";
            variableCreator.CollectedValues.Add(new ValueParameter <IntValue>("EvaluatedSolutions", new IntValue()));
            variableCreator.Successor = dataReducer;

            dataReducer.Name = "Increment EvaluatedSolutions";
            dataReducer.ParameterToReduce.ActualName = "LocalEvaluatedSolutions";
            dataReducer.TargetParameter.ActualName   = "EvaluatedSolutions";
            dataReducer.ReductionOperation.Value     = new ReductionOperation(ReductionOperations.Sum);
            dataReducer.TargetOperation.Value        = new ReductionOperation(ReductionOperations.Sum);
            dataReducer.Successor = resultsCollector;

            resultsCollector.Name = "ResultsCollector";
            resultsCollector.CollectedValues.Add(new LookupParameter <IntValue>("EvaluatedSolutions", null, "EvaluatedSolutions"));
            resultsCollector.Successor = bestSelector;

            bestSelector.NumberOfSelectedSubScopesParameter.ActualName = NumberOfHighQualitySolutionsParameter.Name;
            bestSelector.CopySelected = new BoolValue(false);
            bestSelector.Successor    = mainLoop;

            mainLoop.MaximumIterationsParameter.ActualName            = MaximumIterationsParameter.Name;
            mainLoop.RandomParameter.ActualName                       = randomCreator.RandomParameter.ActualName;
            mainLoop.ResultsParameter.ActualName                      = "Results";
            mainLoop.AnalyzerParameter.ActualName                     = AnalyzerParameter.Name;
            mainLoop.IterationsParameter.ActualName                   = "Iterations";
            mainLoop.EvaluatedSolutionsParameter.ActualName           = "EvaluatedSolutions";
            mainLoop.CrossoverParameter.ActualName                    = CrossoverParameter.Name;
            mainLoop.PopulationSizeParameter.ActualName               = PopulationSizeParameter.Name;
            mainLoop.NumberOfHighQualitySolutionsParameter.ActualName = NumberOfHighQualitySolutionsParameter.Name;
            mainLoop.Successor = null;
            #endregion

            qualityAnalyzer = new BestAverageWorstQualityAnalyzer();
            ParameterizeAnalyzers();
            UpdateAnalyzers();

            Initialize();
        }
Ejemplo n.º 12
0
 public IEnumerable <TDataModel> Search(DataReducer <TDataModel> reducer) => _base.Search(reducer);
Ejemplo n.º 13
0
    public ScatterSearch()
      : base() {
      #region Create parameters
      Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The analyzer used to analyze each iteration.", new MultiAnalyzer()));
      Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions."));
      Parameters.Add(new ValueParameter<BoolValue>("ExecutePathRelinking", "True if path relinking should be executed instead of crossover, otherwise false.", new BoolValue(false)));
      Parameters.Add(new ConstrainedValueParameter<IImprovementOperator>("Improver", "The operator used to improve solutions."));
      Parameters.Add(new ValueParameter<IntValue>("MaximumIterations", "The maximum number of iterations which should be processed.", new IntValue(100)));
      Parameters.Add(new ValueParameter<IntValue>("NumberOfHighQualitySolutions", "The number of high quality solutions in the reference set.", new IntValue(5)));
      Parameters.Add(new ConstrainedValueParameter<IPathRelinker>("PathRelinker", "The operator used to execute path relinking."));
      Parameters.Add(new ValueParameter<IntValue>("PopulationSize", "The size of the population of solutions.", new IntValue(50)));
      Parameters.Add(new ValueParameter<IntValue>("ReferenceSetSize", "The size of the reference set.", new IntValue(20)));
      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 ConstrainedValueParameter<ISolutionSimilarityCalculator>("SimilarityCalculator", "The operator used to calculate the similarity between two solutions."));
      #endregion

      #region Create operators
      RandomCreator randomCreator = new RandomCreator();
      SolutionsCreator solutionsCreator = new SolutionsCreator();
      UniformSubScopesProcessor uniformSubScopesProcessor = new UniformSubScopesProcessor();
      Placeholder solutionEvaluator = new Placeholder();
      Placeholder solutionImprover = new Placeholder();
      VariableCreator variableCreator = new VariableCreator();
      DataReducer dataReducer = new DataReducer();
      ResultsCollector resultsCollector = new ResultsCollector();
      BestSelector bestSelector = new BestSelector();
      ScatterSearchMainLoop mainLoop = new ScatterSearchMainLoop();
      #endregion

      #region Create operator graph
      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 = solutionsCreator;

      solutionsCreator.Name = "DiversificationGenerationMethod";
      solutionsCreator.NumberOfSolutionsParameter.ActualName = "PopulationSize";
      solutionsCreator.Successor = uniformSubScopesProcessor;

      uniformSubScopesProcessor.Operator = solutionImprover;
      uniformSubScopesProcessor.ParallelParameter.Value = new BoolValue(true);
      uniformSubScopesProcessor.Successor = variableCreator;

      solutionImprover.Name = "SolutionImprover";
      solutionImprover.OperatorParameter.ActualName = "Improver";
      solutionImprover.Successor = solutionEvaluator;

      solutionEvaluator.Name = "SolutionEvaluator";
      solutionEvaluator.OperatorParameter.ActualName = "Evaluator";
      solutionEvaluator.Successor = null;

      variableCreator.Name = "Initialize EvaluatedSolutions";
      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedSolutions", new IntValue()));
      variableCreator.Successor = dataReducer;

      dataReducer.Name = "Increment EvaluatedSolutions";
      dataReducer.ParameterToReduce.ActualName = "LocalEvaluatedSolutions";
      dataReducer.TargetParameter.ActualName = "EvaluatedSolutions";
      dataReducer.ReductionOperation.Value = new ReductionOperation(ReductionOperations.Sum);
      dataReducer.TargetOperation.Value = new ReductionOperation(ReductionOperations.Sum);
      dataReducer.Successor = resultsCollector;

      resultsCollector.Name = "ResultsCollector";
      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("EvaluatedSolutions", null, "EvaluatedSolutions"));
      resultsCollector.Successor = bestSelector;

      bestSelector.NumberOfSelectedSubScopesParameter.ActualName = NumberOfHighQualitySolutionsParameter.Name;
      bestSelector.CopySelected = new BoolValue(false);
      bestSelector.Successor = mainLoop;

      mainLoop.MaximumIterationsParameter.ActualName = MaximumIterationsParameter.Name;
      mainLoop.RandomParameter.ActualName = randomCreator.RandomParameter.ActualName;
      mainLoop.ResultsParameter.ActualName = "Results";
      mainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name;
      mainLoop.IterationsParameter.ActualName = "Iterations";
      mainLoop.EvaluatedSolutionsParameter.ActualName = "EvaluatedSolutions";
      mainLoop.CrossoverParameter.ActualName = CrossoverParameter.Name;
      mainLoop.PopulationSizeParameter.ActualName = PopulationSizeParameter.Name;
      mainLoop.NumberOfHighQualitySolutionsParameter.ActualName = NumberOfHighQualitySolutionsParameter.Name;
      mainLoop.Successor = null;
      #endregion

      qualityAnalyzer = new BestAverageWorstQualityAnalyzer();
      ParameterizeAnalyzers();
      UpdateAnalyzers();

      Initialize();
    }
Ejemplo n.º 14
0
        public AlpsOffspringSelectionGeneticAlgorithm()
            : base()
        {
            #region Add parameters
            Parameters.Add(new FixedValueParameter <IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
            Parameters.Add(new FixedValueParameter <BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));

            Parameters.Add(new FixedValueParameter <MultiAnalyzer>("Analyzer", "The operator used to analyze all individuals from all layers combined.", new MultiAnalyzer()));
            Parameters.Add(new FixedValueParameter <MultiAnalyzer>("LayerAnalyzer", "The operator used to analyze each layer.", new MultiAnalyzer()));

            Parameters.Add(new FixedValueParameter <IntValue>("NumberOfLayers", "The number of layers.", new IntValue(10)));
            Parameters.Add(new FixedValueParameter <IntValue>("PopulationSize", "The size of the population of solutions in each layer.", 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 ConstrainedValueParameter <IManipulator>("Mutator", "The operator used to mutate solutions."));
            Parameters.Add(new FixedValueParameter <PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new PercentValue(0.05)));
            Parameters.Add(new FixedValueParameter <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 FixedValueParameter <DoubleValue>("SuccessRatio", "The ratio of successful to total children that should be achieved.", new DoubleValue(1)));
            Parameters.Add(new FixedValueParameter <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].", new DoubleValue(1)));
            Parameters.Add(new FixedValueParameter <DoubleValue>("MaximumSelectionPressure", "The maximum selection pressure that terminates the algorithm.", new DoubleValue(100)));
            Parameters.Add(new FixedValueParameter <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 FixedValueParameter <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 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(false))
            {
                Hidden = true
            });

            Parameters.Add(new FixedValueParameter <EnumValue <AgingScheme> >("AgingScheme", "The aging scheme for setting the age-limits for the layers.", new EnumValue <AgingScheme>(ALPS.AgingScheme.Polynomial)));
            Parameters.Add(new FixedValueParameter <IntValue>("AgeGap", "The frequency of reseeding the lowest layer and scaling factor for the age-limits for the layers.", new IntValue(20)));
            Parameters.Add(new FixedValueParameter <DoubleValue>("AgeInheritance", "A weight that determines the age of a child after crossover based on the older (1.0) and younger (0.0) parent.", new DoubleValue(1.0))
            {
                Hidden = true
            });
            Parameters.Add(new FixedValueParameter <IntArray>("AgeLimits", "The maximum age an individual is allowed to reach in a certain layer.", new IntArray(new int[0]))
            {
                Hidden = true
            });

            Parameters.Add(new FixedValueParameter <IntValue>("MatingPoolRange", "The range of layers used for creating a mating pool. (1 = current + previous layer)", new IntValue(1))
            {
                Hidden = true
            });
            Parameters.Add(new FixedValueParameter <BoolValue>("ReduceToPopulationSize", "Reduce the CurrentPopulationSize after elder migration to PopulationSize", new BoolValue(true))
            {
                Hidden = true
            });

            Parameters.Add(new FixedValueParameter <MultiTerminator>("Terminator", "The termination criteria that defines if the algorithm should continue or stop.", new MultiTerminator()));
            #endregion

            #region Create operators
            var globalRandomCreator = new RandomCreator();
            var layer0Creator       = new SubScopesCreator()
            {
                Name = "Create Layer Zero"
            };
            var layer0Processor        = new SubScopesProcessor();
            var localRandomCreator     = new LocalRandomCreator();
            var layerSolutionsCreator  = new SolutionsCreator();
            var initializeAgeProcessor = new UniformSubScopesProcessor();
            var initializeAge          = new VariableCreator()
            {
                Name = "Initialize Age"
            };
            var initializeCurrentPopulationSize = new SubScopesCounter()
            {
                Name = "Initialize CurrentPopulationCounter"
            };
            var initializeLocalEvaluatedSolutions = new Assigner()
            {
                Name = "Initialize LayerEvaluatedSolutions"
            };
            var initializeGlobalEvaluatedSolutions = new DataReducer()
            {
                Name = "Initialize EvaluatedSolutions"
            };
            var resultsCollector = new ResultsCollector();
            var mainLoop         = new AlpsOffspringSelectionGeneticAlgorithmMainLoop();
            #endregion

            #region Create and parameterize operator graph
            OperatorGraph.InitialOperator = globalRandomCreator;

            globalRandomCreator.RandomParameter.ActualName          = "GlobalRandom";
            globalRandomCreator.SeedParameter.Value                 = null;
            globalRandomCreator.SeedParameter.ActualName            = SeedParameter.Name;
            globalRandomCreator.SetSeedRandomlyParameter.Value      = null;
            globalRandomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameter.Name;
            globalRandomCreator.Successor = layer0Creator;

            layer0Creator.NumberOfSubScopesParameter.Value = new IntValue(1);
            layer0Creator.Successor = layer0Processor;

            layer0Processor.Operators.Add(localRandomCreator);
            layer0Processor.Successor = initializeGlobalEvaluatedSolutions;

            localRandomCreator.Successor = layerSolutionsCreator;

            layerSolutionsCreator.NumberOfSolutionsParameter.ActualName = PopulationSizeParameter.Name;
            layerSolutionsCreator.Successor = initializeAgeProcessor;

            initializeAgeProcessor.Operator  = initializeAge;
            initializeAgeProcessor.Successor = initializeCurrentPopulationSize;

            initializeCurrentPopulationSize.ValueParameter.ActualName = "CurrentPopulationSize";
            initializeCurrentPopulationSize.Successor = initializeLocalEvaluatedSolutions;

            initializeAge.CollectedValues.Add(new ValueParameter <DoubleValue>("Age", new DoubleValue(0)));
            initializeAge.Successor = null;

            initializeLocalEvaluatedSolutions.LeftSideParameter.ActualName  = "LayerEvaluatedSolutions";
            initializeLocalEvaluatedSolutions.RightSideParameter.ActualName = "CurrentPopulationSize";
            initializeLocalEvaluatedSolutions.Successor = null;

            initializeGlobalEvaluatedSolutions.ReductionOperation.Value.Value = ReductionOperations.Sum;
            initializeGlobalEvaluatedSolutions.TargetOperation.Value.Value    = ReductionOperations.Assign;
            initializeGlobalEvaluatedSolutions.ParameterToReduce.ActualName   = "LayerEvaluatedSolutions";
            initializeGlobalEvaluatedSolutions.TargetParameter.ActualName     = "EvaluatedSolutions";
            initializeGlobalEvaluatedSolutions.Successor = resultsCollector;

            resultsCollector.CollectedValues.Add(new LookupParameter <IntValue>("Evaluated Solutions", null, "EvaluatedSolutions"));
            resultsCollector.Successor = mainLoop;

            mainLoop.GlobalRandomParameter.ActualName          = "GlobalRandom";
            mainLoop.LocalRandomParameter.ActualName           = localRandomCreator.LocalRandomParameter.Name;
            mainLoop.EvaluatedSolutionsParameter.ActualName    = "EvaluatedSolutions";
            mainLoop.AnalyzerParameter.ActualName              = AnalyzerParameter.Name;
            mainLoop.LayerAnalyzerParameter.ActualName         = LayerAnalyzerParameter.Name;
            mainLoop.NumberOfLayersParameter.ActualName        = NumberOfLayersParameter.Name;
            mainLoop.PopulationSizeParameter.ActualName        = PopulationSizeParameter.Name;
            mainLoop.CurrentPopulationSizeParameter.ActualName = "CurrentPopulationSize";
            mainLoop.SelectorParameter.ActualName              = SelectorParameter.Name;
            mainLoop.CrossoverParameter.ActualName             = CrossoverParameter.Name;
            mainLoop.MutatorParameter.ActualName             = MutatorParameter.Name;
            mainLoop.MutationProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
            mainLoop.ElitesParameter.ActualName                           = ElitesParameter.Name;
            mainLoop.ReevaluateElitesParameter.ActualName                 = ReevaluateElitesParameter.Name;
            mainLoop.SuccessRatioParameter.ActualName                     = SuccessRatioParameter.Name;
            mainLoop.ComparisonFactorParameter.ActualName                 = ComparisonFactorParameter.Name;
            mainLoop.MaximumSelectionPressureParameter.ActualName         = MaximumSelectionPressureParameter.Name;
            mainLoop.OffspringSelectionBeforeMutationParameter.ActualName = OffspringSelectionBeforeMutationParameter.Name;
            mainLoop.FillPopulationWithParentsParameter.ActualName        = FillPopulationWithParentsParameter.Name;
            mainLoop.AgeParameter.ActualName                    = "Age";
            mainLoop.AgeGapParameter.ActualName                 = AgeGapParameter.Name;
            mainLoop.AgeInheritanceParameter.ActualName         = AgeInheritanceParameter.Name;
            mainLoop.AgeLimitsParameter.ActualName              = AgeLimitsParameter.Name;
            mainLoop.MatingPoolRangeParameter.ActualName        = MatingPoolRangeParameter.Name;
            mainLoop.ReduceToPopulationSizeParameter.ActualName = ReduceToPopulationSizeParameter.Name;
            mainLoop.TerminatorParameter.ActualName             = TerminatorParameter.Name;
            #endregion

            #region Set operators
            foreach (var selector in ApplicationManager.Manager.GetInstances <ISelector>().Where(s => !(s is IMultiObjectiveSelector)).OrderBy(s => Name))
            {
                SelectorParameter.ValidValues.Add(selector);
            }
            var defaultSelector = SelectorParameter.ValidValues.OfType <GeneralizedRankSelector>().FirstOrDefault();
            if (defaultSelector != null)
            {
                defaultSelector.PressureParameter.Value = new DoubleValue(4.0);
                SelectorParameter.Value = defaultSelector;
            }
            #endregion

            #region Create analyzers
            qualityAnalyzer                = new BestAverageWorstQualityAnalyzer();
            layerQualityAnalyzer           = new BestAverageWorstQualityAnalyzer();
            ageAnalyzer                    = new OldestAverageYoungestAgeAnalyzer();
            layerAgeAnalyzer               = new OldestAverageYoungestAgeAnalyzer();
            ageDistributionAnalyzer        = new AgeDistributionAnalyzer();
            layerAgeDistributionAnalyzer   = new AgeDistributionAnalyzer();
            selectionPressureAnalyzer      = new ValueAnalyzer();
            layerSelectionPressureAnalyzer = new ValueAnalyzer();
            currentSuccessRatioAnalyzer    = new ValueAnalyzer();
            #endregion

            #region Create terminators
            generationsTerminator = new ComparisonTerminator <IntValue>("Generations", ComparisonType.Less, new IntValue(1000))
            {
                Name = "Generations"
            };
            evaluationsTerminator = new ComparisonTerminator <IntValue>("EvaluatedSolutions", ComparisonType.Less, new IntValue(int.MaxValue))
            {
                Name = "Evaluations"
            };
            qualityTerminator = new SingleObjectiveQualityTerminator()
            {
                Name = "Quality"
            };
            executionTimeTerminator = new ExecutionTimeTerminator(this, new TimeSpanValue(TimeSpan.FromMinutes(5)));
            #endregion

            #region Parameterize
            UpdateAnalyzers();
            ParameterizeAnalyzers();

            ParameterizeSelectors();

            UpdateTerminators();

            ParameterizeAgeLimits();
            #endregion

            Initialize();
        }
    private void InitializeOperators() {
      prunedNodesReducer = new DataReducer();
      prunedNodesReducer.ParameterToReduce.ActualName = PruningOperator.PrunedNodesParameter.ActualName;
      prunedNodesReducer.ReductionOperation.Value = new ReductionOperation(ReductionOperations.Sum); // sum all the pruned subtrees parameter values
      prunedNodesReducer.TargetOperation.Value = new ReductionOperation(ReductionOperations.Assign); // asign the sum to the target parameter
      prunedNodesReducer.TargetParameter.ActualName = TotalNumberOfPrunedNodesParameterName;

      prunedSubtreesReducer = new DataReducer();
      prunedSubtreesReducer.ParameterToReduce.ActualName = PruningOperator.PrunedSubtreesParameter.ActualName;
      prunedSubtreesReducer.ReductionOperation.Value = new ReductionOperation(ReductionOperations.Sum); // sum all the pruned subtrees parameter values
      prunedSubtreesReducer.TargetOperation.Value = new ReductionOperation(ReductionOperations.Assign); // asign the sum to the target parameter
      prunedSubtreesReducer.TargetParameter.ActualName = TotalNumberOfPrunedSubtreesParameterName;

      prunedTreesReducer = new DataReducer();
      prunedTreesReducer.ParameterToReduce.ActualName = PruningOperator.PrunedTreesParameter.ActualName;
      prunedTreesReducer.ReductionOperation.Value = new ReductionOperation(ReductionOperations.Sum);
      prunedTreesReducer.TargetOperation.Value = new ReductionOperation(ReductionOperations.Assign);
      prunedTreesReducer.TargetParameter.ActualName = TotalNumberOfPrunedTreesParameterName;

      valuesCollector = new DataTableValuesCollector();
      valuesCollector.CollectedValues.Add(new LookupParameter<IntValue>(TotalNumberOfPrunedNodesParameterName));
      valuesCollector.CollectedValues.Add(new LookupParameter<IntValue>(TotalNumberOfPrunedSubtreesParameterName));
      valuesCollector.CollectedValues.Add(new LookupParameter<IntValue>(TotalNumberOfPrunedTreesParameterName));
      valuesCollector.DataTableParameter.ActualName = "Population pruning";

      resultsCollector = new ResultsCollector();
      resultsCollector.CollectedValues.Add(new LookupParameter<DataTable>("Population pruning"));
      resultsCollector.ResultsParameter.ActualName = ResultsParameterName;
    }
Ejemplo n.º 16
0
        private void Initialize()
        {
            #region Create parameters

            Parameters.Add(new ValueLookupParameter <IRandom>("GlobalRandom", "A pseudo random number generator."));
            Parameters.Add(new ValueLookupParameter <IRandom>("LocalRandom", "A pseudo random number generator."));

            Parameters.Add(new ValueLookupParameter <BoolArray>("Maximization", "True if an objective should be maximized, or false if it should be minimized."));
            Parameters.Add(new ScopeTreeLookupParameter <DoubleArray>("Qualities", "The vector of quality values."));

            Parameters.Add(new ValueLookupParameter <IntValue>("NumberOfLayers", "The number of layers."));
            Parameters.Add(new ValueLookupParameter <IntValue>("PopulationSize", "The population size."));
            Parameters.Add(new LookupParameter <IntValue>("CurrentPopulationSize", "The current size of the population."));

            Parameters.Add(new ValueLookupParameter <IOperator>("Selector", "The operator used to select solutions for reproduction."));

            Parameters.Add(new ValueLookupParameter <PercentValue>("CrossoverProbability", "The probability that the crossover operator is applied on a solution."));
            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 ScopeTreeLookupParameter <DoubleValue>("Age", "The age of individuals."));
            Parameters.Add(new ValueLookupParameter <IntValue>("AgeGap", "The frequency of reseeding the lowest layer and scaling factor for the age-limits for the layers."));
            Parameters.Add(new ValueLookupParameter <DoubleValue>("AgeInheritance", "A weight that determines the age of a child after crossover based on the older (1.0) and younger (0.0) parent."));
            Parameters.Add(new ValueLookupParameter <IntArray>("AgeLimits", "The maximum age an individual is allowed to reach in a certain layer."));

            Parameters.Add(new ValueLookupParameter <IntValue>("MatingPoolRange", "The range of sub - populations used for creating a mating pool. (1 = current + previous sub-population)"));
            Parameters.Add(new ValueLookupParameter <BoolValue>("ReduceToPopulationSize", "Reduce the CurrentPopulationSize after elder migration to PopulationSize"));

            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 <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 <IOperator>("LayerAnalyzer", "The operator used to analyze each layer."));
            Parameters.Add(new ValueLookupParameter <IOperator>("FinalAnalyzer", "The operator used to finally analyze the solution (after termination of the algorithm)."));

            Parameters.Add(new LookupParameter <IntValue>("EvaluatedSolutions", "The number of times solutions have been evaluated."));
            Parameters.Add(new ValueLookupParameter <BoolValue>("DominateOnEqualQualities", "Flag which determines whether solutions with equal quality values should be treated as dominated."));

            Parameters.Add(new ValueLookupParameter <IOperator>("Terminator", "The termination criteria that defines if the algorithm should continue or stop"));

            Parameters.Add(new FixedValueParameter <IntValue>("Zero", "Zero Value.", new IntValue(0)));
            Parameters.Add(new FixedValueParameter <IntValue>("One", "1 as a Value.", new IntValue(1)));

            #endregion

            #region Create operators and operator graph

            var variableCreator = new VariableCreator {
                Name = "Initialize"
            };
            var resultsCollector1          = new ResultsCollector();
            var initLayerAnalyzerProcessor = new SubScopesProcessor();
            var layerVariableCreator       = new VariableCreator {
                Name = "Initialize Layer"
            };
            var initLayerAnalyzerPlaceholder = new Placeholder {
                Name = "LayerAnalyzer (Placeholder)"
            };
            var initAnalyzerPlaceholder = new Placeholder {
                Name = "Analyzer (Placeholder)"
            };
            var initFinalAnalyzerPlaceholder = new Placeholder {
                Name = "FinalAnalyzer (Placeholder)"
            };
            var matingPoolCreator = new MatingPoolCreator {
                Name = "Create Mating Pools"
            };
            var matingPoolProcessor = new UniformSubScopesProcessor {
                Name = "Process Mating Pools"
            };
            var initializeLayer = new Assigner {
                Name = "Reset LayerEvaluatedSolutions"
            };
            var mainOperator           = new AlpsNsga2MainOperator();
            var generationsIncrementer = new IntCounter {
                Name = "Increment Generations"
            };
            var evaluatedSolutionsReducer = new DataReducer {
                Name = "Increment EvaluatedSolutions"
            };
            var eldersEmigrator = CreateEldersEmigrator();
            var layerOpener     = CreateLayerOpener();
            var layerReseeder   = CreateReseeder();
            var currentPopulationSizeComparator = new Comparator {
                Name = "Isn't CurrentPopulationSize 0?"
            };
            var currentPopulationSizeIsNotZeroBranch = new ConditionalBranch {
                Name = "CurrentPopulationSize != Zero"
            };
            var layerAnalyzerProcessor   = new UniformSubScopesProcessor();
            var layerAnalyzerPlaceholder = new Placeholder {
                Name = "LayerAnalyzer (Placeholder)"
            };
            var analyzerPlaceholder = new Placeholder {
                Name = "Analyzer (Placeholder)"
            };
            var termination           = new TerminationOperator();
            var rankAndCrowdingSorter = new RankAndCrowdingSorter();
            var mergingReducer        = new MergingReducer();
            var leftSelector          = new LeftSelector();
            var rightReducer          = new RightReducer();

            OperatorGraph.InitialOperator = variableCreator;

            variableCreator.CollectedValues.Add(new ValueParameter <IntValue>("Generations", new IntValue(0)));
            variableCreator.CollectedValues.Add(new ValueParameter <IntValue>("OpenLayers", new IntValue(1)));
            variableCreator.Successor = initLayerAnalyzerProcessor;

            initLayerAnalyzerProcessor.Operators.Add(layerVariableCreator);
            initLayerAnalyzerProcessor.Successor = initAnalyzerPlaceholder;

            layerVariableCreator.CollectedValues.Add(new ValueParameter <IntValue>("Layer", new IntValue(0)));
            layerVariableCreator.CollectedValues.Add(new ValueParameter <ResultCollection>("LayerResults"));
            layerVariableCreator.Successor = initLayerAnalyzerPlaceholder;

            initLayerAnalyzerPlaceholder.OperatorParameter.ActualName = LayerAnalyzerParameter.Name;
            initLayerAnalyzerPlaceholder.Successor = null;

            initAnalyzerPlaceholder.OperatorParameter.ActualName = AnalyzerParameter.Name;
            initAnalyzerPlaceholder.Successor = resultsCollector1;

            resultsCollector1.CollectedValues.Add(new LookupParameter <IntValue>("Generations"));
            resultsCollector1.CollectedValues.Add(new ScopeTreeLookupParameter <ResultCollection>("LayerResults", "Result set for each Layer", "LayerResults"));
            resultsCollector1.CollectedValues.Add(new LookupParameter <IntValue>("OpenLayers"));
            resultsCollector1.CopyValue = new BoolValue(false);
            resultsCollector1.ResultsParameter.ActualName = ResultsParameter.Name;
            resultsCollector1.Successor = matingPoolCreator;

            matingPoolCreator.MatingPoolRangeParameter.Value      = null;
            matingPoolCreator.MatingPoolRangeParameter.ActualName = MatingPoolRangeParameter.Name;
            matingPoolCreator.Successor = matingPoolProcessor;

            matingPoolProcessor.Parallel.Value = true;
            matingPoolProcessor.Operator       = initializeLayer;
            matingPoolProcessor.Successor      = generationsIncrementer;

            initializeLayer.LeftSideParameter.ActualName = "LayerEvaluatedSolutions";
            initializeLayer.RightSideParameter.Value     = new IntValue(0);
            initializeLayer.Successor = mainOperator;

            mainOperator.RandomParameter.ActualName               = LocalRandomParameter.Name;
            mainOperator.EvaluatorParameter.ActualName            = EvaluatorParameter.Name;
            mainOperator.EvaluatedSolutionsParameter.ActualName   = "LayerEvaluatedSolutions";
            mainOperator.QualityParameter.ActualName              = QualitiesParameter.Name;
            mainOperator.MaximizationParameter.ActualName         = MaximizationParameter.Name;
            mainOperator.PopulationSizeParameter.ActualName       = PopulationSizeParameter.Name;
            mainOperator.SelectorParameter.ActualName             = SelectorParameter.Name;
            mainOperator.CrossoverParameter.ActualName            = CrossoverParameter.Name;
            mainOperator.CrossoverProbabilityParameter.ActualName = CrossoverProbabilityParameter.Name;
            mainOperator.MutatorParameter.ActualName              = MutatorParameter.ActualName;
            mainOperator.MutationProbabilityParameter.ActualName  = MutationProbabilityParameter.Name;
            mainOperator.AgeParameter.ActualName            = AgeParameter.Name;
            mainOperator.AgeInheritanceParameter.ActualName = AgeInheritanceParameter.Name;
            mainOperator.AgeIncrementParameter.Value        = new DoubleValue(1.0);
            mainOperator.Successor = null;

            generationsIncrementer.ValueParameter.ActualName = "Generations";
            generationsIncrementer.Increment = new IntValue(1);
            generationsIncrementer.Successor = evaluatedSolutionsReducer;

            evaluatedSolutionsReducer.ParameterToReduce.ActualName = "LayerEvaluatedSolutions";
            evaluatedSolutionsReducer.TargetParameter.ActualName   = EvaluatedSolutionsParameter.Name;
            evaluatedSolutionsReducer.ReductionOperation.Value     = new ReductionOperation(ReductionOperations.Sum);
            evaluatedSolutionsReducer.TargetOperation.Value        = new ReductionOperation(ReductionOperations.Sum);
            evaluatedSolutionsReducer.Successor = eldersEmigrator;

            eldersEmigrator.Successor = layerOpener;

            layerOpener.Successor = layerReseeder;

            layerReseeder.Successor = layerAnalyzerProcessor;

            // Layer analyzer is only performed if individuals count is not 0
            layerAnalyzerProcessor.Operator  = currentPopulationSizeComparator;
            layerAnalyzerProcessor.Successor = analyzerPlaceholder;

            currentPopulationSizeComparator.LeftSideParameter.ActualName  = CurrentPopulationSizeParameter.Name;
            currentPopulationSizeComparator.RightSideParameter.ActualName = ZeroParameter.Name;
            currentPopulationSizeComparator.ResultParameter.ActualName    = "CurrentPopulationSizeIsNotZero";
            currentPopulationSizeComparator.Comparison = new Comparison(ComparisonType.NotEqual);
            currentPopulationSizeComparator.Successor  = currentPopulationSizeIsNotZeroBranch;

            currentPopulationSizeIsNotZeroBranch.ConditionParameter.ActualName = "CurrentPopulationSizeIsNotZero";
            currentPopulationSizeIsNotZeroBranch.TrueBranch = layerAnalyzerPlaceholder;

            layerAnalyzerPlaceholder.OperatorParameter.ActualName = LayerAnalyzerParameter.Name;

            analyzerPlaceholder.OperatorParameter.ActualName = AnalyzerParameter.Name;
            analyzerPlaceholder.Successor = termination;

            termination.TerminatorParameter.ActualName = TerminatorParameter.Name;
            termination.ContinueBranch = matingPoolCreator;

            termination.TerminateBranch = mergingReducer;
            mergingReducer.Successor    = rankAndCrowdingSorter;

            rankAndCrowdingSorter.DominateOnEqualQualitiesParameter.ActualName = DominateOnEqualQualitiesParameter.Name;
            rankAndCrowdingSorter.CrowdingDistanceParameter.ActualName         = "CrowdingDistance";
            rankAndCrowdingSorter.RankParameter.ActualName = "Rank";
            rankAndCrowdingSorter.Successor = leftSelector;

            leftSelector.CopySelected = new BoolValue(false);
            leftSelector.NumberOfSelectedSubScopesParameter.ActualName = PopulationSizeParameter.Name;
            leftSelector.Successor = rightReducer;

            rightReducer.Successor = initFinalAnalyzerPlaceholder;

            initFinalAnalyzerPlaceholder.OperatorParameter.ActualName = FinalAnalyzerParameter.Name;

            #endregion
        }
Ejemplo n.º 17
0
        public IEnumerable <TDataModel> Search(DataReducer <TDataModel> reducer)
        {
            Checker.NotNullArgument(reducer, nameof(reducer));

            return(QuerySearch(reducer));
        }
        public AlpsGeneticAlgorithmMainLoop()
            : base()
        {
            Parameters.Add(new ValueLookupParameter <IRandom>("GlobalRandom", "A pseudo random number generator."));
            Parameters.Add(new ValueLookupParameter <IRandom>("LocalRandom", "A pseudo random number generator."));

            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>("EvaluatedSolutions", "The number of times solutions have been evaluated."));
            Parameters.Add(new ScopeTreeLookupParameter <DoubleValue>("Quality", "The value which represents the quality of a solution."));
            Parameters.Add(new ValueLookupParameter <BoolValue>("Maximization", "True if the problem is a maximization problem, otherwise false."));

            Parameters.Add(new ValueLookupParameter <IOperator>("Analyzer", "The operator used to analyze all individuals from all layers combined."));
            Parameters.Add(new ValueLookupParameter <IOperator>("LayerAnalyzer", "The operator used to analyze each layer."));

            Parameters.Add(new ValueLookupParameter <IntValue>("NumberOfLayers", "The number of layers."));
            Parameters.Add(new ValueLookupParameter <IntValue>("PopulationSize", "The size of the population of solutions in each layer."));
            Parameters.Add(new LookupParameter <IntValue>("CurrentPopulationSize", "The current size of the population."));

            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 <IOperator>("Mutator", "The operator used to mutate solutions."));
            Parameters.Add(new ValueLookupParameter <PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution."));
            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 <BoolValue>("PlusSelection", "Include the parents in the selection of the invividuals for the next generation."));

            Parameters.Add(new ScopeTreeLookupParameter <DoubleValue>("Age", "The age of individuals."));
            Parameters.Add(new ValueLookupParameter <IntValue>("AgeGap", "The frequency of reseeding the lowest layer and scaling factor for the age-limits for the layers."));
            Parameters.Add(new ValueLookupParameter <DoubleValue>("AgeInheritance", "A weight that determines the age of a child after crossover based on the older (1.0) and younger (0.0) parent."));
            Parameters.Add(new ValueLookupParameter <IntArray>("AgeLimits", "The maximum age an individual is allowed to reach in a certain layer."));

            Parameters.Add(new ValueLookupParameter <IntValue>("MatingPoolRange", "The range of sub - populations used for creating a mating pool. (1 = current + previous sub-population)"));
            Parameters.Add(new ValueLookupParameter <BoolValue>("ReduceToPopulationSize", "Reduce the CurrentPopulationSize after elder migration to PopulationSize"));

            Parameters.Add(new ValueLookupParameter <IOperator>("Terminator", "The termination criteria that defines if the algorithm should continue or stop"));


            var variableCreator = new VariableCreator()
            {
                Name = "Initialize"
            };
            var initLayerAnalyzerProcessor = new SubScopesProcessor();
            var layerVariableCreator       = new VariableCreator()
            {
                Name = "Initialize Layer"
            };
            var initLayerAnalyzerPlaceholder = new Placeholder()
            {
                Name = "LayerAnalyzer (Placeholder)"
            };
            var initAnalyzerPlaceholder = new Placeholder()
            {
                Name = "Analyzer (Placeholder)"
            };
            var resultsCollector  = new ResultsCollector();
            var matingPoolCreator = new MatingPoolCreator()
            {
                Name = "Create Mating Pools"
            };
            var matingPoolProcessor = new UniformSubScopesProcessor()
            {
                Name = "Process Mating Pools"
            };
            var initializeLayer = new Assigner()
            {
                Name = "Reset LayerEvaluatedSolutions"
            };
            var mainOperator          = new AlpsGeneticAlgorithmMainOperator();
            var generationsIcrementor = new IntCounter()
            {
                Name = "Increment Generations"
            };
            var evaluatedSolutionsReducer = new DataReducer()
            {
                Name = "Increment EvaluatedSolutions"
            };
            var eldersEmigrator          = CreateEldersEmigrator();
            var layerOpener              = CreateLayerOpener();
            var layerReseeder            = CreateReseeder();
            var layerAnalyzerProcessor   = new UniformSubScopesProcessor();
            var layerAnalyzerPlaceholder = new Placeholder()
            {
                Name = "LayerAnalyzer (Placeholder)"
            };
            var analyzerPlaceholder = new Placeholder()
            {
                Name = "Analyzer (Placeholder)"
            };
            var termination = new TerminationOperator();

            OperatorGraph.InitialOperator = variableCreator;

            variableCreator.CollectedValues.Add(new ValueParameter <IntValue>("Generations", new IntValue(0)));
            variableCreator.CollectedValues.Add(new ValueParameter <IntValue>("OpenLayers", new IntValue(1)));
            variableCreator.Successor = initLayerAnalyzerProcessor;

            initLayerAnalyzerProcessor.Operators.Add(layerVariableCreator);
            initLayerAnalyzerProcessor.Successor = initAnalyzerPlaceholder;

            layerVariableCreator.CollectedValues.Add(new ValueParameter <IntValue>("Layer", new IntValue(0)));
            layerVariableCreator.CollectedValues.Add(new ValueParameter <ResultCollection>("LayerResults"));
            layerVariableCreator.Successor = initLayerAnalyzerPlaceholder;

            initLayerAnalyzerPlaceholder.OperatorParameter.ActualName = LayerAnalyzerParameter.Name;
            initLayerAnalyzerPlaceholder.Successor = null;

            initAnalyzerPlaceholder.OperatorParameter.ActualName = AnalyzerParameter.Name;
            initAnalyzerPlaceholder.Successor = resultsCollector;

            resultsCollector.CollectedValues.Add(new LookupParameter <IntValue>("Generations"));
            resultsCollector.CollectedValues.Add(new ScopeTreeLookupParameter <ResultCollection>("LayerResults", "Result set for each Layer", "LayerResults"));
            resultsCollector.CollectedValues.Add(new LookupParameter <IntValue>("OpenLayers"));
            resultsCollector.CopyValue = new BoolValue(false);
            resultsCollector.Successor = matingPoolCreator;

            matingPoolCreator.MatingPoolRangeParameter.Value      = null;
            matingPoolCreator.MatingPoolRangeParameter.ActualName = MatingPoolRangeParameter.Name;
            matingPoolCreator.Successor = matingPoolProcessor;

            matingPoolProcessor.Parallel.Value = true;
            matingPoolProcessor.Operator       = initializeLayer;
            matingPoolProcessor.Successor      = generationsIcrementor;

            initializeLayer.LeftSideParameter.ActualName = "LayerEvaluatedSolutions";
            initializeLayer.RightSideParameter.Value     = new IntValue(0);
            initializeLayer.Successor = mainOperator;

            mainOperator.RandomParameter.ActualName              = LocalRandomParameter.Name;
            mainOperator.EvaluatorParameter.ActualName           = EvaluatorParameter.Name;
            mainOperator.EvaluatedSolutionsParameter.ActualName  = "LayerEvaluatedSolutions";
            mainOperator.QualityParameter.ActualName             = QualityParameter.Name;
            mainOperator.MaximizationParameter.ActualName        = MaximizationParameter.Name;
            mainOperator.PopulationSizeParameter.ActualName      = PopulationSizeParameter.Name;
            mainOperator.SelectorParameter.ActualName            = SelectorParameter.Name;
            mainOperator.CrossoverParameter.ActualName           = CrossoverParameter.Name;
            mainOperator.MutatorParameter.ActualName             = MutatorParameter.ActualName;
            mainOperator.MutationProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
            mainOperator.ElitesParameter.ActualName              = ElitesParameter.Name;
            mainOperator.ReevaluateElitesParameter.ActualName    = ReevaluateElitesParameter.Name;
            mainOperator.PlusSelectionParameter.ActualName       = PlusSelectionParameter.Name;
            mainOperator.AgeParameter.ActualName            = AgeParameter.Name;
            mainOperator.AgeInheritanceParameter.ActualName = AgeInheritanceParameter.Name;
            mainOperator.AgeIncrementParameter.Value        = new DoubleValue(1.0);
            mainOperator.Successor = null;

            generationsIcrementor.ValueParameter.ActualName = "Generations";
            generationsIcrementor.Increment = new IntValue(1);
            generationsIcrementor.Successor = evaluatedSolutionsReducer;

            evaluatedSolutionsReducer.ParameterToReduce.ActualName = "LayerEvaluatedSolutions";
            evaluatedSolutionsReducer.TargetParameter.ActualName   = EvaluatedSolutionsParameter.Name;
            evaluatedSolutionsReducer.ReductionOperation.Value     = new ReductionOperation(ReductionOperations.Sum);
            evaluatedSolutionsReducer.TargetOperation.Value        = new ReductionOperation(ReductionOperations.Sum);
            evaluatedSolutionsReducer.Successor = eldersEmigrator;

            eldersEmigrator.Successor = layerOpener;

            layerOpener.Successor = layerReseeder;

            layerReseeder.Successor = layerAnalyzerProcessor;

            layerAnalyzerProcessor.Operator  = layerAnalyzerPlaceholder;
            layerAnalyzerProcessor.Successor = analyzerPlaceholder;

            layerAnalyzerPlaceholder.OperatorParameter.ActualName = LayerAnalyzerParameter.Name;

            analyzerPlaceholder.OperatorParameter.ActualName = AnalyzerParameter.Name;
            analyzerPlaceholder.Successor = termination;

            termination.TerminatorParameter.ActualName = TerminatorParameter.Name;
            termination.ContinueBranch = matingPoolCreator;
        }
Ejemplo n.º 19
0
 public void BulkRemoveFromSearch(DataReducer <TDataModel> reducer)
 {
     throw new System.NotImplementedException();
 }
Ejemplo n.º 20
0
        private void Initialize()
        {
            #region Create parameters
            Parameters.Add(new ValueLookupParameter <IMultiAnalyzer>("Analyzer", "The analyzer used to analyze each iteration."));
            Parameters.Add(new ValueLookupParameter <DoubleValue>("BestKnownQuality", "The best known quality value found so far."));
            Parameters.Add(new ValueLookupParameter <ICrossover>("Crossover", "The operator used to cross solutions."));
            Parameters.Add(new ValueLookupParameter <IntValue>("EvaluatedSolutions", "The number of times solutions have been evaluated."));
            Parameters.Add(new ValueLookupParameter <IEvaluator>("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 <BoolValue>("ExecutePathRelinking", "True if path relinking should be executed instead of crossover, otherwise false."));
            Parameters.Add(new ValueLookupParameter <IImprovementOperator>("Improver", "The operator used to improve solutions."));
            Parameters.Add(new ValueLookupParameter <IntValue>("Iterations", "The number of iterations performed."));
            Parameters.Add(new ValueLookupParameter <BoolValue>("Maximization", "True if the problem is a maximization problem, otherwise false."));
            Parameters.Add(new ValueLookupParameter <IntValue>("MaximumIterations", "The maximum number of iterations which should be processed."));
            Parameters.Add(new ValueLookupParameter <IntValue>("NumberOfHighQualitySolutions", "The number of high quality solutions in the reference set."));
            Parameters.Add(new ValueLookupParameter <IPathRelinker>("PathRelinker", "The operator used to execute path relinking."));
            Parameters.Add(new ValueLookupParameter <IntValue>("PopulationSize", "The size of the population of solutions."));
            Parameters.Add(new ValueLookupParameter <IntValue>("ReferenceSetSize", "The size of the reference set."));
            Parameters.Add(new ValueLookupParameter <DoubleValue>("Quality", "This parameter is used for name translation only."));
            Parameters.Add(new ValueLookupParameter <IRandom>("Random", "A pseudo random number generator."));
            Parameters.Add(new ValueLookupParameter <VariableCollection>("Results", "The variable collection where results should be stored."));
            Parameters.Add(new ValueLookupParameter <ISolutionSimilarityCalculator>("SimilarityCalculator", "The operator used to calculate the similarity between two solutions."));
            #endregion

            #region Create operators
            Placeholder               analyzer                   = new Placeholder();
            Assigner                  assigner1                  = new Assigner();
            Assigner                  assigner2                  = new Assigner();
            ChildrenCreator           childrenCreator            = new ChildrenCreator();
            Placeholder               crossover                  = new Placeholder();
            Comparator                iterationsChecker          = new Comparator();
            IntCounter                iterationsCounter          = new IntCounter();
            MergingReducer            mergingReducer             = new MergingReducer();
            ConditionalBranch         executePathRelinkingBranch = new ConditionalBranch();
            ConditionalBranch         newSolutionsBranch         = new ConditionalBranch();
            OffspringProcessor        offspringProcessor         = new OffspringProcessor();
            Placeholder               pathRelinker               = new Placeholder();
            PopulationRebuildMethod   populationRebuildMethod    = new PopulationRebuildMethod();
            ReferenceSetUpdateMethod  referenceSetUpdateMethod   = new ReferenceSetUpdateMethod();
            ResultsCollector          resultsCollector           = new ResultsCollector();
            RightSelector             rightSelector              = new RightSelector();
            Placeholder               solutionEvaluator1         = new Placeholder();
            Placeholder               solutionEvaluator2         = new Placeholder();
            Placeholder               solutionImprover1          = new Placeholder();
            Placeholder               solutionImprover2          = new Placeholder();
            SolutionPoolUpdateMethod  solutionPoolUpdateMethod   = new SolutionPoolUpdateMethod();
            SolutionsCreator          solutionsCreator           = new SolutionsCreator();
            DataReducer               dataReducer1               = new DataReducer();
            DataReducer               dataReducer2               = new DataReducer();
            SubScopesProcessor        subScopesProcessor1        = new SubScopesProcessor();
            SubScopesProcessor        subScopesProcessor2        = new SubScopesProcessor();
            SubScopesProcessor        subScopesProcessor3        = new SubScopesProcessor();
            SubScopesProcessor        subScopesProcessor4        = new SubScopesProcessor();
            ConditionalBranch         terminateBranch            = new ConditionalBranch();
            UniformSubScopesProcessor uniformSubScopesProcessor1 = new UniformSubScopesProcessor();
            UniformSubScopesProcessor uniformSubScopesProcessor2 = new UniformSubScopesProcessor();
            UniformSubScopesProcessor uniformSubScopesProcessor3 = new UniformSubScopesProcessor();
            VariableCreator           variableCreator            = new VariableCreator();
            #endregion

            #region Create operator graph
            OperatorGraph.InitialOperator = variableCreator;
            variableCreator.CollectedValues.Add(new ValueParameter <IntValue>(IterationsParameter.Name, new IntValue(0)));
            variableCreator.CollectedValues.Add(new ValueParameter <BoolValue>("NewSolutions", new BoolValue(false)));
            variableCreator.Successor = resultsCollector;

            resultsCollector.CopyValue = new BoolValue(false);
            resultsCollector.CollectedValues.Add(new LookupParameter <IntValue>(IterationsParameter.Name));
            resultsCollector.ResultsParameter.ActualName = ResultsParameter.Name;
            resultsCollector.Successor = iterationsChecker;

            iterationsChecker.Name                          = "IterationsChecker";
            iterationsChecker.Comparison.Value              = ComparisonType.GreaterOrEqual;
            iterationsChecker.LeftSideParameter.ActualName  = IterationsParameter.Name;
            iterationsChecker.RightSideParameter.ActualName = MaximumIterationsParameter.Name;
            iterationsChecker.ResultParameter.ActualName    = "Terminate";
            iterationsChecker.Successor                     = terminateBranch;

            terminateBranch.Name = "TerminateChecker";
            terminateBranch.ConditionParameter.ActualName = "Terminate";
            terminateBranch.FalseBranch = referenceSetUpdateMethod;

            referenceSetUpdateMethod.Successor = assigner1;

            assigner1.Name = "NewSolutions = true";
            assigner1.LeftSideParameter.ActualName = "NewSolutions";
            assigner1.RightSideParameter.Value     = new BoolValue(true);
            assigner1.Successor = subScopesProcessor1;

            subScopesProcessor1.DepthParameter.Value = new IntValue(1);
            subScopesProcessor1.Operators.Add(new EmptyOperator());
            subScopesProcessor1.Operators.Add(childrenCreator);
            subScopesProcessor1.Successor = newSolutionsBranch;

            childrenCreator.Name = "SubsetGenerator";
            childrenCreator.ParentsPerChildParameter.Value = new IntValue(2);
            childrenCreator.Successor = assigner2;

            assigner2.Name = "NewSolutions = false";
            assigner2.LeftSideParameter.ActualName = "NewSolutions";
            assigner2.RightSideParameter.Value     = new BoolValue(false);
            assigner2.Successor = uniformSubScopesProcessor1;

            uniformSubScopesProcessor1.DepthParameter.Value = new IntValue(1);
            uniformSubScopesProcessor1.Operator             = executePathRelinkingBranch;
            uniformSubScopesProcessor1.Successor            = solutionPoolUpdateMethod;

            executePathRelinkingBranch.Name = "ExecutePathRelinkingChecker";
            executePathRelinkingBranch.ConditionParameter.ActualName = ExecutePathRelinkingParameter.ActualName;
            executePathRelinkingBranch.TrueBranch  = pathRelinker;
            executePathRelinkingBranch.FalseBranch = crossover;

            pathRelinker.Name = "PathRelinker";
            pathRelinker.OperatorParameter.ActualName = PathRelinkerParameter.Name;
            pathRelinker.Successor = rightSelector;

            crossover.Name = "Crossover";
            crossover.OperatorParameter.ActualName = CrossoverParameter.Name;
            crossover.Successor = offspringProcessor;

            offspringProcessor.Successor = rightSelector;

            rightSelector.NumberOfSelectedSubScopesParameter.Value = new IntValue(1);
            rightSelector.CopySelected = new BoolValue(false);
            rightSelector.Successor    = subScopesProcessor2;

            subScopesProcessor2.DepthParameter.Value = new IntValue(1);
            subScopesProcessor2.Operators.Add(new EmptyOperator());
            subScopesProcessor2.Operators.Add(uniformSubScopesProcessor2);
            subScopesProcessor2.Successor = mergingReducer;

            uniformSubScopesProcessor2.DepthParameter.Value    = new IntValue(2);
            uniformSubScopesProcessor2.Operator                = solutionImprover1;
            uniformSubScopesProcessor2.ParallelParameter.Value = new BoolValue(true);
            uniformSubScopesProcessor2.Successor               = subScopesProcessor4;

            solutionImprover1.Name = "SolutionImprover";
            solutionImprover1.OperatorParameter.ActualName = ImproverParameter.Name;
            solutionImprover1.Successor = solutionEvaluator1;

            solutionEvaluator1.Name = "SolutionEvaluator";
            solutionEvaluator1.OperatorParameter.ActualName = EvaluatorParameter.Name;

            subScopesProcessor4.Operators.Add(dataReducer1);

            dataReducer1.Name = "Increment EvaluatedSolutions";
            dataReducer1.ParameterToReduce.ActualName = "LocalEvaluatedSolutions";
            dataReducer1.TargetParameter.ActualName   = EvaluatedSolutionsParameter.Name;
            dataReducer1.ReductionOperation.Value     = new ReductionOperation(ReductionOperations.Sum);
            dataReducer1.TargetOperation.Value        = new ReductionOperation(ReductionOperations.Sum);

            solutionPoolUpdateMethod.QualityParameter.ActualName = QualityParameter.ActualName;
            solutionPoolUpdateMethod.Successor = analyzer;

            analyzer.Name = "Analyzer";
            analyzer.OperatorParameter.ActualName = AnalyzerParameter.Name;

            newSolutionsBranch.Name = "NewSolutionsChecker";
            newSolutionsBranch.ConditionParameter.ActualName = "NewSolutions";
            newSolutionsBranch.TrueBranch  = subScopesProcessor1;
            newSolutionsBranch.FalseBranch = populationRebuildMethod;

            populationRebuildMethod.QualityParameter.ActualName = QualityParameter.ActualName;
            populationRebuildMethod.Successor = subScopesProcessor3;

            subScopesProcessor3.DepthParameter.Value = new IntValue(1);
            subScopesProcessor3.Operators.Add(solutionsCreator);
            subScopesProcessor3.Operators.Add(new EmptyOperator());
            subScopesProcessor3.Successor = iterationsCounter;

            solutionsCreator.Name = "DiversificationGenerationMethod";
            solutionsCreator.NumberOfSolutionsParameter.ActualName = PopulationSizeParameter.Name;
            solutionsCreator.Successor = uniformSubScopesProcessor3;

            uniformSubScopesProcessor3.DepthParameter.Value    = new IntValue(1);
            uniformSubScopesProcessor3.Operator                = solutionImprover2;
            uniformSubScopesProcessor3.ParallelParameter.Value = new BoolValue(true);
            uniformSubScopesProcessor3.Successor               = dataReducer2;

            solutionImprover2.Name = "SolutionImprover";
            solutionImprover2.OperatorParameter.ActualName = ImproverParameter.Name;
            solutionImprover2.Successor = solutionEvaluator2;

            solutionEvaluator2.Name = "SolutionEvaluator";
            solutionEvaluator2.OperatorParameter.ActualName = EvaluatorParameter.Name;

            dataReducer2.Name = "Increment EvaluatedSolutions";
            dataReducer2.ParameterToReduce.ActualName = "LocalEvaluatedSolutions";
            dataReducer2.TargetParameter.ActualName   = EvaluatedSolutionsParameter.Name;
            dataReducer2.ReductionOperation.Value     = new ReductionOperation(ReductionOperations.Sum);
            dataReducer2.TargetOperation.Value        = new ReductionOperation(ReductionOperations.Sum);

            iterationsCounter.Name = "IterationCounter";
            iterationsCounter.IncrementParameter.Value  = new IntValue(1);
            iterationsCounter.ValueParameter.ActualName = IterationsParameter.Name;
            iterationsCounter.Successor = resultsCollector;
            #endregion
        }
    public IslandGeneticAlgorithmMainLoop()
      : base() {
      #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<DoubleValue>("BestKnownQuality", "The best known quality value found so far."));
      Parameters.Add(new ValueLookupParameter<IntValue>("NumberOfIslands", "The number of islands."));
      Parameters.Add(new ValueLookupParameter<IntValue>("MigrationInterval", "The number of generations that should pass between migration phases."));
      Parameters.Add(new ValueLookupParameter<PercentValue>("MigrationRate", "The proportion of individuals that should migrate between the islands."));
      Parameters.Add(new ValueLookupParameter<IOperator>("Migrator", "The migration strategy."));
      Parameters.Add(new ValueLookupParameter<IOperator>("EmigrantsSelector", "Selects the individuals that will be migrated."));
      Parameters.Add(new ValueLookupParameter<IOperator>("ImmigrationReplacer", "Replaces some of the original population with the immigrants."));
      Parameters.Add(new ValueLookupParameter<IntValue>("PopulationSize", "The size of the population of solutions."));
      Parameters.Add(new ValueLookupParameter<IntValue>("MaximumGenerations", "The maximum number of generations that the algorithm should process."));
      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."));
      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<ResultCollection>("Results", "The results collection to store the results."));
      Parameters.Add(new ValueLookupParameter<IOperator>("Analyzer", "The operator used to the analyze the islands."));
      Parameters.Add(new ValueLookupParameter<IOperator>("IslandAnalyzer", "The operator used to analyze each island."));
      Parameters.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "The number of times a solution has been evaluated."));
      Parameters.Add(new LookupParameter<IntValue>("IslandGenerations", "The number of generations calculated on one island."));
      Parameters.Add(new LookupParameter<IntValue>("IslandEvaluatedSolutions", "The number of times a solution has been evaluated on one island."));
      Parameters.Add(new ValueLookupParameter<BoolValue>("Migrate", "Migrate the island?"));
      #endregion

      #region Create operators
      VariableCreator variableCreator = new VariableCreator();
      UniformSubScopesProcessor uniformSubScopesProcessor0 = new UniformSubScopesProcessor();
      VariableCreator islandVariableCreator = new VariableCreator();
      Placeholder islandAnalyzer1 = new Placeholder();
      LocalRandomCreator localRandomCreator = new LocalRandomCreator();
      Placeholder analyzer1 = new Placeholder();
      ResultsCollector resultsCollector1 = new ResultsCollector();
      UniformSubScopesProcessor uniformSubScopesProcessor1 = new UniformSubScopesProcessor();
      Assigner generationsAssigner = new Assigner();
      Assigner evaluatedSolutionsAssigner = new Assigner();
      Placeholder selector = new Placeholder();
      SubScopesProcessor subScopesProcessor1 = new SubScopesProcessor();
      ChildrenCreator childrenCreator = new ChildrenCreator();
      UniformSubScopesProcessor uniformSubScopesProcessor2 = new UniformSubScopesProcessor();
      Placeholder crossover = new Placeholder();
      StochasticBranch stochasticBranch = new StochasticBranch();
      Placeholder mutator = new Placeholder();
      SubScopesRemover subScopesRemover = new SubScopesRemover();
      UniformSubScopesProcessor uniformSubScopesProcessor3 = new UniformSubScopesProcessor();
      Placeholder evaluator = new Placeholder();
      SubScopesCounter subScopesCounter = new SubScopesCounter();
      SubScopesProcessor subScopesProcessor2 = new SubScopesProcessor();
      BestSelector bestSelector = new BestSelector();
      RightReducer rightReducer = new RightReducer();
      MergingReducer mergingReducer = new MergingReducer();
      IntCounter islandGenerationsCounter = new IntCounter();
      Comparator checkIslandGenerationsReachedMaximum = new Comparator();
      ConditionalBranch checkContinueEvolution = new ConditionalBranch();
      DataReducer generationsReducer = new DataReducer();
      DataReducer evaluatedSolutionsReducer = new DataReducer();
      Placeholder islandAnalyzer2 = new Placeholder();
      UniformSubScopesProcessor uniformSubScopesProcessor5 = new UniformSubScopesProcessor();
      Placeholder emigrantsSelector = new Placeholder();
      IntCounter migrationsCounter = new IntCounter();
      Placeholder migrator = new Placeholder();
      UniformSubScopesProcessor uniformSubScopesProcessor6 = new UniformSubScopesProcessor();
      Placeholder immigrationReplacer = new Placeholder();
      Comparator generationsComparator = new Comparator();
      Placeholder analyzer2 = new Placeholder();
      ConditionalBranch generationsTerminationCondition = new ConditionalBranch();
      ConditionalBranch reevaluateElitesBranch = new ConditionalBranch();


      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Migrations", new IntValue(0)));
      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("GenerationsSinceLastMigration", new IntValue(0)));
      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0))); // Class IslandGeneticAlgorithm expects this to be called Generations

      islandVariableCreator.CollectedValues.Add(new ValueParameter<ResultCollection>("Results", new ResultCollection()));
      islandVariableCreator.CollectedValues.Add(new ValueParameter<IntValue>("IslandGenerations", new IntValue(0)));
      islandVariableCreator.CollectedValues.Add(new ValueParameter<IntValue>("IslandEvaluatedSolutions", new IntValue(0)));

      islandAnalyzer1.Name = "Island Analyzer (placeholder)";
      islandAnalyzer1.OperatorParameter.ActualName = IslandAnalyzerParameter.Name;

      analyzer1.Name = "Analyzer (placeholder)";
      analyzer1.OperatorParameter.ActualName = AnalyzerParameter.Name;

      resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Migrations"));
      resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Generations"));
      resultsCollector1.CollectedValues.Add(new ScopeTreeLookupParameter<ResultCollection>("IslandResults", "Result set for each island", "Results"));
      resultsCollector1.ResultsParameter.ActualName = ResultsParameter.Name;

      uniformSubScopesProcessor1.Parallel.Value = true;

      generationsAssigner.Name = "Initialize Island Generations";
      generationsAssigner.LeftSideParameter.ActualName = IslandGenerations.Name;
      generationsAssigner.RightSideParameter.Value = new IntValue(0);

      evaluatedSolutionsAssigner.Name = "Initialize Island evaluated solutions";
      evaluatedSolutionsAssigner.LeftSideParameter.ActualName = IslandEvaluatedSolutions.Name;
      evaluatedSolutionsAssigner.RightSideParameter.Value = new IntValue(0);

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

      childrenCreator.ParentsPerChild = new IntValue(2);

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

      stochasticBranch.ProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
      //set it to the random number generator of the island
      stochasticBranch.RandomParameter.ActualName = "LocalRandom";

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

      subScopesRemover.RemoveAllSubScopes = true;

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

      subScopesCounter.Name = "Increment EvaluatedSolutions";
      subScopesCounter.ValueParameter.ActualName = IslandEvaluatedSolutions.Name;

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

      islandGenerationsCounter.Name = "Increment island generatrions";
      islandGenerationsCounter.ValueParameter.ActualName = IslandGenerations.Name;
      islandGenerationsCounter.Increment = new IntValue(1);

      checkIslandGenerationsReachedMaximum.LeftSideParameter.ActualName = IslandGenerations.Name;
      checkIslandGenerationsReachedMaximum.RightSideParameter.ActualName = MigrationIntervalParameter.Name;
      checkIslandGenerationsReachedMaximum.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
      checkIslandGenerationsReachedMaximum.ResultParameter.ActualName = Migrate.Name;

      checkContinueEvolution.Name = "Migrate?";
      checkContinueEvolution.ConditionParameter.ActualName = Migrate.Name;
      checkContinueEvolution.FalseBranch = selector;

      islandAnalyzer2.Name = "Island Analyzer (placeholder)";
      islandAnalyzer2.OperatorParameter.ActualName = IslandAnalyzerParameter.Name;

      generationsReducer.Name = "Increment Generations";
      generationsReducer.ParameterToReduce.ActualName = islandGenerationsCounter.ValueParameter.ActualName;
      generationsReducer.TargetParameter.ActualName = "Generations";
      generationsReducer.ReductionOperation.Value = new ReductionOperation(ReductionOperations.Min);
      generationsReducer.TargetOperation.Value = new ReductionOperation(ReductionOperations.Sum);

      evaluatedSolutionsReducer.Name = "Increment Evaluated Solutions";
      evaluatedSolutionsReducer.ParameterToReduce.ActualName = IslandEvaluatedSolutions.Name;
      evaluatedSolutionsReducer.TargetParameter.ActualName = EvaluatedSolutionsParameter.Name;
      evaluatedSolutionsReducer.ReductionOperation.Value = new ReductionOperation(ReductionOperations.Sum);
      evaluatedSolutionsReducer.TargetOperation.Value = new ReductionOperation(ReductionOperations.Sum);

      emigrantsSelector.Name = "Emigrants Selector (placeholder)";
      emigrantsSelector.OperatorParameter.ActualName = EmigrantsSelectorParameter.Name;

      migrationsCounter.Name = "Increment number of Migrations";
      migrationsCounter.ValueParameter.ActualName = "Migrations";
      migrationsCounter.Increment = new IntValue(1);

      migrator.Name = "Migrator (placeholder)";
      migrator.OperatorParameter.ActualName = MigratorParameter.Name;

      immigrationReplacer.Name = "Immigration Replacer (placeholder)";
      immigrationReplacer.OperatorParameter.ActualName = ImmigrationReplacerParameter.Name;

      generationsComparator.Name = "Generations >= MaximumGenerations ?";
      generationsComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
      generationsComparator.LeftSideParameter.ActualName = "Generations";
      generationsComparator.ResultParameter.ActualName = "TerminateGenerations";
      generationsComparator.RightSideParameter.ActualName = MaximumGenerationsParameter.Name;

      analyzer2.Name = "Analyzer (placeholder)";
      analyzer2.OperatorParameter.ActualName = AnalyzerParameter.Name;

      generationsTerminationCondition.Name = "Terminate?";
      generationsTerminationCondition.ConditionParameter.ActualName = "TerminateGenerations";

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

      #region Create operator graph
      OperatorGraph.InitialOperator = variableCreator;
      variableCreator.Successor = uniformSubScopesProcessor0;
      uniformSubScopesProcessor0.Operator = islandVariableCreator;
      uniformSubScopesProcessor0.Successor = analyzer1;
      islandVariableCreator.Successor = islandAnalyzer1;
      // BackwardsCompatibility3.3
      //the local randoms are created by the island GA itself and are only here to ensure same algorithm results
      #region Backwards compatible code, remove local random creator with 3.4 and rewire the operator graph
      islandAnalyzer1.Successor = localRandomCreator;
      localRandomCreator.Successor = null;
      #endregion
      analyzer1.Successor = resultsCollector1;
      resultsCollector1.Successor = uniformSubScopesProcessor1;
      uniformSubScopesProcessor1.Operator = generationsAssigner;
      uniformSubScopesProcessor1.Successor = generationsReducer;
      generationsReducer.Successor = evaluatedSolutionsReducer;
      evaluatedSolutionsReducer.Successor = migrationsCounter;
      migrationsCounter.Successor = uniformSubScopesProcessor5;
      generationsAssigner.Successor = evaluatedSolutionsAssigner;
      evaluatedSolutionsAssigner.Successor = selector;
      selector.Successor = subScopesProcessor1;
      subScopesProcessor1.Operators.Add(new EmptyOperator());
      subScopesProcessor1.Operators.Add(childrenCreator);
      subScopesProcessor1.Successor = subScopesProcessor2;
      childrenCreator.Successor = uniformSubScopesProcessor2;
      uniformSubScopesProcessor2.Operator = crossover;
      uniformSubScopesProcessor2.Successor = uniformSubScopesProcessor3;
      crossover.Successor = stochasticBranch;
      stochasticBranch.FirstBranch = mutator;
      stochasticBranch.SecondBranch = null;
      stochasticBranch.Successor = subScopesRemover;
      mutator.Successor = null;
      subScopesRemover.Successor = null;
      uniformSubScopesProcessor3.Operator = evaluator;
      uniformSubScopesProcessor3.Successor = subScopesCounter;
      evaluator.Successor = null;
      subScopesCounter.Successor = null;
      subScopesProcessor2.Operators.Add(bestSelector);
      subScopesProcessor2.Operators.Add(new EmptyOperator());
      subScopesProcessor2.Successor = mergingReducer;
      mergingReducer.Successor = islandAnalyzer2;
      bestSelector.Successor = rightReducer;
      rightReducer.Successor = reevaluateElitesBranch;
      reevaluateElitesBranch.TrueBranch = uniformSubScopesProcessor3;
      reevaluateElitesBranch.FalseBranch = null;
      reevaluateElitesBranch.Successor = null;
      islandAnalyzer2.Successor = islandGenerationsCounter;
      islandGenerationsCounter.Successor = checkIslandGenerationsReachedMaximum;
      checkIslandGenerationsReachedMaximum.Successor = checkContinueEvolution;
      uniformSubScopesProcessor5.Operator = emigrantsSelector;
      emigrantsSelector.Successor = null;
      uniformSubScopesProcessor5.Successor = migrator;
      migrator.Successor = uniformSubScopesProcessor6;
      uniformSubScopesProcessor6.Operator = immigrationReplacer;
      uniformSubScopesProcessor6.Successor = generationsComparator;
      generationsComparator.Successor = analyzer2;
      analyzer2.Successor = generationsTerminationCondition;
      generationsTerminationCondition.TrueBranch = null;
      generationsTerminationCondition.FalseBranch = uniformSubScopesProcessor1;
      generationsTerminationCondition.Successor = null;
      #endregion
    }
        public IslandGeneticAlgorithmMainLoop()
            : base()
        {
            #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 <DoubleValue>("BestKnownQuality", "The best known quality value found so far."));
            Parameters.Add(new ValueLookupParameter <IntValue>("NumberOfIslands", "The number of islands."));
            Parameters.Add(new ValueLookupParameter <IntValue>("MigrationInterval", "The number of generations that should pass between migration phases."));
            Parameters.Add(new ValueLookupParameter <PercentValue>("MigrationRate", "The proportion of individuals that should migrate between the islands."));
            Parameters.Add(new ValueLookupParameter <IOperator>("Migrator", "The migration strategy."));
            Parameters.Add(new ValueLookupParameter <IOperator>("EmigrantsSelector", "Selects the individuals that will be migrated."));
            Parameters.Add(new ValueLookupParameter <IOperator>("ImmigrationReplacer", "Replaces some of the original population with the immigrants."));
            Parameters.Add(new ValueLookupParameter <IntValue>("PopulationSize", "The size of the population of solutions."));
            Parameters.Add(new ValueLookupParameter <IntValue>("MaximumGenerations", "The maximum number of generations that the algorithm should process."));
            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."));
            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 <ResultCollection>("Results", "The results collection to store the results."));
            Parameters.Add(new ValueLookupParameter <IOperator>("Analyzer", "The operator used to the analyze the islands."));
            Parameters.Add(new ValueLookupParameter <IOperator>("IslandAnalyzer", "The operator used to analyze each island."));
            Parameters.Add(new LookupParameter <IntValue>("EvaluatedSolutions", "The number of times a solution has been evaluated."));
            Parameters.Add(new LookupParameter <IntValue>("IslandGenerations", "The number of generations calculated on one island."));
            Parameters.Add(new LookupParameter <IntValue>("IslandEvaluatedSolutions", "The number of times a solution has been evaluated on one island."));
            Parameters.Add(new ValueLookupParameter <BoolValue>("Migrate", "Migrate the island?"));
            #endregion

            #region Create operators
            VariableCreator           variableCreator            = new VariableCreator();
            UniformSubScopesProcessor uniformSubScopesProcessor0 = new UniformSubScopesProcessor();
            VariableCreator           islandVariableCreator      = new VariableCreator();
            Placeholder               islandAnalyzer1            = new Placeholder();
            LocalRandomCreator        localRandomCreator         = new LocalRandomCreator();
            Placeholder               analyzer1                  = new Placeholder();
            ResultsCollector          resultsCollector1          = new ResultsCollector();
            UniformSubScopesProcessor uniformSubScopesProcessor1 = new UniformSubScopesProcessor();
            Assigner                  generationsAssigner        = new Assigner();
            Assigner                  evaluatedSolutionsAssigner = new Assigner();
            Placeholder               selector                   = new Placeholder();
            SubScopesProcessor        subScopesProcessor1        = new SubScopesProcessor();
            ChildrenCreator           childrenCreator            = new ChildrenCreator();
            UniformSubScopesProcessor uniformSubScopesProcessor2 = new UniformSubScopesProcessor();
            Placeholder               crossover                  = new Placeholder();
            StochasticBranch          stochasticBranch           = new StochasticBranch();
            Placeholder               mutator                              = new Placeholder();
            SubScopesRemover          subScopesRemover                     = new SubScopesRemover();
            UniformSubScopesProcessor uniformSubScopesProcessor3           = new UniformSubScopesProcessor();
            Placeholder               evaluator                            = new Placeholder();
            SubScopesCounter          subScopesCounter                     = new SubScopesCounter();
            SubScopesProcessor        subScopesProcessor2                  = new SubScopesProcessor();
            BestSelector              bestSelector                         = new BestSelector();
            RightReducer              rightReducer                         = new RightReducer();
            MergingReducer            mergingReducer                       = new MergingReducer();
            IntCounter                islandGenerationsCounter             = new IntCounter();
            Comparator                checkIslandGenerationsReachedMaximum = new Comparator();
            ConditionalBranch         checkContinueEvolution               = new ConditionalBranch();
            DataReducer               generationsReducer                   = new DataReducer();
            DataReducer               evaluatedSolutionsReducer            = new DataReducer();
            Placeholder               islandAnalyzer2                      = new Placeholder();
            UniformSubScopesProcessor uniformSubScopesProcessor5           = new UniformSubScopesProcessor();
            Placeholder               emigrantsSelector                    = new Placeholder();
            IntCounter                migrationsCounter                    = new IntCounter();
            Placeholder               migrator                             = new Placeholder();
            UniformSubScopesProcessor uniformSubScopesProcessor6           = new UniformSubScopesProcessor();
            Placeholder               immigrationReplacer                  = new Placeholder();
            Comparator                generationsComparator                = new Comparator();
            Placeholder               analyzer2                            = new Placeholder();
            ConditionalBranch         generationsTerminationCondition      = new ConditionalBranch();
            ConditionalBranch         reevaluateElitesBranch               = new ConditionalBranch();


            variableCreator.CollectedValues.Add(new ValueParameter <IntValue>("Migrations", new IntValue(0)));
            variableCreator.CollectedValues.Add(new ValueParameter <IntValue>("GenerationsSinceLastMigration", new IntValue(0)));
            variableCreator.CollectedValues.Add(new ValueParameter <IntValue>("Generations", new IntValue(0))); // Class IslandGeneticAlgorithm expects this to be called Generations

            islandVariableCreator.CollectedValues.Add(new ValueParameter <ResultCollection>("Results", new ResultCollection()));
            islandVariableCreator.CollectedValues.Add(new ValueParameter <IntValue>("IslandGenerations", new IntValue(0)));
            islandVariableCreator.CollectedValues.Add(new ValueParameter <IntValue>("IslandEvaluatedSolutions", new IntValue(0)));

            islandAnalyzer1.Name = "Island Analyzer (placeholder)";
            islandAnalyzer1.OperatorParameter.ActualName = IslandAnalyzerParameter.Name;

            analyzer1.Name = "Analyzer (placeholder)";
            analyzer1.OperatorParameter.ActualName = AnalyzerParameter.Name;

            resultsCollector1.CollectedValues.Add(new LookupParameter <IntValue>("Migrations"));
            resultsCollector1.CollectedValues.Add(new LookupParameter <IntValue>("Generations"));
            resultsCollector1.CollectedValues.Add(new ScopeTreeLookupParameter <ResultCollection>("IslandResults", "Result set for each island", "Results"));
            resultsCollector1.ResultsParameter.ActualName = ResultsParameter.Name;

            uniformSubScopesProcessor1.Parallel.Value = true;

            generationsAssigner.Name = "Initialize Island Generations";
            generationsAssigner.LeftSideParameter.ActualName = IslandGenerations.Name;
            generationsAssigner.RightSideParameter.Value     = new IntValue(0);

            evaluatedSolutionsAssigner.Name = "Initialize Island evaluated solutions";
            evaluatedSolutionsAssigner.LeftSideParameter.ActualName = IslandEvaluatedSolutions.Name;
            evaluatedSolutionsAssigner.RightSideParameter.Value     = new IntValue(0);

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

            childrenCreator.ParentsPerChild = new IntValue(2);

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

            stochasticBranch.ProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
            //set it to the random number generator of the island
            stochasticBranch.RandomParameter.ActualName = "LocalRandom";

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

            subScopesRemover.RemoveAllSubScopes = true;

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

            subScopesCounter.Name = "Increment EvaluatedSolutions";
            subScopesCounter.ValueParameter.ActualName = IslandEvaluatedSolutions.Name;

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

            islandGenerationsCounter.Name = "Increment island generatrions";
            islandGenerationsCounter.ValueParameter.ActualName = IslandGenerations.Name;
            islandGenerationsCounter.Increment = new IntValue(1);

            checkIslandGenerationsReachedMaximum.LeftSideParameter.ActualName  = IslandGenerations.Name;
            checkIslandGenerationsReachedMaximum.RightSideParameter.ActualName = MigrationIntervalParameter.Name;
            checkIslandGenerationsReachedMaximum.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
            checkIslandGenerationsReachedMaximum.ResultParameter.ActualName = Migrate.Name;

            checkContinueEvolution.Name = "Migrate?";
            checkContinueEvolution.ConditionParameter.ActualName = Migrate.Name;
            checkContinueEvolution.FalseBranch = selector;

            islandAnalyzer2.Name = "Island Analyzer (placeholder)";
            islandAnalyzer2.OperatorParameter.ActualName = IslandAnalyzerParameter.Name;

            generationsReducer.Name = "Increment Generations";
            generationsReducer.ParameterToReduce.ActualName = islandGenerationsCounter.ValueParameter.ActualName;
            generationsReducer.TargetParameter.ActualName   = "Generations";
            generationsReducer.ReductionOperation.Value     = new ReductionOperation(ReductionOperations.Min);
            generationsReducer.TargetOperation.Value        = new ReductionOperation(ReductionOperations.Sum);

            evaluatedSolutionsReducer.Name = "Increment Evaluated Solutions";
            evaluatedSolutionsReducer.ParameterToReduce.ActualName = IslandEvaluatedSolutions.Name;
            evaluatedSolutionsReducer.TargetParameter.ActualName   = EvaluatedSolutionsParameter.Name;
            evaluatedSolutionsReducer.ReductionOperation.Value     = new ReductionOperation(ReductionOperations.Sum);
            evaluatedSolutionsReducer.TargetOperation.Value        = new ReductionOperation(ReductionOperations.Sum);

            emigrantsSelector.Name = "Emigrants Selector (placeholder)";
            emigrantsSelector.OperatorParameter.ActualName = EmigrantsSelectorParameter.Name;

            migrationsCounter.Name = "Increment number of Migrations";
            migrationsCounter.ValueParameter.ActualName = "Migrations";
            migrationsCounter.Increment = new IntValue(1);

            migrator.Name = "Migrator (placeholder)";
            migrator.OperatorParameter.ActualName = MigratorParameter.Name;

            immigrationReplacer.Name = "Immigration Replacer (placeholder)";
            immigrationReplacer.OperatorParameter.ActualName = ImmigrationReplacerParameter.Name;

            generationsComparator.Name       = "Generations >= MaximumGenerations ?";
            generationsComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
            generationsComparator.LeftSideParameter.ActualName  = "Generations";
            generationsComparator.ResultParameter.ActualName    = "TerminateGenerations";
            generationsComparator.RightSideParameter.ActualName = MaximumGenerationsParameter.Name;

            analyzer2.Name = "Analyzer (placeholder)";
            analyzer2.OperatorParameter.ActualName = AnalyzerParameter.Name;

            generationsTerminationCondition.Name = "Terminate?";
            generationsTerminationCondition.ConditionParameter.ActualName = "TerminateGenerations";

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

            #region Create operator graph
            OperatorGraph.InitialOperator        = variableCreator;
            variableCreator.Successor            = uniformSubScopesProcessor0;
            uniformSubScopesProcessor0.Operator  = islandVariableCreator;
            uniformSubScopesProcessor0.Successor = analyzer1;
            islandVariableCreator.Successor      = islandAnalyzer1;
            // BackwardsCompatibility3.3
            //the local randoms are created by the island GA itself and are only here to ensure same algorithm results
            #region Backwards compatible code, remove local random creator with 3.4 and rewire the operator graph
            islandAnalyzer1.Successor    = localRandomCreator;
            localRandomCreator.Successor = null;
            #endregion
            analyzer1.Successor                  = resultsCollector1;
            resultsCollector1.Successor          = uniformSubScopesProcessor1;
            uniformSubScopesProcessor1.Operator  = generationsAssigner;
            uniformSubScopesProcessor1.Successor = generationsReducer;
            generationsReducer.Successor         = evaluatedSolutionsReducer;
            evaluatedSolutionsReducer.Successor  = migrationsCounter;
            migrationsCounter.Successor          = uniformSubScopesProcessor5;
            generationsAssigner.Successor        = evaluatedSolutionsAssigner;
            evaluatedSolutionsAssigner.Successor = selector;
            selector.Successor = subScopesProcessor1;
            subScopesProcessor1.Operators.Add(new EmptyOperator());
            subScopesProcessor1.Operators.Add(childrenCreator);
            subScopesProcessor1.Successor        = subScopesProcessor2;
            childrenCreator.Successor            = uniformSubScopesProcessor2;
            uniformSubScopesProcessor2.Operator  = crossover;
            uniformSubScopesProcessor2.Successor = uniformSubScopesProcessor3;
            crossover.Successor                  = stochasticBranch;
            stochasticBranch.FirstBranch         = mutator;
            stochasticBranch.SecondBranch        = null;
            stochasticBranch.Successor           = subScopesRemover;
            mutator.Successor                    = null;
            subScopesRemover.Successor           = null;
            uniformSubScopesProcessor3.Operator  = evaluator;
            uniformSubScopesProcessor3.Successor = subScopesCounter;
            evaluator.Successor                  = null;
            subScopesCounter.Successor           = null;
            subScopesProcessor2.Operators.Add(bestSelector);
            subScopesProcessor2.Operators.Add(new EmptyOperator());
            subScopesProcessor2.Successor                  = mergingReducer;
            mergingReducer.Successor                       = islandAnalyzer2;
            bestSelector.Successor                         = rightReducer;
            rightReducer.Successor                         = reevaluateElitesBranch;
            reevaluateElitesBranch.TrueBranch              = uniformSubScopesProcessor3;
            reevaluateElitesBranch.FalseBranch             = null;
            reevaluateElitesBranch.Successor               = null;
            islandAnalyzer2.Successor                      = islandGenerationsCounter;
            islandGenerationsCounter.Successor             = checkIslandGenerationsReachedMaximum;
            checkIslandGenerationsReachedMaximum.Successor = checkContinueEvolution;
            uniformSubScopesProcessor5.Operator            = emigrantsSelector;
            emigrantsSelector.Successor                    = null;
            uniformSubScopesProcessor5.Successor           = migrator;
            migrator.Successor = uniformSubScopesProcessor6;
            uniformSubScopesProcessor6.Operator  = immigrationReplacer;
            uniformSubScopesProcessor6.Successor = generationsComparator;
            generationsComparator.Successor      = analyzer2;
            analyzer2.Successor = generationsTerminationCondition;
            generationsTerminationCondition.TrueBranch  = null;
            generationsTerminationCondition.FalseBranch = uniformSubScopesProcessor1;
            generationsTerminationCondition.Successor   = null;
            #endregion
        }
    private void Initialize() {
      #region Create parameters
      Parameters.Add(new ValueLookupParameter<IMultiAnalyzer>("Analyzer", "The analyzer used to analyze each iteration."));
      Parameters.Add(new ValueLookupParameter<DoubleValue>("BestKnownQuality", "The best known quality value found so far."));
      Parameters.Add(new ValueLookupParameter<ICrossover>("Crossover", "The operator used to cross solutions."));
      Parameters.Add(new ValueLookupParameter<IntValue>("EvaluatedSolutions", "The number of times solutions have been evaluated."));
      Parameters.Add(new ValueLookupParameter<IEvaluator>("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<BoolValue>("ExecutePathRelinking", "True if path relinking should be executed instead of crossover, otherwise false."));
      Parameters.Add(new ValueLookupParameter<IImprovementOperator>("Improver", "The operator used to improve solutions."));
      Parameters.Add(new ValueLookupParameter<IntValue>("Iterations", "The number of iterations performed."));
      Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem, otherwise false."));
      Parameters.Add(new ValueLookupParameter<IntValue>("MaximumIterations", "The maximum number of iterations which should be processed."));
      Parameters.Add(new ValueLookupParameter<IntValue>("NumberOfHighQualitySolutions", "The number of high quality solutions in the reference set."));
      Parameters.Add(new ValueLookupParameter<IPathRelinker>("PathRelinker", "The operator used to execute path relinking."));
      Parameters.Add(new ValueLookupParameter<IntValue>("PopulationSize", "The size of the population of solutions."));
      Parameters.Add(new ValueLookupParameter<IntValue>("ReferenceSetSize", "The size of the reference set."));
      Parameters.Add(new ValueLookupParameter<DoubleValue>("Quality", "This parameter is used for name translation only."));
      Parameters.Add(new ValueLookupParameter<IRandom>("Random", "A pseudo random number generator."));
      Parameters.Add(new ValueLookupParameter<VariableCollection>("Results", "The variable collection where results should be stored."));
      Parameters.Add(new ValueLookupParameter<ISolutionSimilarityCalculator>("SimilarityCalculator", "The operator used to calculate the similarity between two solutions."));
      #endregion

      #region Create operators
      Placeholder analyzer = new Placeholder();
      Assigner assigner1 = new Assigner();
      Assigner assigner2 = new Assigner();
      ChildrenCreator childrenCreator = new ChildrenCreator();
      Placeholder crossover = new Placeholder();
      Comparator iterationsChecker = new Comparator();
      IntCounter iterationsCounter = new IntCounter();
      MergingReducer mergingReducer = new MergingReducer();
      ConditionalBranch executePathRelinkingBranch = new ConditionalBranch();
      ConditionalBranch newSolutionsBranch = new ConditionalBranch();
      OffspringProcessor offspringProcessor = new OffspringProcessor();
      Placeholder pathRelinker = new Placeholder();
      PopulationRebuildMethod populationRebuildMethod = new PopulationRebuildMethod();
      ReferenceSetUpdateMethod referenceSetUpdateMethod = new ReferenceSetUpdateMethod();
      ResultsCollector resultsCollector = new ResultsCollector();
      RightSelector rightSelector = new RightSelector();
      Placeholder solutionEvaluator1 = new Placeholder();
      Placeholder solutionEvaluator2 = new Placeholder();
      Placeholder solutionImprover1 = new Placeholder();
      Placeholder solutionImprover2 = new Placeholder();
      SolutionPoolUpdateMethod solutionPoolUpdateMethod = new SolutionPoolUpdateMethod();
      SolutionsCreator solutionsCreator = new SolutionsCreator();
      DataReducer dataReducer1 = new DataReducer();
      DataReducer dataReducer2 = new DataReducer();
      SubScopesProcessor subScopesProcessor1 = new SubScopesProcessor();
      SubScopesProcessor subScopesProcessor2 = new SubScopesProcessor();
      SubScopesProcessor subScopesProcessor3 = new SubScopesProcessor();
      SubScopesProcessor subScopesProcessor4 = new SubScopesProcessor();
      ConditionalBranch terminateBranch = new ConditionalBranch();
      UniformSubScopesProcessor uniformSubScopesProcessor1 = new UniformSubScopesProcessor();
      UniformSubScopesProcessor uniformSubScopesProcessor2 = new UniformSubScopesProcessor();
      UniformSubScopesProcessor uniformSubScopesProcessor3 = new UniformSubScopesProcessor();
      VariableCreator variableCreator = new VariableCreator();
      #endregion

      #region Create operator graph
      OperatorGraph.InitialOperator = variableCreator;
      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>(IterationsParameter.Name, new IntValue(0)));
      variableCreator.CollectedValues.Add(new ValueParameter<BoolValue>("NewSolutions", new BoolValue(false)));
      variableCreator.Successor = resultsCollector;

      resultsCollector.CopyValue = new BoolValue(false);
      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>(IterationsParameter.Name));
      resultsCollector.ResultsParameter.ActualName = ResultsParameter.Name;
      resultsCollector.Successor = iterationsChecker;

      iterationsChecker.Name = "IterationsChecker";
      iterationsChecker.Comparison.Value = ComparisonType.GreaterOrEqual;
      iterationsChecker.LeftSideParameter.ActualName = IterationsParameter.Name;
      iterationsChecker.RightSideParameter.ActualName = MaximumIterationsParameter.Name;
      iterationsChecker.ResultParameter.ActualName = "Terminate";
      iterationsChecker.Successor = terminateBranch;

      terminateBranch.Name = "TerminateChecker";
      terminateBranch.ConditionParameter.ActualName = "Terminate";
      terminateBranch.FalseBranch = referenceSetUpdateMethod;

      referenceSetUpdateMethod.Successor = assigner1;

      assigner1.Name = "NewSolutions = true";
      assigner1.LeftSideParameter.ActualName = "NewSolutions";
      assigner1.RightSideParameter.Value = new BoolValue(true);
      assigner1.Successor = subScopesProcessor1;

      subScopesProcessor1.DepthParameter.Value = new IntValue(1);
      subScopesProcessor1.Operators.Add(new EmptyOperator());
      subScopesProcessor1.Operators.Add(childrenCreator);
      subScopesProcessor1.Successor = newSolutionsBranch;

      childrenCreator.Name = "SubsetGenerator";
      childrenCreator.ParentsPerChildParameter.Value = new IntValue(2);
      childrenCreator.Successor = assigner2;

      assigner2.Name = "NewSolutions = false";
      assigner2.LeftSideParameter.ActualName = "NewSolutions";
      assigner2.RightSideParameter.Value = new BoolValue(false);
      assigner2.Successor = uniformSubScopesProcessor1;

      uniformSubScopesProcessor1.DepthParameter.Value = new IntValue(1);
      uniformSubScopesProcessor1.Operator = executePathRelinkingBranch;
      uniformSubScopesProcessor1.Successor = solutionPoolUpdateMethod;

      executePathRelinkingBranch.Name = "ExecutePathRelinkingChecker";
      executePathRelinkingBranch.ConditionParameter.ActualName = ExecutePathRelinkingParameter.ActualName;
      executePathRelinkingBranch.TrueBranch = pathRelinker;
      executePathRelinkingBranch.FalseBranch = crossover;

      pathRelinker.Name = "PathRelinker";
      pathRelinker.OperatorParameter.ActualName = PathRelinkerParameter.Name;
      pathRelinker.Successor = rightSelector;

      crossover.Name = "Crossover";
      crossover.OperatorParameter.ActualName = CrossoverParameter.Name;
      crossover.Successor = offspringProcessor;

      offspringProcessor.Successor = rightSelector;

      rightSelector.NumberOfSelectedSubScopesParameter.Value = new IntValue(1);
      rightSelector.CopySelected = new BoolValue(false);
      rightSelector.Successor = subScopesProcessor2;

      subScopesProcessor2.DepthParameter.Value = new IntValue(1);
      subScopesProcessor2.Operators.Add(new EmptyOperator());
      subScopesProcessor2.Operators.Add(uniformSubScopesProcessor2);
      subScopesProcessor2.Successor = mergingReducer;

      uniformSubScopesProcessor2.DepthParameter.Value = new IntValue(2);
      uniformSubScopesProcessor2.Operator = solutionImprover1;
      uniformSubScopesProcessor2.ParallelParameter.Value = new BoolValue(true);
      uniformSubScopesProcessor2.Successor = subScopesProcessor4;

      solutionImprover1.Name = "SolutionImprover";
      solutionImprover1.OperatorParameter.ActualName = ImproverParameter.Name;
      solutionImprover1.Successor = solutionEvaluator1;

      solutionEvaluator1.Name = "SolutionEvaluator";
      solutionEvaluator1.OperatorParameter.ActualName = EvaluatorParameter.Name;

      subScopesProcessor4.Operators.Add(dataReducer1);

      dataReducer1.Name = "Increment EvaluatedSolutions";
      dataReducer1.ParameterToReduce.ActualName = "LocalEvaluatedSolutions";
      dataReducer1.TargetParameter.ActualName = EvaluatedSolutionsParameter.Name;
      dataReducer1.ReductionOperation.Value = new ReductionOperation(ReductionOperations.Sum);
      dataReducer1.TargetOperation.Value = new ReductionOperation(ReductionOperations.Sum);

      solutionPoolUpdateMethod.QualityParameter.ActualName = QualityParameter.ActualName;
      solutionPoolUpdateMethod.Successor = analyzer;

      analyzer.Name = "Analyzer";
      analyzer.OperatorParameter.ActualName = AnalyzerParameter.Name;

      newSolutionsBranch.Name = "NewSolutionsChecker";
      newSolutionsBranch.ConditionParameter.ActualName = "NewSolutions";
      newSolutionsBranch.TrueBranch = subScopesProcessor1;
      newSolutionsBranch.FalseBranch = populationRebuildMethod;

      populationRebuildMethod.QualityParameter.ActualName = QualityParameter.ActualName;
      populationRebuildMethod.Successor = subScopesProcessor3;

      subScopesProcessor3.DepthParameter.Value = new IntValue(1);
      subScopesProcessor3.Operators.Add(solutionsCreator);
      subScopesProcessor3.Operators.Add(new EmptyOperator());
      subScopesProcessor3.Successor = iterationsCounter;

      solutionsCreator.Name = "DiversificationGenerationMethod";
      solutionsCreator.NumberOfSolutionsParameter.ActualName = PopulationSizeParameter.Name;
      solutionsCreator.Successor = uniformSubScopesProcessor3;

      uniformSubScopesProcessor3.DepthParameter.Value = new IntValue(1);
      uniformSubScopesProcessor3.Operator = solutionImprover2;
      uniformSubScopesProcessor3.ParallelParameter.Value = new BoolValue(true);
      uniformSubScopesProcessor3.Successor = dataReducer2;

      solutionImprover2.Name = "SolutionImprover";
      solutionImprover2.OperatorParameter.ActualName = ImproverParameter.Name;
      solutionImprover2.Successor = solutionEvaluator2;

      solutionEvaluator2.Name = "SolutionEvaluator";
      solutionEvaluator2.OperatorParameter.ActualName = EvaluatorParameter.Name;

      dataReducer2.Name = "Increment EvaluatedSolutions";
      dataReducer2.ParameterToReduce.ActualName = "LocalEvaluatedSolutions";
      dataReducer2.TargetParameter.ActualName = EvaluatedSolutionsParameter.Name;
      dataReducer2.ReductionOperation.Value = new ReductionOperation(ReductionOperations.Sum);
      dataReducer2.TargetOperation.Value = new ReductionOperation(ReductionOperations.Sum);

      iterationsCounter.Name = "IterationCounter";
      iterationsCounter.IncrementParameter.Value = new IntValue(1);
      iterationsCounter.ValueParameter.ActualName = IterationsParameter.Name;
      iterationsCounter.Successor = resultsCollector;
      #endregion
    }