private RightSelector(RightSelector original, Cloner cloner) : base(original, cloner) { }
Exemple #2
0
 private RightSelector(RightSelector original, Cloner cloner) : base(original, cloner)
 {
 }
    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
    }