Changeset 14087


Ignore:
Timestamp:
07/15/16 14:25:02 (15 months ago)
Author:
ichiriac
Message:

Final revision of the code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ichiriac/HeuristicLab.Algorithms.GDE3/GDE3.cs

    r13852 r14087  
    55 * This file is part of HeuristicLab.
    66 *
     7 * Implementation based on the GDE3 implementation in jMetal Framework https://github.com/jMetal/jMetal
    78 *
    89 * HeuristicLab is free software: you can redistribute it and/or modify
     
    7172        #region ParameterNames
    7273        private const string MaximumGenerationsParameterName = "Maximum Generations";
     74        private const string MaximumEvaluationsParameterName = "Maximum Evaluations";
    7375        private const string CrossoverProbabilityParameterName = "CrossoverProbability";
    7476        private const string PopulationSizeParameterName = "PopulationSize";
     
    8284            get { return (IFixedValueParameter<IntValue>)Parameters[MaximumGenerationsParameterName]; }
    8385        }
     86        public IFixedValueParameter<IntValue> MaximumEvaluationsParameter
     87        {
     88            get { return (IFixedValueParameter<IntValue>)Parameters[MaximumEvaluationsParameterName]; }
     89        }
    8490        private ValueParameter<IntValue> PopulationSizeParameter
    8591        {
     
    97103
    98104        #region Properties
    99         public int MaximumEvaluations
     105        public int MaximumGenerations
    100106        {
    101107            get { return MaximumGenerationsParameter.Value.Value; }
     
    103109        }
    104110
     111        public int MaximumEvaluations
     112        {
     113            get { return MaximumEvaluationsParameter.Value.Value; }
     114            set { MaximumEvaluationsParameter.Value.Value = value; }
     115        }
     116
    105117        public Double CrossoverProbability
    106118        {
     
    209221        {
    210222            Parameters.Add(new FixedValueParameter<IntValue>(MaximumGenerationsParameterName, "", new IntValue(1000)));
     223            Parameters.Add(new FixedValueParameter<IntValue>(MaximumEvaluationsParameterName, "", new IntValue(Int32.MaxValue)));
    211224            Parameters.Add(new ValueParameter<IntValue>(PopulationSizeParameterName, "The size of the population of solutions.", new IntValue(100)));
    212225            Parameters.Add(new ValueParameter<DoubleValue>(CrossoverProbabilityParameterName, "The value for crossover rate", new DoubleValue(0.5)));
     
    261274            int generations = 1;
    262275
    263             while (ResultsGenerations < MaximumGenerationsParameter.Value.Value
     276            while (ResultsEvaluations < MaximumEvaluationsParameter.Value.Value
    264277               && !cancellationToken.IsCancellationRequested)
    265278            {
     
    353366            ResultsBestFront = new DoubleMatrix(MultiObjectiveTestFunctionProblem.To2D(qualitiesFinal));
    354367            ResultsCrowding = Crowding.Calculate(qualitiesFinal, Problem.TestFunction.Bounds(objectives));
    355             ResultsInvertedGenerationalDistance = InvertedGenerationalDistance.Calculate(en, optimalfront, 1);
     368            GenerationalDistanceCalculator distance = new GenerationalDistanceCalculator();
     369            ResultsInvertedGenerationalDistance = distance.CalculateGenerationalDistance(qualitiesFinal, opf, Problem.Objectives);
    356370            ResultsHypervolume = Hypervolume.Calculate(frontVectors, Problem.TestFunction.ReferencePoint(objectives), Problem.TestFunction.Maximization(objectives));
    357371            ResultsGenerationalDistance = GenerationalDistance.Calculate(qualitiesFinal, optimalfront, 1);
     
    397411        }
    398412
    399         protected SolutionSet createIndividual()
     413        private SolutionSet createIndividual()
    400414        {
    401415            var dim = Problem.ProblemSize;
     
    423437        }
    424438
    425         protected void initProgress()
     439        private void initProgress()
    426440        {
    427441            this.evals = PopulationSizeParameter.Value.Value;
    428442        }
    429443
    430         protected void updateProgres()
     444        private void updateProgres()
    431445        {
    432446            this.evals++;
    433447        }
    434448
    435         protected SolutionSet[] selection(List<SolutionSet> population, int i)
     449        private SolutionSet[] selection(List<SolutionSet> population, int i)
    436450        {
    437451            SolutionSet[] parents = new SolutionSet[3];
     
    458472        }
    459473
    460         protected SolutionSet reproduction(SolutionSet parent, SolutionSet[] parentsSolutions)
     474        private SolutionSet reproduction(SolutionSet parent, SolutionSet[] parentsSolutions)
    461475        {
    462476            var individual = createEmptyIndividual();
     
    516530        }
    517531
    518         public void crowdingDistanceAssignment(List<SolutionSet> rankingSubfront)
     532        private void crowdingDistanceAssignment(List<SolutionSet> rankingSubfront)
    519533        {
    520534            int size = rankingSubfront.Count;
Note: See TracChangeset for help on using the changeset viewer.