Ejemplo n.º 1
0
        public ScatterSearch()
            : base()
        {
            #region Create parameters
            Parameters.Add(new ValueParameter <MultiAnalyzer>("Analyzer", "The analyzer used to analyze each iteration.", new MultiAnalyzer()));
            Parameters.Add(new ConstrainedValueParameter <ICrossover>("Crossover", "The operator used to cross solutions."));
            Parameters.Add(new ValueParameter <BoolValue>("ExecutePathRelinking", "True if path relinking should be executed instead of crossover, otherwise false.", new BoolValue(false)));
            Parameters.Add(new ConstrainedValueParameter <IImprovementOperator>("Improver", "The operator used to improve solutions."));
            Parameters.Add(new ValueParameter <IntValue>("MaximumIterations", "The maximum number of iterations which should be processed.", new IntValue(100)));
            Parameters.Add(new ValueParameter <IntValue>("NumberOfHighQualitySolutions", "The number of high quality solutions in the reference set.", new IntValue(5)));
            Parameters.Add(new ConstrainedValueParameter <IPathRelinker>("PathRelinker", "The operator used to execute path relinking."));
            Parameters.Add(new ValueParameter <IntValue>("PopulationSize", "The size of the population of solutions.", new IntValue(50)));
            Parameters.Add(new ValueParameter <IntValue>("ReferenceSetSize", "The size of the reference set.", new IntValue(20)));
            Parameters.Add(new ValueParameter <IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
            Parameters.Add(new ValueParameter <BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
            Parameters.Add(new ConstrainedValueParameter <ISolutionSimilarityCalculator>("SimilarityCalculator", "The operator used to calculate the similarity between two solutions."));
            #endregion

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

            #region Create operator graph
            OperatorGraph.InitialOperator                     = randomCreator;
            randomCreator.RandomParameter.ActualName          = "Random";
            randomCreator.SeedParameter.ActualName            = SeedParameter.Name;
            randomCreator.SeedParameter.Value                 = null;
            randomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameter.Name;
            randomCreator.SetSeedRandomlyParameter.Value      = null;
            randomCreator.Successor = solutionsCreator;

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

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

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

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

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

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

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

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

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

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

            Initialize();
        }
Ejemplo n.º 2
0
    public ScatterSearch()
      : base() {
      #region Create parameters
      Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The analyzer used to analyze each iteration.", new MultiAnalyzer()));
      Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions."));
      Parameters.Add(new ValueParameter<BoolValue>("ExecutePathRelinking", "True if path relinking should be executed instead of crossover, otherwise false.", new BoolValue(false)));
      Parameters.Add(new ConstrainedValueParameter<IImprovementOperator>("Improver", "The operator used to improve solutions."));
      Parameters.Add(new ValueParameter<IntValue>("MaximumIterations", "The maximum number of iterations which should be processed.", new IntValue(100)));
      Parameters.Add(new ValueParameter<IntValue>("NumberOfHighQualitySolutions", "The number of high quality solutions in the reference set.", new IntValue(5)));
      Parameters.Add(new ConstrainedValueParameter<IPathRelinker>("PathRelinker", "The operator used to execute path relinking."));
      Parameters.Add(new ValueParameter<IntValue>("PopulationSize", "The size of the population of solutions.", new IntValue(50)));
      Parameters.Add(new ValueParameter<IntValue>("ReferenceSetSize", "The size of the reference set.", new IntValue(20)));
      Parameters.Add(new ValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
      Parameters.Add(new ValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
      Parameters.Add(new ConstrainedValueParameter<ISolutionSimilarityCalculator>("SimilarityCalculator", "The operator used to calculate the similarity between two solutions."));
      #endregion

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

      #region Create operator graph
      OperatorGraph.InitialOperator = randomCreator;
      randomCreator.RandomParameter.ActualName = "Random";
      randomCreator.SeedParameter.ActualName = SeedParameter.Name;
      randomCreator.SeedParameter.Value = null;
      randomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameter.Name;
      randomCreator.SetSeedRandomlyParameter.Value = null;
      randomCreator.Successor = solutionsCreator;

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

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

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

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

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

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

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

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

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

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

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