Пример #1
0
 private SimulatedAnnealing(SimulatedAnnealing original, Cloner cloner)
     : base(original, cloner)
 {
     qualityAnalyzer     = cloner.Clone(original.qualityAnalyzer);
     temperatureAnalyzer = cloner.Clone(original.temperatureAnalyzer);
     Initialize();
 }
    private SimulatedAnnealing CreateSimulatedAnnealingRastriginSample() {
      SimulatedAnnealing sa = new SimulatedAnnealing();
      #region Problem Configuration
      var problem = new SingleObjectiveTestFunctionProblem();
      problem.BestKnownQuality.Value = 0.0;
      problem.BestKnownSolutionParameter.Value = new RealVector(new double[] { 0, 0 });
      problem.Bounds = new DoubleMatrix(new double[,] { { -5.12, 5.12 } });
      problem.EvaluatorParameter.Value = new RastriginEvaluator();
      problem.Maximization.Value = false;
      problem.ProblemSize.Value = 2;
      problem.SolutionCreatorParameter.Value = new UniformRandomRealVectorCreator();
      #endregion
      #region Algorithm Configuration
      sa.Name = "Simulated Annealing - Rastrigin";
      sa.Description = "A simulated annealing algorithm that solves the 2-dimensional Rastrigin test function";
      sa.Problem = problem;
      var annealingOperator = sa.AnnealingOperatorParameter.ValidValues
        .OfType<ExponentialDiscreteDoubleValueModifier>()
        .Single();
      annealingOperator.StartIndexParameter.Value = new IntValue(0);
      sa.AnnealingOperator = annealingOperator;

      sa.EndTemperature.Value = 1E-6;
      sa.InnerIterations.Value = 50;
      sa.MaximumIterations.Value = 100;
      var moveEvaluator = sa.MoveEvaluatorParameter.ValidValues
        .OfType<RastriginAdditiveMoveEvaluator>()
        .Single();
      moveEvaluator.A.Value = 10;
      sa.MoveEvaluator = moveEvaluator;

      var moveGenerator = sa.MoveGeneratorParameter.ValidValues
        .OfType<StochasticNormalMultiMoveGenerator>()
        .Single();
      moveGenerator.SigmaParameter.Value = new DoubleValue(1);
      sa.MoveGenerator = moveGenerator;

      sa.MoveMaker = sa.MoveMakerParameter.ValidValues
        .OfType<AdditiveMoveMaker>()
        .Single();

      sa.Seed.Value = 0;
      sa.SetSeedRandomly.Value = true;
      sa.StartTemperature.Value = 1;
      #endregion
      sa.Engine = new ParallelEngine.ParallelEngine();
      return sa;
    }
Пример #3
0
 private SimulatedAnnealing(SimulatedAnnealing original, Cloner cloner)
   : base(original, cloner) {
   qualityAnalyzer = cloner.Clone(original.qualityAnalyzer);
   temperatureAnalyzer = cloner.Clone(original.temperatureAnalyzer);
   Initialize();
 }