public OffspringSelectionEvolutionStrategy()
      : base() {
      Parameters.Add(new ValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
      Parameters.Add(new ValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
      Parameters.Add(new ValueParameter<IntValue>("PopulationSize", "µ (mu) - the size of the population.", new IntValue(20)));
      Parameters.Add(new ValueParameter<IntValue>("ParentsPerChild", "ρ (rho) - how many parents should be recombined.", new IntValue(1)));
      Parameters.Add(new ValueParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed.", new IntValue(1000)));
      Parameters.Add(new ValueParameter<BoolValue>("PlusSelection", "True for plus selection (elitist population), false for comma selection (non-elitist population).", new BoolValue(true)));
      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 OptionalConstrainedValueParameter<ICrossover>("Recombinator", "The operator used to cross solutions."));
      Parameters.Add(new ConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
      Parameters.Add(new OptionalConstrainedValueParameter<IStrategyParameterCreator>("StrategyParameterCreator", "The operator that creates the strategy parameters."));
      Parameters.Add(new OptionalConstrainedValueParameter<IStrategyParameterCrossover>("StrategyParameterCrossover", "The operator that recombines the strategy parameters."));
      Parameters.Add(new OptionalConstrainedValueParameter<IStrategyParameterManipulator>("StrategyParameterManipulator", "The operator that manipulates the strategy parameters."));
      Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze each generation.", new MultiAnalyzer()));

      Parameters.Add(new ValueLookupParameter<DoubleValue>("SuccessRatio", "The ratio of successful to total children that should be achieved.", new DoubleValue(1)));
      Parameters.Add(new ValueLookupParameter<IntValue>("SelectedParents", "How much parents should be selected each time the offspring selection step is performed until the population is filled. This parameter should be about the same or twice the size of PopulationSize for smaller problems, and less for large problems.", new IntValue(40)));
      Parameters.Add(new ValueLookupParameter<DoubleValue>("MaximumSelectionPressure", "The maximum selection pressure that terminates the algorithm.", new DoubleValue(100)));
      Parameters.Add(new ValueParameter<IntValue>("MaximumEvaluatedSolutions", "The maximum number of evaluated solutions.", new IntValue(int.MaxValue)));
      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].", new DoubleValue(0.5)));



      RandomCreator randomCreator = new RandomCreator();
      SolutionsCreator solutionsCreator = new SolutionsCreator();
      SubScopesCounter subScopesCounter = new SubScopesCounter();
      UniformSubScopesProcessor strategyVectorProcessor = new UniformSubScopesProcessor();
      Placeholder strategyVectorCreator = new Placeholder();
      ResultsCollector resultsCollector = new ResultsCollector();
      OffspringSelectionEvolutionStrategyMainLoop mainLoop = new OffspringSelectionEvolutionStrategyMainLoop();
      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.NumberOfSolutionsParameter.ActualName = PopulationSizeParameter.Name;
      solutionsCreator.Successor = subScopesCounter;

      subScopesCounter.Name = "Initialize EvaluatedSolutions";
      subScopesCounter.ValueParameter.ActualName = "EvaluatedSolutions";
      subScopesCounter.Successor = strategyVectorProcessor;

      strategyVectorProcessor.Operator = strategyVectorCreator;
      strategyVectorProcessor.Successor = resultsCollector;

      strategyVectorCreator.OperatorParameter.ActualName = "StrategyParameterCreator";

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

      mainLoop.RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
      mainLoop.PopulationSizeParameter.ActualName = PopulationSizeParameter.Name;
      mainLoop.ParentsPerChildParameter.ActualName = ParentsPerChildParameter.Name;
      mainLoop.MaximumGenerationsParameter.ActualName = MaximumGenerationsParameter.Name;
      mainLoop.PlusSelectionParameter.ActualName = PlusSelectionParameter.Name;
      mainLoop.ReevaluateElitesParameter.ActualName = ReevaluateElitesParameter.Name;
      mainLoop.MutatorParameter.ActualName = MutatorParameter.Name;
      mainLoop.RecombinatorParameter.ActualName = RecombinatorParameter.Name;
      mainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name;
      mainLoop.ResultsParameter.ActualName = "Results";
      mainLoop.EvaluatedSolutionsParameter.ActualName = "EvaluatedSolutions";

      mainLoop.SuccessRatioParameter.ActualName = SuccessRatioParameter.Name;
      mainLoop.MaximumSelectionPressureParameter.ActualName = MaximumSelectionPressureParameter.Name;
      mainLoop.MaximumEvaluatedSolutionsParameter.ActualName = MaximumEvaluatedSolutionsParameter.Name;
      mainLoop.SelectedParentsParameter.ActualName = SelectedParentsParameter.Name;
      mainLoop.ComparisonFactorParameter.ActualName = ComparisonFactorParameter.Name;
      mainLoop.CurrentSuccessRatioParameter.ActualName = "CurrentSuccessRatio";
      mainLoop.SelectionPressureParameter.ActualName = "SelectionPressure";

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

      Initialize();
    }
 private RobustTabooSearch(RobustTabooSearch original, Cloner cloner)
   : base(original, cloner) {
   solutionsCreator = cloner.Clone(original.solutionsCreator);
   mainOperator = cloner.Clone(original.mainOperator);
   qualityAnalyzer = cloner.Clone(original.qualityAnalyzer);
   RegisterEventHandlers();
 }
    public RobustTabooSearch() {
      Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The analyzers that are applied after each iteration.", new MultiAnalyzer()));
      Parameters.Add(new FixedValueParameter<IntValue>("Seed", "The seed value of the random number generator.", new IntValue(0)));
      Parameters.Add(new FixedValueParameter<BoolValue>("SetSeedRandomly", "True whether the seed should be set randomly for each run, false if it should be fixed.", new BoolValue(true)));
      Parameters.Add(new FixedValueParameter<IntValue>("MaximumIterations", "The number of iterations that the algorithm should run.", new IntValue(10000)));
      Parameters.Add(new FixedValueParameter<IntValue>("MinimumTabuTenure", "The minimum tabu tenure.", new IntValue(10)));
      Parameters.Add(new FixedValueParameter<IntValue>("MaximumTabuTenure", "The maximum tabu tenure.", new IntValue(20)));
      Parameters.Add(new FixedValueParameter<BoolValue>("UseAlternativeAspiration", "True if the alternative aspiration condition should be used that takes moves that have not been made for some time above others.", new BoolValue(false)));
      Parameters.Add(new FixedValueParameter<IntValue>("AlternativeAspirationTenure", "The time t that a move will be remembered for the alternative aspiration condition.", new IntValue(int.MaxValue)));
      Parameters.Add(new FixedValueParameter<BoolValue>("TerminateOnOptimalSolution", "True when the algorithm should stop if it reached a quality equal or smaller to the BestKnownQuality.", new BoolValue(false)));
      Parameters.Add(new FixedValueParameter<BoolValue>("UseNewTabuTenureAdaptionScheme", @"In an updated version of his implementation, Eric Taillard introduced a different way to change the tabu tenure.
Instead of setting it uniformly between min and max, it will be set between 0 and max according to a right-skewed distribution.
Set this option to false if you want to optimize using the earlier 1991 version, and set to true if you want to optimize using the newer version.
Please note that the MinimumTabuTenure parameter has no effect in the new version.", new BoolValue(true)));

      TerminateOnOptimalSolutionParameter.Hidden = true;

      qualityAnalyzer = new BestAverageWorstQualityAnalyzer();
      qualityAnalyzer.ResultsParameter.ActualName = "Results";
      AnalyzerParameter.Value.Operators.Add(qualityAnalyzer);

      RandomCreator randomCreator = new RandomCreator();
      randomCreator.RandomParameter.ActualName = "Random";
      randomCreator.SeedParameter.Value = null;
      randomCreator.SeedParameter.ActualName = SeedParameter.Name;
      randomCreator.SetSeedRandomlyParameter.Value = null;
      randomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameter.Name;

      VariableCreator variableCreator = new VariableCreator();
      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Iterations", new IntValue(0)));
      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedSolutions", new IntValue(1)));
      variableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("EvaluatedSolutionEquivalents", new DoubleValue(1)));

      ResultsCollector resultsCollector = new ResultsCollector();
      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Iterations", "The actual iteration."));
      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "Number of evaluated solutions."));

      solutionsCreator = new SolutionsCreator();
      solutionsCreator.NumberOfSolutions = new IntValue(1);

      Placeholder analyzer = new Placeholder();
      analyzer.Name = "(Analyzer)";
      analyzer.OperatorParameter.ActualName = AnalyzerParameter.Name;

      UniformSubScopesProcessor ussp = new UniformSubScopesProcessor();

      mainOperator = new RobustTabooSeachOperator();
      mainOperator.AlternativeAspirationTenureParameter.ActualName = AlternativeAspirationTenureParameter.Name;
      mainOperator.BestQualityParameter.ActualName = "BestSoFarQuality";
      mainOperator.IterationsParameter.ActualName = "Iterations";
      mainOperator.LastMoveParameter.ActualName = "LastMove";
      mainOperator.MaximumIterationsParameter.ActualName = MaximumIterationsParameter.Name;
      mainOperator.MaximumTabuTenureParameter.ActualName = MaximumTabuTenureParameter.Name;
      mainOperator.MinimumTabuTenureParameter.ActualName = MinimumTabuTenureParameter.Name;
      mainOperator.MoveQualityMatrixParameter.ActualName = "MoveQualityMatrix";
      mainOperator.RandomParameter.ActualName = "Random";
      mainOperator.ResultsParameter.ActualName = "Results";
      mainOperator.ShortTermMemoryParameter.ActualName = "ShortTermMemory";
      mainOperator.UseAlternativeAspirationParameter.ActualName = UseAlternativeAspirationParameter.Name;
      mainOperator.EvaluatedSolutionsParameter.ActualName = "EvaluatedSolutions";
      mainOperator.EvaluatedSolutionEquivalentsParameter.ActualName = "EvaluatedSolutionEquivalents";

      ConditionalBranch qualityStopBranch = new ConditionalBranch();
      qualityStopBranch.Name = "Terminate on optimal quality?";
      qualityStopBranch.ConditionParameter.ActualName = "TerminateOnOptimalSolution";

      Comparator qualityComparator = new Comparator();
      qualityComparator.Comparison = new Comparison(ComparisonType.Greater);
      qualityComparator.LeftSideParameter.ActualName = "BestQuality";
      qualityComparator.RightSideParameter.ActualName = "BestKnownQuality";
      qualityComparator.ResultParameter.ActualName = "ContinueByQuality";

      ConditionalBranch continueByQualityBranch = new ConditionalBranch();
      continueByQualityBranch.ConditionParameter.ActualName = "ContinueByQuality";

      IntCounter iterationsCounter = new IntCounter();
      iterationsCounter.ValueParameter.ActualName = "Iterations";
      iterationsCounter.Increment = new IntValue(1);

      Comparator comparator = new Comparator();
      comparator.Name = "Iterations < MaximumIterations ?";
      comparator.LeftSideParameter.ActualName = "Iterations";
      comparator.RightSideParameter.ActualName = MaximumIterationsParameter.Name;
      comparator.Comparison = new Comparison(ComparisonType.Less);
      comparator.ResultParameter.ActualName = "ContinueByIteration";

      ConditionalBranch continueByIterationBranch = new ConditionalBranch();
      continueByIterationBranch.ConditionParameter.ActualName = "ContinueByIteration";

      OperatorGraph.InitialOperator = randomCreator;
      randomCreator.Successor = variableCreator;
      variableCreator.Successor = resultsCollector;
      resultsCollector.Successor = solutionsCreator;
      solutionsCreator.Successor = analyzer;
      analyzer.Successor = ussp;
      ussp.Operator = mainOperator;
      ussp.Successor = qualityStopBranch;
      qualityStopBranch.FalseBranch = iterationsCounter;
      qualityStopBranch.TrueBranch = qualityComparator;
      qualityStopBranch.Successor = null;
      qualityComparator.Successor = continueByQualityBranch;
      continueByQualityBranch.TrueBranch = iterationsCounter;
      continueByQualityBranch.FalseBranch = null;
      continueByQualityBranch.Successor = null;
      iterationsCounter.Successor = comparator;
      comparator.Successor = continueByIterationBranch;
      continueByIterationBranch.TrueBranch = analyzer;
      continueByIterationBranch.FalseBranch = null;
      continueByIterationBranch.Successor = null;

      RegisterEventHandlers();
      Problem = new QuadraticAssignmentProblem();
    }
    private CombinedOperator CreateReseeder() {
      var reseeder = new CombinedOperator() { Name = "Reseed Layer Zero if needed" };
      var reseedingController = new ReseedingController() { Name = "Reseeding needed (Generation % AgeGap == 0)?" };
      var removeIndividuals = new SubScopesRemover();
      var createIndividuals = new SolutionsCreator();
      var initializeAgeProsessor = new UniformSubScopesProcessor();
      var initializeAge = new VariableCreator() { Name = "Initialize Age" };
      var incrEvaluatedSolutionsAfterReseeding = new SubScopesCounter() { Name = "Update EvaluatedSolutions" };

      reseeder.OperatorGraph.InitialOperator = reseedingController;

      reseedingController.GenerationsParameter.ActualName = "Generations";
      reseedingController.AgeGapParameter.ActualName = AgeGapParameter.Name;
      reseedingController.FirstLayerOperator = removeIndividuals;
      reseedingController.Successor = null;

      removeIndividuals.Successor = createIndividuals;

      createIndividuals.NumberOfSolutionsParameter.ActualName = PopulationSizeParameter.Name;
      createIndividuals.Successor = initializeAgeProsessor;

      initializeAgeProsessor.Operator = initializeAge;
      initializeAgeProsessor.Successor = incrEvaluatedSolutionsAfterReseeding;

      initializeAge.CollectedValues.Add(new ValueParameter<DoubleValue>(AgeParameter.Name, new DoubleValue(0)));

      incrEvaluatedSolutionsAfterReseeding.ValueParameter.ActualName = EvaluatedSolutionsParameter.Name;
      incrEvaluatedSolutionsAfterReseeding.AccumulateParameter.Value = new BoolValue(true);

      return reseeder;
    }
    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();
    }
    public SimulatedAnnealing()
      : base() {
      Parameters.Add(new ValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
      Parameters.Add(new ValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
      Parameters.Add(new ConstrainedValueParameter<IMultiMoveGenerator>("MoveGenerator", "The operator used to generate moves to the neighborhood of the current solution."));
      Parameters.Add(new ConstrainedValueParameter<ISingleObjectiveMoveEvaluator>("MoveEvaluator", "The operator used to evaluate a move."));
      Parameters.Add(new ConstrainedValueParameter<IMoveMaker>("MoveMaker", "The operator used to perform a move."));
      Parameters.Add(new ConstrainedValueParameter<IDiscreteDoubleValueModifier>("AnnealingOperator", "The operator used to modify the temperature."));
      Parameters.Add(new ValueParameter<IntValue>("MaximumIterations", "The maximum number of generations which should be processed.", new IntValue(100)));
      Parameters.Add(new ValueParameter<IntValue>("InnerIterations", "The amount of inner iterations (number of moves before temperature is adjusted again).", new IntValue(10)));
      Parameters.Add(new ValueParameter<DoubleValue>("StartTemperature", "The initial temperature.", new DoubleValue(100)));
      Parameters.Add(new ValueParameter<DoubleValue>("EndTemperature", "The final temperature which should be reached when iterations reaches maximum iterations.", new DoubleValue(1e-6)));
      Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze each generation.", new MultiAnalyzer()));

      RandomCreator randomCreator = new RandomCreator();
      SolutionsCreator solutionsCreator = new SolutionsCreator();
      VariableCreator variableCreator = new VariableCreator();
      ResultsCollector resultsCollector = new ResultsCollector();
      SimulatedAnnealingMainLoop mainLoop = new SimulatedAnnealingMainLoop();
      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.NumberOfSolutions = new IntValue(1);
      solutionsCreator.Successor = variableCreator;

      variableCreator.Name = "Initialize EvaluatedMoves";
      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedMoves", new IntValue()));
      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Iterations", new IntValue(0)));
      variableCreator.Successor = resultsCollector;

      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Moves", null, "EvaluatedMoves"));
      resultsCollector.ResultsParameter.ActualName = "Results";
      resultsCollector.Successor = mainLoop;

      mainLoop.MoveGeneratorParameter.ActualName = MoveGeneratorParameter.Name;
      mainLoop.MoveEvaluatorParameter.ActualName = MoveEvaluatorParameter.Name;
      mainLoop.MoveMakerParameter.ActualName = MoveMakerParameter.Name;
      mainLoop.AnnealingOperatorParameter.ActualName = AnnealingOperatorParameter.Name;
      mainLoop.MaximumIterationsParameter.ActualName = MaximumIterationsParameter.Name;
      mainLoop.TemperatureParameter.ActualName = "Temperature";
      mainLoop.StartTemperatureParameter.ActualName = StartTemperatureParameter.Name;
      mainLoop.EndTemperatureParameter.ActualName = EndTemperatureParameter.Name;
      mainLoop.RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
      mainLoop.ResultsParameter.ActualName = "Results";
      mainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name;
      mainLoop.EvaluatedMovesParameter.ActualName = "EvaluatedMoves";
      mainLoop.IterationsParameter.ActualName = "Iterations";

      foreach (IDiscreteDoubleValueModifier op in ApplicationManager.Manager.GetInstances<IDiscreteDoubleValueModifier>().OrderBy(x => x.Name))
        AnnealingOperatorParameter.ValidValues.Add(op);
      ParameterizeAnnealingOperators();

      qualityAnalyzer = new QualityAnalyzer();
      temperatureAnalyzer = new SingleValueAnalyzer();
      temperatureAnalyzer.Name = "TemperatureAnalyzer";
      ParameterizeAnalyzers();
      UpdateAnalyzers();

      Initialize();
    }
    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
    }
Beispiel #8
0
    public NSGA2() {
      Parameters.Add(new ValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
      Parameters.Add(new ValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
      Parameters.Add(new ValueParameter<IntValue>("PopulationSize", "The size of the population of solutions.", new IntValue(100)));
      Parameters.Add(new ConstrainedValueParameter<ISelector>("Selector", "The operator used to select solutions for reproduction."));
      Parameters.Add(new ValueParameter<PercentValue>("CrossoverProbability", "The probability that the crossover operator is applied on two parents.", new PercentValue(0.9)));
      Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions."));
      Parameters.Add(new ValueParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new PercentValue(0.05)));
      Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
      Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze each generation.", new MultiAnalyzer()));
      Parameters.Add(new ValueParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed.", new IntValue(1000)));
      Parameters.Add(new ValueParameter<IntValue>("SelectedParents", "Each two parents form a new child, typically this value should be twice the population size, but because the NSGA-II is maximally elitist it can be any multiple of 2 greater than 0.", new IntValue(200)));
      Parameters.Add(new FixedValueParameter<BoolValue>("DominateOnEqualQualities", "Flag which determines wether solutions with equal quality values should be treated as dominated.", new BoolValue(false)));

      RandomCreator randomCreator = new RandomCreator();
      SolutionsCreator solutionsCreator = new SolutionsCreator();
      SubScopesCounter subScopesCounter = new SubScopesCounter();
      RankAndCrowdingSorter rankAndCrowdingSorter = new RankAndCrowdingSorter();
      ResultsCollector resultsCollector = new ResultsCollector();
      NSGA2MainLoop mainLoop = new NSGA2MainLoop();

      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.NumberOfSolutionsParameter.ActualName = PopulationSizeParameter.Name;
      solutionsCreator.Successor = subScopesCounter;

      subScopesCounter.Name = "Initialize EvaluatedSolutions";
      subScopesCounter.ValueParameter.ActualName = "EvaluatedSolutions";
      subScopesCounter.Successor = rankAndCrowdingSorter;

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

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

      mainLoop.PopulationSizeParameter.ActualName = PopulationSizeParameter.Name;
      mainLoop.SelectorParameter.ActualName = SelectorParameter.Name;
      mainLoop.CrossoverParameter.ActualName = CrossoverParameter.Name;
      mainLoop.CrossoverProbabilityParameter.ActualName = CrossoverProbabilityParameter.Name;
      mainLoop.MaximumGenerationsParameter.ActualName = MaximumGenerationsParameter.Name;
      mainLoop.MutatorParameter.ActualName = MutatorParameter.Name;
      mainLoop.MutationProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
      mainLoop.RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
      mainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name;
      mainLoop.ResultsParameter.ActualName = "Results";
      mainLoop.EvaluatedSolutionsParameter.ActualName = "EvaluatedSolutions";

      foreach (ISelector selector in ApplicationManager.Manager.GetInstances<ISelector>().Where(x => !(x is ISingleObjectiveSelector)).OrderBy(x => x.Name))
        SelectorParameter.ValidValues.Add(selector);
      ISelector tournamentSelector = SelectorParameter.ValidValues.FirstOrDefault(x => x.GetType().Name.Equals("CrowdedTournamentSelector"));
      if (tournamentSelector != null) SelectorParameter.Value = tournamentSelector;

      ParameterizeSelectors();

      paretoFrontAnalyzer = new RankBasedParetoFrontAnalyzer();
      paretoFrontAnalyzer.RankParameter.ActualName = "Rank";
      paretoFrontAnalyzer.RankParameter.Depth = 1;
      paretoFrontAnalyzer.ResultsParameter.ActualName = "Results";
      ParameterizeAnalyzers();
      UpdateAnalyzers();

      AfterDeserialization();
    }
    public VariableNeighborhoodSearch()
      : base() {
      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 ConstrainedValueParameter<ILocalImprovementOperator>("LocalImprovement", "The local improvement operation"));
      Parameters.Add(new ConstrainedValueParameter<IMultiNeighborhoodShakingOperator>("ShakingOperator", "The operator that performs the shaking of solutions."));
      Parameters.Add(new FixedValueParameter<IntValue>("MaximumIterations", "The maximum number of iterations which should be processed.", new IntValue(50)));
      Parameters.Add(new FixedValueParameter<IntValue>("LocalImprovementMaximumIterations", "The maximum number of iterations which should be performed in the local improvement phase.", new IntValue(50)));
      Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze the solution and moves.", new MultiAnalyzer()));

      RandomCreator randomCreator = new RandomCreator();
      SolutionsCreator solutionsCreator = new SolutionsCreator();
      VariableCreator variableCreator = new VariableCreator();
      ResultsCollector resultsCollector = new ResultsCollector();
      VariableNeighborhoodSearchMainLoop mainLoop = new VariableNeighborhoodSearchMainLoop();
      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.NumberOfSolutions = new IntValue(1);
      solutionsCreator.Successor = variableCreator;

      variableCreator.Name = "Initialize Evaluated Solutions";

      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Iterations", new IntValue(0)));
      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedSolutions", new IntValue(0)));
      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("CurrentNeighborhoodIndex", new IntValue(0)));
      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("NeighborhoodCount", new IntValue(0)));
      variableCreator.Successor = resultsCollector;

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

      mainLoop.IterationsParameter.ActualName = "Iterations";
      mainLoop.CurrentNeighborhoodIndexParameter.ActualName = "CurrentNeighborhoodIndex";
      mainLoop.NeighborhoodCountParameter.ActualName = "NeighborhoodCount";
      mainLoop.LocalImprovementParameter.ActualName = LocalImprovementParameter.Name;
      mainLoop.ShakingOperatorParameter.ActualName = ShakingOperatorParameter.Name;
      mainLoop.MaximumIterationsParameter.ActualName = MaximumIterationsParameter.Name;
      mainLoop.RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
      mainLoop.ResultsParameter.ActualName = "Results";
      mainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name;
      mainLoop.EvaluatedSolutionsParameter.ActualName = "EvaluatedSolutions";

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

      RegisterEventHandlers();
    }
Beispiel #10
0
    public LocalSearch()
      : base() {
      Parameters.Add(new ValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
      Parameters.Add(new ValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
      Parameters.Add(new ConstrainedValueParameter<IMoveGenerator>("MoveGenerator", "The operator used to generate moves to the neighborhood of the current solution."));
      Parameters.Add(new ConstrainedValueParameter<IMoveMaker>("MoveMaker", "The operator used to perform a move."));
      Parameters.Add(new ConstrainedValueParameter<ISingleObjectiveMoveEvaluator>("MoveEvaluator", "The operator used to evaluate a move."));
      Parameters.Add(new ValueParameter<IntValue>("MaximumIterations", "The maximum number of generations which should be processed.", new IntValue(1000)));
      Parameters.Add(new ValueParameter<IntValue>("SampleSize", "Number of moves that MultiMoveGenerators should create. This is ignored for Exhaustive- and SingleMoveGenerators.", new IntValue(100)));
      Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze the solution and moves.", new MultiAnalyzer()));

      RandomCreator randomCreator = new RandomCreator();
      SolutionsCreator solutionsCreator = new SolutionsCreator();
      VariableCreator variableCreator = new VariableCreator();
      ResultsCollector resultsCollector = new ResultsCollector();
      LocalSearchMainLoop mainLoop = new LocalSearchMainLoop();
      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.NumberOfSolutions = new IntValue(1);
      solutionsCreator.Successor = variableCreator;

      variableCreator.Name = "Initialize EvaluatedMoves";
      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedMoves", new IntValue()));
      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Iterations", new IntValue(0)));
      variableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("BestQuality", new DoubleValue(0)));
      variableCreator.Successor = resultsCollector;

      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Moves", null, "EvaluatedMoves"));
      resultsCollector.ResultsParameter.ActualName = "Results";
      resultsCollector.Successor = mainLoop;

      mainLoop.MoveGeneratorParameter.ActualName = MoveGeneratorParameter.Name;
      mainLoop.MoveMakerParameter.ActualName = MoveMakerParameter.Name;
      mainLoop.MoveEvaluatorParameter.ActualName = MoveEvaluatorParameter.Name;
      mainLoop.MaximumIterationsParameter.ActualName = MaximumIterationsParameter.Name;
      mainLoop.RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
      mainLoop.ResultsParameter.ActualName = "Results";
      mainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name;
      mainLoop.EvaluatedMovesParameter.ActualName = "EvaluatedMoves";
      mainLoop.IterationsParameter.ActualName = "Iterations";
      mainLoop.BestLocalQualityParameter.ActualName = "BestQuality";

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

      Initialize();
    }
    public GeneticAlgorithm()
      : base() {
      Parameters.Add(new ValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
      Parameters.Add(new ValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
      Parameters.Add(new ValueParameter<IntValue>("PopulationSize", "The size of the population of solutions.", new IntValue(100)));
      Parameters.Add(new ConstrainedValueParameter<ISelector>("Selector", "The operator used to select solutions for reproduction."));
      Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions."));
      Parameters.Add(new ValueParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new PercentValue(0.05)));
      Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
      Parameters.Add(new ValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1)));
      Parameters.Add(new FixedValueParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)", new BoolValue(false)) { Hidden = true });
      Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze each generation.", new MultiAnalyzer()));
      Parameters.Add(new ValueParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed.", new IntValue(1000)));

      RandomCreator randomCreator = new RandomCreator();
      SolutionsCreator solutionsCreator = new SolutionsCreator();
      SubScopesCounter subScopesCounter = new SubScopesCounter();
      ResultsCollector resultsCollector = new ResultsCollector();
      GeneticAlgorithmMainLoop mainLoop = new GeneticAlgorithmMainLoop();
      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.NumberOfSolutionsParameter.ActualName = PopulationSizeParameter.Name;
      solutionsCreator.Successor = subScopesCounter;

      subScopesCounter.Name = "Initialize EvaluatedSolutions";
      subScopesCounter.ValueParameter.ActualName = "EvaluatedSolutions";
      subScopesCounter.Successor = resultsCollector;

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

      mainLoop.SelectorParameter.ActualName = SelectorParameter.Name;
      mainLoop.CrossoverParameter.ActualName = CrossoverParameter.Name;
      mainLoop.ElitesParameter.ActualName = ElitesParameter.Name;
      mainLoop.ReevaluateElitesParameter.ActualName = ReevaluateElitesParameter.Name;
      mainLoop.MaximumGenerationsParameter.ActualName = MaximumGenerationsParameter.Name;
      mainLoop.MutatorParameter.ActualName = MutatorParameter.Name;
      mainLoop.MutationProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
      mainLoop.RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
      mainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name;
      mainLoop.EvaluatedSolutionsParameter.ActualName = "EvaluatedSolutions";
      mainLoop.PopulationSizeParameter.ActualName = PopulationSizeParameter.Name;
      mainLoop.ResultsParameter.ActualName = "Results";

      foreach (ISelector selector in ApplicationManager.Manager.GetInstances<ISelector>().Where(x => !(x is IMultiObjectiveSelector)).OrderBy(x => x.Name))
        SelectorParameter.ValidValues.Add(selector);
      ISelector proportionalSelector = SelectorParameter.ValidValues.FirstOrDefault(x => x.GetType().Name.Equals("ProportionalSelector"));
      if (proportionalSelector != null) SelectorParameter.Value = proportionalSelector;
      ParameterizeSelectors();

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

      Initialize();
    }
    public EvolutionStrategy()
      : base() {
      Parameters.Add(new ValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
      Parameters.Add(new ValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
      Parameters.Add(new ValueParameter<IntValue>("PopulationSize", "µ (mu) - the size of the population.", new IntValue(20)));
      Parameters.Add(new ValueParameter<IntValue>("ParentsPerChild", "ρ (rho) - how many parents should be recombined.", new IntValue(1)));
      Parameters.Add(new ValueParameter<IntValue>("Children", "λ (lambda) - the size of the offspring population.", new IntValue(100)));
      Parameters.Add(new ValueParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed.", new IntValue(1000)));
      Parameters.Add(new ValueParameter<BoolValue>("PlusSelection", "True for plus selection (elitist population), false for comma selection (non-elitist population).", new BoolValue(true)));
      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 OptionalConstrainedValueParameter<ICrossover>("Recombinator", "The operator used to cross solutions."));
      Parameters.Add(new ConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
      Parameters.Add(new OptionalConstrainedValueParameter<IStrategyParameterCreator>("StrategyParameterCreator", "The operator that creates the strategy parameters."));
      Parameters.Add(new OptionalConstrainedValueParameter<IStrategyParameterCrossover>("StrategyParameterCrossover", "The operator that recombines the strategy parameters."));
      Parameters.Add(new OptionalConstrainedValueParameter<IStrategyParameterManipulator>("StrategyParameterManipulator", "The operator that manipulates the strategy parameters."));
      Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze each generation.", new MultiAnalyzer()));

      RandomCreator randomCreator = new RandomCreator();
      SolutionsCreator solutionsCreator = new SolutionsCreator();
      SubScopesCounter subScopesCounter = new SubScopesCounter();
      UniformSubScopesProcessor strategyVectorProcessor = new UniformSubScopesProcessor();
      Placeholder strategyVectorCreator = new Placeholder();
      ResultsCollector resultsCollector = new ResultsCollector();
      EvolutionStrategyMainLoop mainLoop = new EvolutionStrategyMainLoop();
      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.NumberOfSolutionsParameter.ActualName = PopulationSizeParameter.Name;
      solutionsCreator.Successor = subScopesCounter;

      subScopesCounter.Name = "Initialize EvaluatedSolutions";
      subScopesCounter.ValueParameter.ActualName = "EvaluatedSolutions";
      subScopesCounter.Successor = strategyVectorProcessor;

      strategyVectorProcessor.Operator = strategyVectorCreator;
      strategyVectorProcessor.Successor = resultsCollector;

      strategyVectorCreator.OperatorParameter.ActualName = "StrategyParameterCreator";

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

      mainLoop.RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
      mainLoop.PopulationSizeParameter.ActualName = PopulationSizeParameter.Name;
      mainLoop.ParentsPerChildParameter.ActualName = ParentsPerChildParameter.Name;
      mainLoop.ChildrenParameter.ActualName = ChildrenParameter.Name;
      mainLoop.MaximumGenerationsParameter.ActualName = MaximumGenerationsParameter.Name;
      mainLoop.PlusSelectionParameter.ActualName = PlusSelectionParameter.Name;
      mainLoop.ReevaluateElitesParameter.ActualName = ReevaluateElitesParameter.Name;
      mainLoop.MutatorParameter.ActualName = MutatorParameter.Name;
      mainLoop.RecombinatorParameter.ActualName = RecombinatorParameter.Name;
      mainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name;
      mainLoop.ResultsParameter.ActualName = "Results";
      mainLoop.EvaluatedSolutionsParameter.ActualName = "EvaluatedSolutions";

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

      Initialize();
    }
    public IslandGeneticAlgorithm()
      : base() {
      Parameters.Add(new ValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
      Parameters.Add(new ValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
      Parameters.Add(new ValueParameter<IntValue>("NumberOfIslands", "The number of islands.", new IntValue(5)));
      Parameters.Add(new ValueParameter<IntValue>("MigrationInterval", "The number of generations that should pass between migration phases.", new IntValue(20)));
      Parameters.Add(new ValueParameter<PercentValue>("MigrationRate", "The proportion of individuals that should migrate between the islands.", new PercentValue(0.15)));
      Parameters.Add(new ConstrainedValueParameter<IMigrator>("Migrator", "The migration strategy."));
      Parameters.Add(new ConstrainedValueParameter<ISelector>("EmigrantsSelector", "Selects the individuals that will be migrated."));
      Parameters.Add(new ConstrainedValueParameter<IReplacer>("ImmigrationReplacer", "Selects the population from the unification of the original population and the immigrants."));
      Parameters.Add(new ValueParameter<IntValue>("PopulationSize", "The size of the population of solutions.", new IntValue(100)));
      Parameters.Add(new ValueParameter<IntValue>("MaximumGenerations", "The maximum number of generations that should be processed.", new IntValue(1000)));
      Parameters.Add(new ConstrainedValueParameter<ISelector>("Selector", "The operator used to select solutions for reproduction."));
      Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions."));
      Parameters.Add(new ValueParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new PercentValue(0.05)));
      Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
      Parameters.Add(new ValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1)));
      Parameters.Add(new FixedValueParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)", new BoolValue(false)) { Hidden = true });
      Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze the islands.", new MultiAnalyzer()));
      Parameters.Add(new ValueParameter<MultiAnalyzer>("IslandAnalyzer", "The operator used to analyze each island.", new MultiAnalyzer()));

      RandomCreator randomCreator = new RandomCreator();
      UniformSubScopesProcessor ussp0 = new UniformSubScopesProcessor();
      LocalRandomCreator localRandomCreator = new LocalRandomCreator();
      RandomCreator globalRandomResetter = new RandomCreator();
      SubScopesCreator populationCreator = new SubScopesCreator();
      UniformSubScopesProcessor ussp1 = new UniformSubScopesProcessor();
      SolutionsCreator solutionsCreator = new SolutionsCreator();
      VariableCreator variableCreator = new VariableCreator();
      UniformSubScopesProcessor ussp2 = new UniformSubScopesProcessor();
      SubScopesCounter subScopesCounter = new SubScopesCounter();
      ResultsCollector resultsCollector = new ResultsCollector();
      IslandGeneticAlgorithmMainLoop mainLoop = new IslandGeneticAlgorithmMainLoop();
      OperatorGraph.InitialOperator = randomCreator;

      randomCreator.RandomParameter.ActualName = "GlobalRandom";
      randomCreator.SeedParameter.ActualName = SeedParameter.Name;
      randomCreator.SeedParameter.Value = null;
      randomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameter.Name;
      randomCreator.SetSeedRandomlyParameter.Value = null;
      randomCreator.Successor = populationCreator;

      populationCreator.NumberOfSubScopesParameter.ActualName = NumberOfIslandsParameter.Name;
      populationCreator.Successor = ussp0;

      ussp0.Operator = localRandomCreator;
      ussp0.Successor = globalRandomResetter;

      // BackwardsCompatibility3.3
      // the global random is resetted to ensure the same algorithm results
      #region Backwards compatible code, remove global random resetter with 3.4 and rewire the operator graph
      globalRandomResetter.RandomParameter.ActualName = "GlobalRandom";
      globalRandomResetter.SeedParameter.ActualName = SeedParameter.Name;
      globalRandomResetter.SeedParameter.Value = null;
      globalRandomResetter.SetSeedRandomlyParameter.Value = new BoolValue(false);
      globalRandomResetter.Successor = ussp1;
      #endregion

      ussp1.Operator = solutionsCreator;
      ussp1.Successor = variableCreator;

      solutionsCreator.NumberOfSolutionsParameter.ActualName = PopulationSizeParameter.Name;
      //don't create solutions in parallel because the hive engine would distribute these tasks
      solutionsCreator.ParallelParameter.Value = new BoolValue(false);
      solutionsCreator.Successor = null;

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

      ussp2.Operator = subScopesCounter;
      ussp2.Successor = resultsCollector;

      subScopesCounter.Name = "Count EvaluatedSolutions";
      subScopesCounter.ValueParameter.ActualName = "EvaluatedSolutions";
      subScopesCounter.Successor = null;

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

      mainLoop.EmigrantsSelectorParameter.ActualName = EmigrantsSelectorParameter.Name;
      mainLoop.ImmigrationReplacerParameter.ActualName = ImmigrationReplacerParameter.Name;
      mainLoop.MaximumGenerationsParameter.ActualName = MaximumGenerationsParameter.Name;
      mainLoop.MigrationIntervalParameter.ActualName = MigrationIntervalParameter.Name;
      mainLoop.MigrationRateParameter.ActualName = MigrationRateParameter.Name;
      mainLoop.MigratorParameter.ActualName = MigratorParameter.Name;
      mainLoop.NumberOfIslandsParameter.ActualName = NumberOfIslandsParameter.Name;
      mainLoop.SelectorParameter.ActualName = SelectorParameter.Name;
      mainLoop.CrossoverParameter.ActualName = CrossoverParameter.Name;
      mainLoop.ElitesParameter.ActualName = ElitesParameter.Name;
      mainLoop.ReevaluateElitesParameter.ActualName = ReevaluateElitesParameter.Name;
      mainLoop.MutatorParameter.ActualName = MutatorParameter.Name;
      mainLoop.MutationProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
      mainLoop.RandomParameter.ActualName = randomCreator.RandomParameter.ActualName;
      mainLoop.ResultsParameter.ActualName = "Results";
      mainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name;
      mainLoop.IslandAnalyzerParameter.ActualName = IslandAnalyzerParameter.Name;
      mainLoop.EvaluatedSolutionsParameter.ActualName = "EvaluatedSolutions";
      mainLoop.Successor = null;

      foreach (ISelector selector in ApplicationManager.Manager.GetInstances<ISelector>().Where(x => !(x is IMultiObjectiveSelector)).OrderBy(x => x.Name))
        SelectorParameter.ValidValues.Add(selector);
      ISelector proportionalSelector = SelectorParameter.ValidValues.FirstOrDefault(x => x.GetType().Name.Equals("ProportionalSelector"));
      if (proportionalSelector != null) SelectorParameter.Value = proportionalSelector;

      foreach (ISelector selector in ApplicationManager.Manager.GetInstances<ISelector>().Where(x => !(x is IMultiObjectiveSelector)).OrderBy(x => x.Name))
        EmigrantsSelectorParameter.ValidValues.Add(selector);

      foreach (IReplacer replacer in ApplicationManager.Manager.GetInstances<IReplacer>().OrderBy(x => x.Name))
        ImmigrationReplacerParameter.ValidValues.Add(replacer);

      ParameterizeSelectors();

      foreach (IMigrator migrator in ApplicationManager.Manager.GetInstances<IMigrator>().OrderBy(x => x.Name)) {
        // BackwardsCompatibility3.3
        // Set the migration direction to counterclockwise
        var unidirectionalRing = migrator as UnidirectionalRingMigrator;
        if (unidirectionalRing != null) unidirectionalRing.ClockwiseMigrationParameter.Value = new BoolValue(false);
        MigratorParameter.ValidValues.Add(migrator);
      }

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

      Initialize();
    }
    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();
    }
 private ParticleSwarmOptimization(ParticleSwarmOptimization original, Cloner cloner)
   : base(original, cloner) {
   qualityAnalyzer = cloner.Clone(original.qualityAnalyzer);
   solutionsCreator = cloner.Clone(original.solutionsCreator);
   mainLoop = cloner.Clone(original.mainLoop);
   Initialize();
 }
    public RandomSearchAlgorithm()
      : 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 the solutions each iteration.", new MultiAnalyzer()));
      Parameters.Add(new FixedValueParameter<IntValue>("MaximumEvaluatedSolutions", "The number of random solutions the algorithm should evaluate.", new IntValue(1000)));
      Parameters.Add(new FixedValueParameter<IntValue>("BatchSize", "The number of random solutions that are evaluated (in parallel) per iteration.", new IntValue(100)));
      Parameters.Add(new FixedValueParameter<IntValue>("MaximumIterations", "The number of iterations that the algorithm will run.", new IntValue(10)) { Hidden = true });
      Parameters.Add(new FixedValueParameter<MultiTerminator>("Terminator", "The termination criteria that defines if the algorithm should continue or stop.", new MultiTerminator()) { Hidden = true });
      #endregion

      #region Create operators
      var randomCreator = new RandomCreator();
      var variableCreator = new VariableCreator() { Name = "Initialize Variables" };
      var resultsCollector = new ResultsCollector();
      var solutionCreator = new SolutionsCreator() { Name = "Create Solutions" };
      var analyzerPlaceholder = new Placeholder() { Name = "Analyzer (Placeholder)" };
      var evaluationsCounter = new IntCounter() { Name = "Increment EvaluatedSolutions" };
      var subScopesRemover = new SubScopesRemover();
      var iterationsCounter = new IntCounter() { Name = "Increment Iterations" };
      var terminationOperator = new TerminationOperator();
      #endregion

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

      randomCreator.SeedParameter.Value = null;
      randomCreator.SeedParameter.ActualName = SeedParameter.Name;
      randomCreator.SetSeedRandomlyParameter.Value = null;
      randomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameter.Name;
      randomCreator.Successor = variableCreator;

      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Iterations", new IntValue(0)));
      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedSolutions", new IntValue(0)));
      variableCreator.Successor = resultsCollector;

      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Iterations", "The current iteration number."));
      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "The current number of evaluated solutions."));
      resultsCollector.Successor = solutionCreator;

      solutionCreator.NumberOfSolutionsParameter.ActualName = BatchSizeParameter.Name;
      solutionCreator.ParallelParameter.Value.Value = true;
      solutionCreator.Successor = evaluationsCounter;

      evaluationsCounter.ValueParameter.ActualName = "EvaluatedSolutions";
      evaluationsCounter.Increment = null;
      evaluationsCounter.IncrementParameter.ActualName = BatchSizeParameter.Name;
      evaluationsCounter.Successor = analyzerPlaceholder;

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

      subScopesRemover.RemoveAllSubScopes = true;
      subScopesRemover.Successor = iterationsCounter;

      iterationsCounter.ValueParameter.ActualName = "Iterations";
      iterationsCounter.Increment = new IntValue(1);
      iterationsCounter.Successor = terminationOperator;

      terminationOperator.TerminatorParameter.ActualName = TerminatorParameter.Name;
      terminationOperator.ContinueBranch = solutionCreator;
      #endregion

      #region Create analyzers
      singleObjectiveQualityAnalyzer = new BestAverageWorstQualityAnalyzer();
      #endregion

      #region Create terminators
      evaluationsTerminator = new ComparisonTerminator<IntValue>("EvaluatedSolutions", ComparisonType.Less, MaximumEvaluatedSolutionsParameter) { Name = "Evaluated solutions." };
      qualityTerminator = new SingleObjectiveQualityTerminator() { Name = "Quality" };
      executionTimeTerminator = new ExecutionTimeTerminator(this, new TimeSpanValue(TimeSpan.FromMinutes(5)));
      #endregion

      #region Parameterize
      UpdateAnalyzers();
      ParameterizeAnalyzers();
      UpdateTerminators();
      #endregion

      Initialize();
    }
    public ParticleSwarmOptimization()
      : base() {
      Parameters.Add(new ValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
      Parameters.Add(new ValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
      Parameters.Add(new ValueParameter<IntValue>("SwarmSize", "Size of the particle swarm.", new IntValue(10)));
      Parameters.Add(new ValueParameter<IntValue>("MaxIterations", "Maximal number of iterations.", new IntValue(1000)));
      Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze each generation.", new MultiAnalyzer()));
      Parameters.Add(new ValueParameter<DoubleValue>("Inertia", "Inertia weight on a particle's movement (omega).", new DoubleValue(1)));
      Parameters.Add(new ValueParameter<DoubleValue>("PersonalBestAttraction", "Weight for particle's pull towards its personal best soution (phi_p).", new DoubleValue(-0.01)));
      Parameters.Add(new ValueParameter<DoubleValue>("NeighborBestAttraction", "Weight for pull towards the neighborhood best solution or global best solution in case of a totally connected topology (phi_g).", new DoubleValue(3.7)));
      Parameters.Add(new ConstrainedValueParameter<IParticleCreator>("ParticleCreator", "Operator that creates a new particle."));
      Parameters.Add(new ConstrainedValueParameter<IParticleUpdater>("ParticleUpdater", "Operator that updates a particle."));
      Parameters.Add(new OptionalConstrainedValueParameter<ITopologyInitializer>("TopologyInitializer", "Creates neighborhood description vectors."));
      Parameters.Add(new OptionalConstrainedValueParameter<ITopologyUpdater>("TopologyUpdater", "Updates the neighborhood description vectors."));
      Parameters.Add(new OptionalConstrainedValueParameter<IDiscreteDoubleValueModifier>("InertiaUpdater", "Updates the omega parameter."));
      Parameters.Add(new ConstrainedValueParameter<ISwarmUpdater>("SwarmUpdater", "Encoding-specific parameter which is provided by the problem. May provide additional encoding-specific parameters, such as velocity bounds for real valued problems"));
      ParticleUpdaterParameter.Hidden = true;

      RandomCreator randomCreator = new RandomCreator();
      VariableCreator variableCreator = new VariableCreator();
      Assigner currentInertiaAssigner = new Assigner();
      solutionsCreator = new SolutionsCreator();
      SubScopesCounter subScopesCounter = new SubScopesCounter();
      Placeholder topologyInitializerPlaceholder = new Placeholder();
      mainLoop = new ParticleSwarmOptimizationMainLoop();

      OperatorGraph.InitialOperator = randomCreator;

      randomCreator.SetSeedRandomlyParameter.Value = null;
      randomCreator.SeedParameter.Value = null;
      randomCreator.Successor = variableCreator;

      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Iterations", new IntValue(0)));
      variableCreator.Successor = currentInertiaAssigner;

      currentInertiaAssigner.Name = "CurrentInertia := Inertia";
      currentInertiaAssigner.LeftSideParameter.ActualName = "CurrentInertia";
      currentInertiaAssigner.RightSideParameter.ActualName = "Inertia";
      currentInertiaAssigner.Successor = solutionsCreator;

      solutionsCreator.NumberOfSolutionsParameter.ActualName = "SwarmSize";
      ParameterizeSolutionsCreator();
      solutionsCreator.Successor = subScopesCounter;

      subScopesCounter.Name = "Initialize EvaluatedSolutions";
      subScopesCounter.ValueParameter.ActualName = "EvaluatedSolutions";
      subScopesCounter.Successor = topologyInitializerPlaceholder;

      topologyInitializerPlaceholder.Name = "(TopologyInitializer)";
      topologyInitializerPlaceholder.OperatorParameter.ActualName = "TopologyInitializer";
      topologyInitializerPlaceholder.Successor = mainLoop;

      mainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name;
      mainLoop.InertiaParameter.ActualName = "CurrentInertia";
      mainLoop.MaxIterationsParameter.ActualName = MaxIterationsParameter.Name;
      mainLoop.NeighborBestAttractionParameter.ActualName = NeighborBestAttractionParameter.Name;
      mainLoop.InertiaUpdaterParameter.ActualName = InertiaUpdaterParameter.Name;
      mainLoop.ParticleUpdaterParameter.ActualName = ParticleUpdaterParameter.Name;
      mainLoop.PersonalBestAttractionParameter.ActualName = PersonalBestAttractionParameter.Name;
      mainLoop.RandomParameter.ActualName = randomCreator.RandomParameter.ActualName;
      mainLoop.SwarmSizeParameter.ActualName = SwarmSizeParameter.Name;
      mainLoop.TopologyUpdaterParameter.ActualName = TopologyUpdaterParameter.Name;
      mainLoop.RandomParameter.ActualName = randomCreator.RandomParameter.ActualName;
      mainLoop.ResultsParameter.ActualName = "Results";

      InitializeAnalyzers();
      InitializeParticleCreator();
      InitializeSwarmUpdater();
      ParameterizeSolutionsCreator();
      UpdateAnalyzers();
      UpdateInertiaUpdater();
      InitInertiaUpdater();
      UpdateTopologyInitializer();
      Initialize();
      ParameterizeMainLoop();
    }
    public OffspringSelectionGeneticAlgorithm()
      : base() {
      Parameters.Add(new ValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
      Parameters.Add(new ValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
      Parameters.Add(new ValueParameter<IntValue>("PopulationSize", "The size of the population of solutions.", new IntValue(100)));
      Parameters.Add(new ConstrainedValueParameter<ISelector>("Selector", "The operator used to select solutions for reproduction."));
      Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions."));
      Parameters.Add(new ValueParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new PercentValue(0.05)));
      Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
      Parameters.Add(new ValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1)));
      Parameters.Add(new FixedValueParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)", new BoolValue(false)) { Hidden = true });
      Parameters.Add(new ValueParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed.", new IntValue(1000)));
      Parameters.Add(new ValueLookupParameter<DoubleValue>("SuccessRatio", "The ratio of successful to total children that should be achieved.", new DoubleValue(1)));
      Parameters.Add(new ValueLookupParameter<DoubleValue>("ComparisonFactorLowerBound", "The lower bound of the comparison factor (start).", new DoubleValue(0)));
      Parameters.Add(new ValueLookupParameter<DoubleValue>("ComparisonFactorUpperBound", "The upper bound of the comparison factor (end).", new DoubleValue(1)));
      Parameters.Add(new OptionalConstrainedValueParameter<IDiscreteDoubleValueModifier>("ComparisonFactorModifier", "The operator used to modify the comparison factor.", new ItemSet<IDiscreteDoubleValueModifier>(new IDiscreteDoubleValueModifier[] { new LinearDiscreteDoubleValueModifier() }), new LinearDiscreteDoubleValueModifier()));
      Parameters.Add(new ValueLookupParameter<DoubleValue>("MaximumSelectionPressure", "The maximum selection pressure that terminates the algorithm.", new DoubleValue(100)));
      Parameters.Add(new ValueLookupParameter<BoolValue>("OffspringSelectionBeforeMutation", "True if the offspring selection step should be applied before mutation, false if it should be applied after mutation.", new BoolValue(false)));
      Parameters.Add(new ValueLookupParameter<IntValue>("SelectedParents", "How much parents should be selected each time the offspring selection step is performed until the population is filled. This parameter should be about the same or twice the size of PopulationSize for smaller problems, and less for large problems.", new IntValue(200)));
      Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze each generation.", new MultiAnalyzer()));
      Parameters.Add(new ValueParameter<IntValue>("MaximumEvaluatedSolutions", "The maximum number of evaluated solutions (approximately).", new IntValue(int.MaxValue)));
      Parameters.Add(new FixedValueParameter<BoolValue>("FillPopulationWithParents", "True if the population should be filled with parent individual or false if worse children should be used when the maximum selection pressure is exceeded.", new BoolValue(false)) { Hidden = true });

      RandomCreator randomCreator = new RandomCreator();
      SolutionsCreator solutionsCreator = new SolutionsCreator();
      SubScopesCounter subScopesCounter = new SubScopesCounter();
      ResultsCollector resultsCollector = new ResultsCollector();
      OffspringSelectionGeneticAlgorithmMainLoop mainLoop = new OffspringSelectionGeneticAlgorithmMainLoop();
      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.NumberOfSolutionsParameter.ActualName = PopulationSizeParameter.Name;
      solutionsCreator.Successor = subScopesCounter;

      subScopesCounter.Name = "Initialize EvaluatedSolutions";
      subScopesCounter.ValueParameter.ActualName = "EvaluatedSolutions";
      subScopesCounter.Successor = resultsCollector;

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

      mainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name;
      mainLoop.ComparisonFactorModifierParameter.ActualName = ComparisonFactorModifierParameter.Name;
      mainLoop.ComparisonFactorParameter.ActualName = "ComparisonFactor";
      mainLoop.ComparisonFactorStartParameter.ActualName = ComparisonFactorLowerBoundParameter.Name;
      mainLoop.CrossoverParameter.ActualName = CrossoverParameter.Name;
      mainLoop.ElitesParameter.ActualName = ElitesParameter.Name;
      mainLoop.ReevaluateElitesParameter.ActualName = ReevaluateElitesParameter.Name;
      mainLoop.EvaluatedSolutionsParameter.ActualName = "EvaluatedSolutions";
      mainLoop.MaximumGenerationsParameter.ActualName = MaximumGenerationsParameter.Name;
      mainLoop.MaximumSelectionPressureParameter.ActualName = MaximumSelectionPressureParameter.Name;
      mainLoop.MutationProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
      mainLoop.MutatorParameter.ActualName = MutatorParameter.Name;
      mainLoop.OffspringSelectionBeforeMutationParameter.ActualName = OffspringSelectionBeforeMutationParameter.Name;
      mainLoop.RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
      mainLoop.ResultsParameter.ActualName = "Results";
      mainLoop.SelectorParameter.ActualName = SelectorParameter.Name;
      mainLoop.SuccessRatioParameter.ActualName = SuccessRatioParameter.Name;
      mainLoop.FillPopulationWithParentsParameter.ActualName = FillPopulationWithParentsParameter.Name;

      foreach (ISelector selector in ApplicationManager.Manager.GetInstances<ISelector>().Where(x => !(x is IMultiObjectiveSelector)).OrderBy(x => x.Name))
        SelectorParameter.ValidValues.Add(selector);
      ISelector proportionalSelector = SelectorParameter.ValidValues.FirstOrDefault(x => x.GetType().Name.Equals("ProportionalSelector"));
      if (proportionalSelector != null) SelectorParameter.Value = proportionalSelector;
      ParameterizeSelectors();

      foreach (IDiscreteDoubleValueModifier modifier in ApplicationManager.Manager.GetInstances<IDiscreteDoubleValueModifier>().OrderBy(x => x.Name))
        ComparisonFactorModifierParameter.ValidValues.Add(modifier);
      IDiscreteDoubleValueModifier linearModifier = ComparisonFactorModifierParameter.ValidValues.FirstOrDefault(x => x.GetType().Name.Equals("LinearDiscreteDoubleValueModifier"));
      if (linearModifier != null) ComparisonFactorModifierParameter.Value = linearModifier;
      ParameterizeComparisonFactorModifiers();

      qualityAnalyzer = new BestAverageWorstQualityAnalyzer();
      selectionPressureAnalyzer = new ValueAnalyzer();
      successfulOffspringAnalyzer = new SuccessfulOffspringAnalyzer();
      ParameterizeAnalyzers();
      UpdateAnalyzers();

      Initialize();
    }
Beispiel #19
0
    public TabuSearch()
      : base() {
      Parameters.Add(new ValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
      Parameters.Add(new ValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
      Parameters.Add(new ConstrainedValueParameter<IMoveGenerator>("MoveGenerator", "The operator used to generate moves to the neighborhood of the current solution."));
      Parameters.Add(new ConstrainedValueParameter<IMoveMaker>("MoveMaker", "The operator used to perform a move."));
      Parameters.Add(new ConstrainedValueParameter<ISingleObjectiveMoveEvaluator>("MoveEvaluator", "The operator used to evaluate a move."));
      Parameters.Add(new ConstrainedValueParameter<ITabuChecker>("TabuChecker", "The operator to check whether a move is tabu or not."));
      Parameters.Add(new ConstrainedValueParameter<ITabuMaker>("TabuMaker", "The operator used to insert attributes of a move into the tabu list."));
      Parameters.Add(new ValueParameter<IntValue>("TabuTenure", "The length of the tabu list.", new IntValue(10)));
      Parameters.Add(new ValueParameter<IntValue>("MaximumIterations", "The maximum number of generations which should be processed.", new IntValue(1000)));
      Parameters.Add(new ValueParameter<IntValue>("SampleSize", "The neighborhood size for stochastic sampling move generators", new IntValue(100)));
      Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze the solution.", new MultiAnalyzer()));

      RandomCreator randomCreator = new RandomCreator();
      SolutionsCreator solutionsCreator = new SolutionsCreator();
      VariableCreator variableCreator = new VariableCreator();
      ResultsCollector resultsCollector = new ResultsCollector();
      TabuSearchMainLoop mainLoop = new TabuSearchMainLoop();
      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.NumberOfSolutions = new IntValue(1);
      solutionsCreator.Successor = variableCreator;

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

      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Moves", null, "EvaluatedMoves"));
      resultsCollector.ResultsParameter.ActualName = "Results";
      resultsCollector.Successor = mainLoop;

      mainLoop.MoveGeneratorParameter.ActualName = MoveGeneratorParameter.Name;
      mainLoop.MoveMakerParameter.ActualName = MoveMakerParameter.Name;
      mainLoop.MoveEvaluatorParameter.ActualName = MoveEvaluatorParameter.Name;
      mainLoop.TabuCheckerParameter.ActualName = TabuCheckerParameter.Name;
      mainLoop.TabuMakerParameter.ActualName = TabuMakerParameter.Name;
      mainLoop.MaximumIterationsParameter.ActualName = MaximumIterationsParameter.Name;
      mainLoop.RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
      mainLoop.ResultsParameter.ActualName = "Results";
      mainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name;
      mainLoop.EvaluatedMovesParameter.ActualName = "EvaluatedMoves";

      moveQualityAnalyzer = new BestAverageWorstQualityAnalyzer();
      tabuNeighborhoodAnalyzer = new TabuNeighborhoodAnalyzer();
      ParameterizeAnalyzers();
      UpdateAnalyzers();

      Initialize();
    }
 private SolutionsCreator(SolutionsCreator original, Cloner cloner) : base(original, cloner) { }