Free cookie consent management tool by TermsFeed Policy Generator

Changeset 17261


Ignore:
Timestamp:
09/17/19 16:49:35 (5 years ago)
Author:
mkommend
Message:

#2521: Refactored multi-obj test functions and CMA-ES.

Location:
branches/2521_ProblemRefactoring
Files:
4 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/MOCMAEvolutionStrategy.cs

    r17226 r17261  
    3333using HeuristicLab.Optimization;
    3434using HeuristicLab.Parameters;
    35 using HeuristicLab.Problems.TestFunctions.MultiObjective;
    3635using HeuristicLab.Random;
    3736
     
    327326      solutions = new Individual[PopulationSize];
    328327      for (var i = 0; i < PopulationSize; i++) {
    329         var x = new RealVector(Encoding.Length); // Uniform distibution in all dimensions assumed.
     328        var x = new RealVector(Encoding.Length); // Uniform distribution in all dimensions assumed.
    330329        var bounds = Encoding.Bounds;
    331330        for (var j = 0; j < Encoding.Length; j++) {
     
    350349    }
    351350    private void InitResults() {
    352       Results.Add(new Result(IterationsResultName, "The number of gererations evaluated", new IntValue(0)));
    353       Results.Add(new Result(EvaluationsResultName, "The number of function evaltions performed", new IntValue(0)));
    354       Results.Add(new Result(HypervolumeResultName, "The hypervolume of the current front considering the Referencepoint defined in the Problem", new DoubleValue(0.0)));
    355       Results.Add(new Result(BestHypervolumeResultName, "The best hypervolume of the current run considering the Referencepoint defined in the Problem", new DoubleValue(0.0)));
    356       Results.Add(new Result(BestKnownHypervolumeResultName, "The best knwon hypervolume considering the Referencepoint defined in the Problem", new DoubleValue(double.NaN)));
    357       Results.Add(new Result(DifferenceToBestKnownHypervolumeResultName, "The difference between the current and the best known hypervolume", new DoubleValue(double.NaN)));
    358       Results.Add(new Result(GenerationalDistanceResultName, "The generational distance to an optimal pareto front defined in the Problem", new DoubleValue(double.NaN)));
    359       Results.Add(new Result(InvertedGenerationalDistanceResultName, "The inverted generational distance to an optimal pareto front defined in the Problem", new DoubleValue(double.NaN)));
     351      Results.Add(new Result(IterationsResultName, "The number of generations evaluated", new IntValue(0)));
     352      Results.Add(new Result(EvaluationsResultName, "The number of function evaluations performed", new IntValue(0)));
     353      Results.Add(new Result(HypervolumeResultName, "The hyper volume of the current front considering the reference point defined in the Problem", new DoubleValue(0.0)));
     354      Results.Add(new Result(BestHypervolumeResultName, "The best hyper volume of the current run considering the reference point defined in the Problem", new DoubleValue(0.0)));
     355      Results.Add(new Result(BestKnownHypervolumeResultName, "The best known hyper volume considering the reference point defined in the Problem", new DoubleValue(double.NaN)));
     356      Results.Add(new Result(DifferenceToBestKnownHypervolumeResultName, "The difference between the current and the best known hyper volume", new DoubleValue(double.NaN)));
     357      Results.Add(new Result(GenerationalDistanceResultName, "The generational distance to an optimal Pareto front defined in the Problem", new DoubleValue(double.NaN)));
     358      Results.Add(new Result(InvertedGenerationalDistanceResultName, "The inverted generational distance to an optimal Pareto front defined in the Problem", new DoubleValue(double.NaN)));
    360359      Results.Add(new Result(CrowdingResultName, "The average crowding value for the current front (excluding infinities)", new DoubleValue(0.0)));
    361360      Results.Add(new Result(SpacingResultName, "The spacing for the current front (excluding infinities)", new DoubleValue(0.0)));
     
    369368      table.Rows.Add(new DataRow(DifferenceToBestKnownHypervolumeResultName));
    370369      table.Rows.Add(new DataRow(SpacingResultName));
    371       Results.Add(new Result(TimetableResultName, "Different quality meassures in a timeseries", table));
     370      Results.Add(new Result(TimetableResultName, "Different quality measures in a time series", table));
    372371      Results.Add(new Result(CurrentFrontResultName, "The current front", new DoubleMatrix()));
    373       Results.Add(new Result(ScatterPlotResultName, "A scatterplot displaying the evaluated solutions and (if available) the analytically optimal front", new ParetoFrontScatterPlot()));
     372      Results.Add(new Result(ScatterPlotResultName, "A scatter plot displaying the evaluated solutions and (if available) the analytically optimal front", new ParetoFrontScatterPlot()));
    374373
    375374      var problem = Problem;
     
    455454
    456455    private void SelectParents(IReadOnlyList<Individual> parents, int length) {
    457       //perform a nondominated sort to assign the rank to every element
     456      //perform a non-dominated sort to assign the rank to every element
    458457      int[] ranks;
    459458      var fronts = DominationCalculator.CalculateAllParetoFronts(parents.ToArray(), parents.Select(i => i.PenalizedFitness).ToArray(), Problem.Maximization, out ranks);
     
    469468      }
    470469
    471       //now use the indicator to deselect the approximatingly worst elements of the last selected front
     470      //now use the indicator to deselect the approximately worst elements of the last selected front
    472471      var front1 = fronts[rank].OrderBy(x => x.Item1.PenalizedFitness[0]).ToList();
    473472      for (; popSize > length; popSize--) {
     
    501500      if (qualities.Length == 0) return;
    502501      ResultsCrowding = CrowdingCalculator.CalculateCrowding(qualities);
    503       ResultsSpacing = Spacing.Calculate(qualities);
    504 
    505 
    506       ResultsGenerationalDistance = problem.BestKnownFront != null ? GenerationalDistance.Calculate(qualities, problem.BestKnownFront, 1) : double.NaN;
    507       ResultsInvertedGenerationalDistance = problem.BestKnownFront != null ? InvertedGenerationalDistance.Calculate(qualities, problem.BestKnownFront, 1) : double.NaN;
     502      ResultsSpacing = SpacingAnalyzer.CalculateSpacing(qualities);
     503
     504
     505      ResultsGenerationalDistance = problem.BestKnownFront != null ? GenerationalDistanceAnalyzer.CalculateGenerationalDistance(qualities, problem.BestKnownFront, 1) : double.NaN;
     506      ResultsInvertedGenerationalDistance = problem.BestKnownFront != null ? GenerationalDistanceAnalyzer.CalculateInverseGenerationalDistance(qualities, problem.BestKnownFront, 1) : double.NaN;
    508507      ResultsHypervolume = problem.ReferencePoint != null ? HypervolumeCalculator.CalculateHypervolume(qualities, problem.ReferencePoint, Problem.Maximization) : double.NaN;
    509508      ResultsBestHypervolume = Math.Max(ResultsHypervolume, ResultsBestHypervolume);
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/HeuristicLab.Problems.TestFunctions.MultiObjective-3.3.csproj

    r17229 r17261  
    9696  </ItemGroup>
    9797  <ItemGroup>
    98     <Compile Include="Analyzers\ScatterPlotAnalyzer.cs" />
    99     <Compile Include="Analyzers\CrowdingAnalyzer.cs" />
    100     <Compile Include="Analyzers\InvertedGenerationalDistanceAnalyzer.cs" />
    101     <Compile Include="Analyzers\HypervolumeAnalyzer.cs" />
    102     <Compile Include="Analyzers\MOTFAnalyzer.cs" />
    103     <Compile Include="Analyzers\GenerationalDistanceAnalyzer.cs" />
    104     <Compile Include="Analyzers\SpacingAnalyzer.cs" />
    10598    <Compile Include="Instances\IHRInstanceProvider.cs" />
    10699    <Compile Include="Interfaces\IConstrainedTestFunction.cs" />
    107     <Compile Include="Interfaces\IMultiObjectiveTestFunctionAnalyzer.cs" />
    108     <Compile Include="Calculators\Crowding.cs" />
    109     <Compile Include="Calculators\Spacing.cs" />
    110     <Compile Include="Calculators\HyperVolume.cs" />
    111     <Compile Include="Calculators\InvertedGenerationalDistance.cs" />
    112     <Compile Include="Calculators\GenerationalDistance.cs" />
    113100    <Compile Include="Utilities.cs" />
    114101    <Compile Include="Instances\MISCInstanceProvider.cs" />
     
    125112    <Compile Include="TestFunctions\IHR\IHR2.cs" />
    126113    <Compile Include="TestFunctions\Misc\ELLI1.cs" />
    127     <Compile Include="NonDominatedSelect.cs" />
    128114    <Compile Include="Interfaces\IMultiObjectiveTestFunction.cs" />
    129115    <Compile Include="MultiObjectiveTestFunctionProblem.cs" />
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/MultiObjectiveTestFunctionProblem.cs

    r17226 r17261  
    2020#endregion
    2121using System;
    22 using System.Collections.Generic;
    2322using System.Linq;
    2423using HEAL.Attic;
     
    148147      var front = TestFunction.OptimalParetoFront(Objectives);
    149148      var bkf = front != null ? (DoubleMatrix)Utilities.ToMatrix(front).AsReadOnly() : null;
    150       Parameters.Add(new FixedValueParameter<DoubleMatrix>(BestKnownFrontParameterName, "A double matrix representing the best known qualites for this problem (aka points on the Pareto front). Points are to be given in a row-wise fashion.", bkf));
     149      Parameters.Add(new FixedValueParameter<DoubleMatrix>(BestKnownFrontParameterName, "A double matrix representing the best known qualities for this problem (aka points on the Pareto front). Points are to be given in a row-wise fashion.", bkf));
    151150
    152151      Parameters.Remove(ReferencePointParameterName);
    153       Parameters.Add(new FixedValueParameter<DoubleArray>(ReferencePointParameterName, "The refrence point for hypervolume calculations on this problem", new DoubleArray(TestFunction.ReferencePoint(Objectives))));
     152      Parameters.Add(new FixedValueParameter<DoubleArray>(ReferencePointParameterName, "The reference point for hypervolume calculations on this problem", new DoubleArray(TestFunction.ReferencePoint(Objectives))));
    154153
    155154      BoundsParameter.Value = new DoubleMatrix(TestFunction.Bounds(Objectives));
     
    159158      base.OnEncodingChanged();
    160159      UpdateParameterValues();
    161       ParameterizeAnalyzers();
    162160    }
    163161
     
    165163      base.OnEvaluatorChanged();
    166164      UpdateParameterValues();
    167       ParameterizeAnalyzers();
    168165    }
    169166
     
    172169      Objectives = Math.Max(TestFunction.MinimumObjectives, Math.Min(Objectives, TestFunction.MaximumObjectives));
    173170      Parameters.Remove(ReferencePointParameterName);
    174       Parameters.Add(new FixedValueParameter<DoubleArray>(ReferencePointParameterName, "The refrence point for hypervolume calculations on this problem", new DoubleArray(TestFunction.ReferencePoint(Objectives))));
    175       ParameterizeAnalyzers();
     171      Parameters.Add(new FixedValueParameter<DoubleArray>(ReferencePointParameterName, "The reference point for hypervolume calculations on this problem", new DoubleArray(TestFunction.ReferencePoint(Objectives))));
    176172      UpdateParameterValues();
    177173      OnReset();
     
    197193      Operators.Add(new SpacingAnalyzer());
    198194      Operators.Add(new TimelineAnalyzer());
    199       Operators.Add(new ScatterPlotAnalyzer());
    200       ParameterizeAnalyzers();
    201     }
    202 
    203     private IEnumerable<IMultiObjectiveTestFunctionAnalyzer> Analyzers {
    204       get { return Operators.OfType<IMultiObjectiveTestFunctionAnalyzer>(); }
    205     }
    206 
    207     private void ParameterizeAnalyzers() {
    208       foreach (var analyzer in Analyzers) {
    209         analyzer.ResultsParameter.ActualName = "Results";
    210         analyzer.QualitiesParameter.ActualName = Evaluator.QualitiesParameter.ActualName;
    211         analyzer.TestFunctionParameter.ActualName = TestFunctionParameter.Name;
    212         analyzer.BestKnownFrontParameter.ActualName = BestKnownFrontParameter.Name;
    213         var scatterPlotAnalyzer = analyzer as ScatterPlotAnalyzer;
    214         if (scatterPlotAnalyzer != null)
    215           scatterPlotAnalyzer.IndividualsParameter.ActualName = Encoding.Name;
    216       }
    217195    }
    218196    #endregion
Note: See TracChangeset for help on using the changeset viewer.