Exemplo n.º 1
0
 private SimulatedAnnealing(SimulatedAnnealing original, Cloner cloner)
     : base(original, cloner)
 {
     qualityAnalyzer     = cloner.Clone(original.qualityAnalyzer);
     temperatureAnalyzer = cloner.Clone(original.temperatureAnalyzer);
     Initialize();
 }
Exemplo n.º 2
0
 private void AfterDeserialization()
 {
     if (temperatureAnalyzer == null)
     {
         temperatureAnalyzer      = new SingleValueAnalyzer();
         temperatureAnalyzer.Name = "TemperatureAnalyzer";
         temperatureAnalyzer.ResultsParameter.ActualName = "Results";
         temperatureAnalyzer.ValueParameter.ActualName   = "Temperature";
         temperatureAnalyzer.ValuesParameter.ActualName  = "Temperature Chart";
         Analyzer.Operators.Add(temperatureAnalyzer);
     }
     Initialize();
 }
Exemplo n.º 3
0
        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();
        }