protected ProbabilisticQualityComparator(ProbabilisticQualityComparator original, Cloner cloner) : base(original, cloner) { }
Ejemplo n.º 2
0
 protected ProbabilisticQualityComparator(ProbabilisticQualityComparator original, Cloner cloner) : base(original, cloner)
 {
 }
    private void Initialize() {
      #region Create parameters
      Parameters.Add(new ValueLookupParameter<IRandom>("Random", "A pseudo random number generator."));
      Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem, otherwise false."));
      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The value which represents the quality of a solution."));
      Parameters.Add(new ValueLookupParameter<DoubleValue>("BestKnownQuality", "The best known quality value found so far."));
      Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The value which represents the quality of a move."));
      Parameters.Add(new LookupParameter<DoubleValue>("Temperature", "The current temperature."));
      Parameters.Add(new ValueLookupParameter<DoubleValue>("StartTemperature", "The initial temperature."));
      Parameters.Add(new ValueLookupParameter<DoubleValue>("EndTemperature", "The end temperature."));
      Parameters.Add(new ValueLookupParameter<IntValue>("InnerIterations", "The amount of inner iterations (number of moves before temperature is adjusted again)."));
      Parameters.Add(new LookupParameter<IntValue>("Iterations", "The number of iterations."));
      Parameters.Add(new ValueLookupParameter<IntValue>("MaximumIterations", "The maximum number of iterations which should be processed."));

      Parameters.Add(new ValueLookupParameter<IOperator>("MoveGenerator", "The operator that generates the moves."));
      Parameters.Add(new ValueLookupParameter<IOperator>("MoveEvaluator", "The operator that evaluates a move."));
      Parameters.Add(new ValueLookupParameter<IOperator>("MoveMaker", "The operator that performs a move and updates the quality."));
      Parameters.Add(new ValueLookupParameter<IOperator>("AnnealingOperator", "The operator that modifies the temperature."));

      Parameters.Add(new ValueLookupParameter<IOperator>("Analyzer", "The operator used to analyze each generation."));
      Parameters.Add(new ValueLookupParameter<VariableCollection>("Results", "The variable collection where results should be stored."));
      Parameters.Add(new LookupParameter<IntValue>("EvaluatedMoves", "The number of evaluated moves."));
      #endregion

      #region Create operators
      Assigner temperatureInitializer = new Assigner();
      ResultsCollector resultsCollector1 = new ResultsCollector();
      SubScopesProcessor subScopesProcessor0 = new SubScopesProcessor();
      Placeholder analyzer1 = new Placeholder();
      SubScopesProcessor sssp = new SubScopesProcessor();
      ResultsCollector resultsCollector = new ResultsCollector();
      Placeholder annealingOperator = new Placeholder();
      UniformSubScopesProcessor mainProcessor = new UniformSubScopesProcessor();
      Placeholder moveGenerator = new Placeholder();
      UniformSubScopesProcessor moveEvaluationProcessor = new UniformSubScopesProcessor();
      Placeholder moveEvaluator = new Placeholder();
      SubScopesCounter subScopesCounter = new SubScopesCounter();
      ProbabilisticQualityComparator qualityComparator = new ProbabilisticQualityComparator();
      ConditionalBranch improvesQualityBranch = new ConditionalBranch();
      Placeholder moveMaker = new Placeholder();
      SubScopesRemover subScopesRemover = new SubScopesRemover();
      IntCounter iterationsCounter = new IntCounter();
      Comparator iterationsComparator = new Comparator();
      SubScopesProcessor subScopesProcessor1 = new SubScopesProcessor();
      Placeholder analyzer2 = new Placeholder();
      ConditionalBranch iterationsTermination = new ConditionalBranch();

      temperatureInitializer.LeftSideParameter.ActualName = TemperatureParameter.ActualName;
      temperatureInitializer.RightSideParameter.ActualName = StartTemperatureParameter.Name;

      resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>(IterationsParameter.Name));
      resultsCollector1.ResultsParameter.ActualName = ResultsParameter.Name;

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

      annealingOperator.Name = "Annealing operator (placeholder)";
      annealingOperator.OperatorParameter.ActualName = AnnealingOperatorParameter.Name;

      moveGenerator.Name = "Move generator (placeholder)";
      moveGenerator.OperatorParameter.ActualName = MoveGeneratorParameter.Name;

      moveEvaluator.Name = "Move evaluator (placeholder)";
      moveEvaluator.OperatorParameter.ActualName = MoveEvaluatorParameter.Name;

      subScopesCounter.Name = "Increment EvaluatedMoves";
      subScopesCounter.ValueParameter.ActualName = EvaluatedMovesParameter.Name;

      qualityComparator.LeftSideParameter.ActualName = MoveQualityParameter.Name;
      qualityComparator.RightSideParameter.ActualName = QualityParameter.Name;
      qualityComparator.ResultParameter.ActualName = "IsBetter";
      qualityComparator.DampeningParameter.ActualName = "Temperature";

      improvesQualityBranch.ConditionParameter.ActualName = "IsBetter";

      moveMaker.Name = "Move maker (placeholder)";
      moveMaker.OperatorParameter.ActualName = MoveMakerParameter.Name;

      subScopesRemover.RemoveAllSubScopes = true;

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

      iterationsComparator.Name = "Iterations >= MaximumIterations";
      iterationsComparator.LeftSideParameter.ActualName = IterationsParameter.Name;
      iterationsComparator.RightSideParameter.ActualName = MaximumIterationsParameter.Name;
      iterationsComparator.ResultParameter.ActualName = "Terminate";
      iterationsComparator.Comparison.Value = ComparisonType.GreaterOrEqual;

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

      iterationsTermination.Name = "Iterations termination condition";
      iterationsTermination.ConditionParameter.ActualName = "Terminate";
      #endregion

      #region Create operator graph
      OperatorGraph.InitialOperator = temperatureInitializer;
      temperatureInitializer.Successor = resultsCollector1;
      resultsCollector1.Successor = subScopesProcessor0;
      subScopesProcessor0.Operators.Add(analyzer1);
      subScopesProcessor0.Successor = sssp;
      analyzer1.Successor = null;
      sssp.Operators.Add(resultsCollector);
      sssp.Successor = annealingOperator;
      resultsCollector.Successor = null;
      annealingOperator.Successor = mainProcessor;
      mainProcessor.Operator = moveGenerator;
      mainProcessor.Successor = iterationsCounter;
      moveGenerator.Successor = moveEvaluationProcessor;
      moveEvaluationProcessor.Operator = moveEvaluator;
      moveEvaluationProcessor.Successor = subScopesCounter;
      moveEvaluator.Successor = qualityComparator;
      qualityComparator.Successor = improvesQualityBranch;
      improvesQualityBranch.TrueBranch = moveMaker;
      improvesQualityBranch.FalseBranch = null;
      improvesQualityBranch.Successor = null;
      moveMaker.Successor = null;
      subScopesCounter.Successor = subScopesRemover;
      subScopesRemover.Successor = null;
      iterationsCounter.Successor = iterationsComparator;
      iterationsComparator.Successor = subScopesProcessor1;
      subScopesProcessor1.Operators.Add(analyzer2);
      subScopesProcessor1.Successor = iterationsTermination;
      iterationsTermination.TrueBranch = null;
      iterationsTermination.FalseBranch = annealingOperator;
      #endregion
    }