private ResultsHistoryWiper(ResultsHistoryWiper original, Cloner cloner)
     : base(original, cloner)
 {
 }
        private CombinedOperator CreateLayerOpener()
        {
            var layerOpener = new CombinedOperator()
            {
                Name = "Open new Layer if needed"
            };
            var maxLayerReached = new Comparator()
            {
                Name = "MaxLayersReached = OpenLayers >= NumberOfLayers"
            };
            var maxLayerReachedBranch = new ConditionalBranch()
            {
                Name = "MaxLayersReached?"
            };
            var openNewLayerCalculator = new ExpressionCalculator()
            {
                Name = "OpenNewLayer = Generations >= AgeLimits[OpenLayers - 1]"
            };
            var openNewLayerBranch = new ConditionalBranch()
            {
                Name = "OpenNewLayer?"
            };
            var layerCreator = new LastLayerCloner()
            {
                Name = "Create Layer"
            };
            var updateLayerNumber = new Assigner()
            {
                Name = "Layer = OpenLayers"
            };
            var historyWiper = new ResultsHistoryWiper()
            {
                Name = "Clear History in Results"
            };
            var createChildrenViaCrossover        = new AlpsGeneticAlgorithmMainOperator();
            var incrEvaluatedSolutionsForNewLayer = new SubScopesCounter()
            {
                Name = "Update EvaluatedSolutions"
            };
            var incrOpenLayers = new IntCounter()
            {
                Name = "Incr. OpenLayers"
            };
            var newLayerResultsCollector = new ResultsCollector()
            {
                Name = "Collect new Layer Results"
            };

            layerOpener.OperatorGraph.InitialOperator = maxLayerReached;

            maxLayerReached.LeftSideParameter.ActualName  = "OpenLayers";
            maxLayerReached.RightSideParameter.ActualName = NumberOfLayersParameter.Name;
            maxLayerReached.ResultParameter.ActualName    = "MaxLayerReached";
            maxLayerReached.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
            maxLayerReached.Successor  = maxLayerReachedBranch;

            maxLayerReachedBranch.ConditionParameter.ActualName = "MaxLayerReached";
            maxLayerReachedBranch.FalseBranch = openNewLayerCalculator;

            openNewLayerCalculator.CollectedValues.Add(new LookupParameter <IntArray>(AgeLimitsParameter.Name));
            openNewLayerCalculator.CollectedValues.Add(new LookupParameter <IntValue>("Generations"));
            openNewLayerCalculator.CollectedValues.Add(new LookupParameter <IntValue>(NumberOfLayersParameter.Name));
            openNewLayerCalculator.CollectedValues.Add(new LookupParameter <IntValue>("OpenLayers"));
            openNewLayerCalculator.ExpressionResultParameter.ActualName = "OpenNewLayer";
            openNewLayerCalculator.ExpressionParameter.Value            = new StringValue("Generations 1 + AgeLimits OpenLayers 1 - [] >");
            openNewLayerCalculator.Successor = openNewLayerBranch;

            openNewLayerBranch.ConditionParameter.ActualName = "OpenNewLayer";
            openNewLayerBranch.TrueBranch = layerCreator;

            layerCreator.NewLayerOperator = updateLayerNumber;
            layerCreator.Successor        = incrOpenLayers;

            updateLayerNumber.LeftSideParameter.ActualName  = "Layer";
            updateLayerNumber.RightSideParameter.ActualName = "OpenLayers";
            updateLayerNumber.Successor = historyWiper;

            historyWiper.ResultsParameter.ActualName = "LayerResults";
            historyWiper.Successor = createChildrenViaCrossover;

            // Maybe use only crossover and no elitism instead of "default operator"
            createChildrenViaCrossover.RandomParameter.ActualName              = LocalRandomParameter.Name;
            createChildrenViaCrossover.EvaluatorParameter.ActualName           = EvaluatorParameter.Name;
            createChildrenViaCrossover.EvaluatedSolutionsParameter.ActualName  = "LayerEvaluatedSolutions";
            createChildrenViaCrossover.QualityParameter.ActualName             = QualityParameter.Name;
            createChildrenViaCrossover.MaximizationParameter.ActualName        = MaximizationParameter.Name;
            createChildrenViaCrossover.PopulationSizeParameter.ActualName      = PopulationSizeParameter.Name;
            createChildrenViaCrossover.SelectorParameter.ActualName            = SelectorParameter.Name;
            createChildrenViaCrossover.CrossoverParameter.ActualName           = CrossoverParameter.Name;
            createChildrenViaCrossover.MutatorParameter.ActualName             = MutatorParameter.Name;
            createChildrenViaCrossover.MutationProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
            createChildrenViaCrossover.ElitesParameter.ActualName              = ElitesParameter.Name;
            createChildrenViaCrossover.ReevaluateElitesParameter.ActualName    = ReevaluateElitesParameter.Name;
            createChildrenViaCrossover.PlusSelectionParameter.ActualName       = PlusSelectionParameter.Name;
            createChildrenViaCrossover.AgeParameter.ActualName            = AgeParameter.Name;
            createChildrenViaCrossover.AgeInheritanceParameter.ActualName = AgeInheritanceParameter.Name;
            createChildrenViaCrossover.AgeIncrementParameter.Value        = new DoubleValue(0.0);
            createChildrenViaCrossover.Successor = incrEvaluatedSolutionsForNewLayer;

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

            incrOpenLayers.ValueParameter.ActualName = "OpenLayers";
            incrOpenLayers.Increment = new IntValue(1);
            incrOpenLayers.Successor = newLayerResultsCollector;

            newLayerResultsCollector.CollectedValues.Add(new ScopeTreeLookupParameter <ResultCollection>("LayerResults", "Result set for each layer", "LayerResults"));
            newLayerResultsCollector.CopyValue = new BoolValue(false);
            newLayerResultsCollector.Successor = null;

            return(layerOpener);
        }
    private CombinedOperator CreateLayerOpener() {
      var layerOpener = new CombinedOperator() { Name = "Open new Layer if needed" };
      var maxLayerReached = new Comparator() { Name = "MaxLayersReached = OpenLayers >= NumberOfLayers" };
      var maxLayerReachedBranch = new ConditionalBranch() { Name = "MaxLayersReached?" };
      var openNewLayerCalculator = new ExpressionCalculator() { Name = "OpenNewLayer = Generations >= AgeLimits[OpenLayers - 1]" };
      var openNewLayerBranch = new ConditionalBranch() { Name = "OpenNewLayer?" };
      var layerCreator = new LastLayerCloner() { Name = "Create Layer" };
      var updateLayerNumber = new Assigner() { Name = "Layer = OpenLayers" };
      var historyWiper = new ResultsHistoryWiper() { Name = "Clear History in Results" };
      var createChildrenViaCrossover = new AlpsOffspringSelectionGeneticAlgorithmMainOperator();
      var incrEvaluatedSolutionsForNewLayer = new SubScopesCounter() { Name = "Update EvaluatedSolutions" };
      var incrOpenLayers = new IntCounter() { Name = "Incr. OpenLayers" };
      var newLayerResultsCollector = new ResultsCollector() { Name = "Collect new Layer Results" };

      layerOpener.OperatorGraph.InitialOperator = maxLayerReached;

      maxLayerReached.LeftSideParameter.ActualName = "OpenLayers";
      maxLayerReached.RightSideParameter.ActualName = NumberOfLayersParameter.Name;
      maxLayerReached.ResultParameter.ActualName = "MaxLayerReached";
      maxLayerReached.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
      maxLayerReached.Successor = maxLayerReachedBranch;

      maxLayerReachedBranch.ConditionParameter.ActualName = "MaxLayerReached";
      maxLayerReachedBranch.FalseBranch = openNewLayerCalculator;

      openNewLayerCalculator.CollectedValues.Add(new LookupParameter<IntArray>(AgeLimitsParameter.Name));
      openNewLayerCalculator.CollectedValues.Add(new LookupParameter<IntValue>("Generations"));
      openNewLayerCalculator.CollectedValues.Add(new LookupParameter<IntValue>(NumberOfLayersParameter.Name));
      openNewLayerCalculator.CollectedValues.Add(new LookupParameter<IntValue>("OpenLayers"));
      openNewLayerCalculator.ExpressionResultParameter.ActualName = "OpenNewLayer";
      openNewLayerCalculator.ExpressionParameter.Value = new StringValue("Generations 1 + AgeLimits OpenLayers 1 - [] >");
      openNewLayerCalculator.Successor = openNewLayerBranch;

      openNewLayerBranch.ConditionParameter.ActualName = "OpenNewLayer";
      openNewLayerBranch.TrueBranch = layerCreator;

      layerCreator.NewLayerOperator = updateLayerNumber;
      layerCreator.Successor = incrOpenLayers;

      updateLayerNumber.LeftSideParameter.ActualName = "Layer";
      updateLayerNumber.RightSideParameter.ActualName = "OpenLayers";
      updateLayerNumber.Successor = historyWiper;

      historyWiper.ResultsParameter.ActualName = "LayerResults";
      historyWiper.Successor = createChildrenViaCrossover;

      // Maybe use only crossover and no elitism instead of "default operator"
      createChildrenViaCrossover.RandomParameter.ActualName = LocalRandomParameter.Name;
      createChildrenViaCrossover.EvaluatorParameter.ActualName = EvaluatorParameter.Name;
      createChildrenViaCrossover.EvaluatedSolutionsParameter.ActualName = "LayerEvaluatedSolutions";
      createChildrenViaCrossover.QualityParameter.ActualName = QualityParameter.Name;
      createChildrenViaCrossover.MaximizationParameter.ActualName = MaximizationParameter.Name;
      createChildrenViaCrossover.PopulationSizeParameter.ActualName = PopulationSizeParameter.Name;
      createChildrenViaCrossover.SelectorParameter.ActualName = SelectorParameter.Name;
      createChildrenViaCrossover.CrossoverParameter.ActualName = CrossoverParameter.Name;
      createChildrenViaCrossover.MutatorParameter.ActualName = MutatorParameter.ActualName;
      createChildrenViaCrossover.MutationProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
      createChildrenViaCrossover.ElitesParameter.ActualName = ElitesParameter.Name;
      createChildrenViaCrossover.ReevaluateElitesParameter.ActualName = ReevaluateElitesParameter.Name;
      createChildrenViaCrossover.ComparisonFactorParameter.ActualName = ComparisonFactorParameter.Name;
      createChildrenViaCrossover.SuccessRatioParameter.ActualName = SuccessRatioParameter.Name;
      createChildrenViaCrossover.CurrentSuccessRatioParameter.ActualName = "CurrentSuccessRatio";
      createChildrenViaCrossover.SelectionPressureParameter.ActualName = "SelectionPressure";
      createChildrenViaCrossover.MaximumSelectionPressureParameter.ActualName = MaximumSelectionPressureParameter.Name;
      createChildrenViaCrossover.OffspringSelectionBeforeMutationParameter.ActualName = OffspringSelectionBeforeMutationParameter.Name;
      createChildrenViaCrossover.FillPopulationWithParentsParameter.ActualName = FillPopulationWithParentsParameter.Name;
      createChildrenViaCrossover.AgeParameter.ActualName = AgeParameter.Name;
      createChildrenViaCrossover.AgeInheritanceParameter.ActualName = AgeInheritanceParameter.Name;
      createChildrenViaCrossover.AgeIncrementParameter.Value = new DoubleValue(0.0);
      createChildrenViaCrossover.Successor = incrEvaluatedSolutionsForNewLayer;

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

      incrOpenLayers.ValueParameter.ActualName = "OpenLayers";
      incrOpenLayers.Increment = new IntValue(1);
      incrOpenLayers.Successor = newLayerResultsCollector;

      newLayerResultsCollector.CollectedValues.Add(new ScopeTreeLookupParameter<ResultCollection>("LayerResults", "Result set for each layer", "LayerResults"));
      newLayerResultsCollector.CopyValue = new BoolValue(false);
      newLayerResultsCollector.Successor = null;

      return layerOpener;
    }
Пример #4
0
 private ResultsHistoryWiper(ResultsHistoryWiper original, Cloner cloner)
   : base(original, cloner) {
 }