Changeset 16807


Ignore:
Timestamp:
04/17/19 23:07:03 (2 months ago)
Author:
mkommend
Message:

#2521: Adapted test functions to new architecture and partly MOCMAES.

Location:
branches/2521_ProblemRefactoring
Files:
9 edited

Legend:

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

    r16723 r16807  
    2020#endregion
    2121using System.Collections.Generic;
     22using HEAL.Attic;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Encodings.RealVectorEncoding;
    2425using HeuristicLab.Optimization;
    25 using HEAL.Attic;
    2626
    2727namespace HeuristicLab.Algorithms.MOCMAEvolutionStrategy {
     
    3636    /// <param name="problem">The problem on which the front is evaluated (!! The function itself will NOT be evluated only bounds referencePoints & other metadata will be used</param>
    3737    /// <returns>the index of the least contributing point according to any type of quality criteria</returns>
    38     int LeastContributer(IReadOnlyList<Individual> front, MultiObjectiveBasicProblem<RealVectorEncoding> problem);
     38    int LeastContributer(IReadOnlyList<Individual> front, MultiObjectiveProblem<RealVectorEncoding, RealVector> problem);
    3939  }
    4040}
  • branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/Indicators/CrowdingIndicator.cs

    r16723 r16807  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HEAL.Attic;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
    2728using HeuristicLab.Encodings.RealVectorEncoding;
    2829using HeuristicLab.Optimization;
    29 using HEAL.Attic;
    3030
    3131namespace HeuristicLab.Algorithms.MOCMAEvolutionStrategy {
     
    4141    #endregion
    4242
    43     public int LeastContributer(IReadOnlyList<Individual> front, MultiObjectiveBasicProblem<RealVectorEncoding> problem) {
     43    public int LeastContributer(IReadOnlyList<Individual> front, MultiObjectiveProblem<RealVectorEncoding, RealVector> problem) {
    4444      var bounds = problem.Encoding.Bounds;
    4545      var extracted = front.Select(x => x.PenalizedFitness).ToArray();
  • branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/Indicators/HypervolumeIndicator.cs

    r16723 r16807  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HEAL.Attic;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
    2728using HeuristicLab.Encodings.RealVectorEncoding;
    2829using HeuristicLab.Optimization;
    29 using HEAL.Attic;
    3030using HeuristicLab.Problems.TestFunctions.MultiObjective;
    3131namespace HeuristicLab.Algorithms.MOCMAEvolutionStrategy {
     
    4141    #endregion
    4242
    43     public int LeastContributer(IReadOnlyList<Individual> front, MultiObjectiveBasicProblem<RealVectorEncoding> problem) {
     43    public int LeastContributer(IReadOnlyList<Individual> front, MultiObjectiveProblem<RealVectorEncoding, RealVector> problem) {
    4444      var frontCopy = front.Select(x => x.PenalizedFitness).ToList();
    4545      if (frontCopy.Count <= 1) return 0;
     46      //TODO discuss with bwerth
    4647      var p = problem as MultiObjectiveTestFunctionProblem;
    4748      var refPoint = BuildReferencePoint(p != null ? frontCopy.Concat(new[] { p.ReferencePoint.CloneAsArray() }) : frontCopy, problem.Maximization);
  • branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/Indicators/MinimalDistanceIndicator.cs

    r16723 r16807  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HEAL.Attic;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
    2728using HeuristicLab.Encodings.RealVectorEncoding;
    2829using HeuristicLab.Optimization;
    29 using HEAL.Attic;
    3030
    3131namespace HeuristicLab.Algorithms.MOCMAEvolutionStrategy {
     
    4242    #endregion
    4343
    44     public int LeastContributer(IReadOnlyList<Individual> front, MultiObjectiveBasicProblem<RealVectorEncoding> problem) {
     44    public int LeastContributer(IReadOnlyList<Individual> front, MultiObjectiveProblem<RealVectorEncoding, RealVector> problem) {
    4545      var extracted = front.Select(x => x.PenalizedFitness).ToArray();
    4646      if (extracted.Length <= 2) return 0;
  • branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/Individual.cs

    r16723 r16807  
    2323using System;
    2424using System.Linq;
     25using HEAL.Attic;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Encodings.RealVectorEncoding;
    27 using HEAL.Attic;
    2828using HeuristicLab.Random;
    2929
  • branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/MOCMAEvolutionStrategy.cs

    r16723 r16807  
    2525using System.Linq;
    2626using System.Threading;
     27using HEAL.Attic;
    2728using HeuristicLab.Analysis;
    2829using HeuristicLab.Common;
     
    3233using HeuristicLab.Optimization;
    3334using HeuristicLab.Parameters;
    34 using HEAL.Attic;
    3535using HeuristicLab.Problems.TestFunctions.MultiObjective;
    3636using HeuristicLab.Random;
     
    4242  public class MOCMAEvolutionStrategy : BasicAlgorithm {
    4343    public override Type ProblemType {
    44       get { return typeof(MultiObjectiveBasicProblem<RealVectorEncoding>); }
    45     }
    46     public new MultiObjectiveBasicProblem<RealVectorEncoding> Problem {
    47       get { return (MultiObjectiveBasicProblem<RealVectorEncoding>)base.Problem; }
     44      get { return typeof(MultiObjectiveProblem<RealVectorEncoding, RealVector>); }
     45    }
     46    public new MultiObjectiveProblem<RealVectorEncoding, RealVector> Problem {
     47      get { return (MultiObjectiveProblem<RealVectorEncoding, RealVector>)base.Problem; }
    4848      set { base.Problem = value; }
    4949    }
     
    361361        ResultsDifferenceBestKnownHypervolume = ResultsBestKnownHypervolume;
    362362      }
    363       ResultsScatterPlot = new ParetoFrontScatterPlot(new double[0][], new double[0][], problem.BestKnownFront.ToJaggedArray(), problem.Objectives, problem.ProblemSize);
     363      ResultsScatterPlot = new ParetoFrontScatterPlot(new double[0][], new double[0][], problem.BestKnownFront.ToJaggedArray(), Problem.Objectives, Problem.Encoding.Length);
    364364    }
    365365    #endregion
     
    409409    }
    410410    private double[] Evaluate(RealVector x) {
    411       var res = Problem.Evaluate(new SingleEncodingIndividual(Problem.Encoding, new Scope { Variables = { new Variable(Problem.Encoding.Name, x) } }), random);
     411      var res = Problem.Evaluate(x, random);
    412412      return res;
    413413    }
     
    495495      ResultsHypervolumeDifferenceDataLine.Values.Add(ResultsDifferenceBestKnownHypervolume);
    496496
    497       Problem.Analyze(
    498         solutions.Select(x => (Optimization.Individual)new SingleEncodingIndividual(Problem.Encoding, new Scope { Variables = { new Variable(Problem.Encoding.Name, x.Mean) } })).ToArray(),
     497      Problem.Analyze(solutions.Select(x => x.Mean).ToArray(),
    499498        solutions.Select(x => x.Fitness).ToArray(),
    500499        Results,
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/MultiObjectiveTestFunctionProblem.cs

    r16723 r16807  
    2222using System.Collections.Generic;
    2323using System.Linq;
     24using HEAL.Attic;
    2425using HeuristicLab.Common;
    2526using HeuristicLab.Core;
     
    2829using HeuristicLab.Optimization;
    2930using HeuristicLab.Parameters;
    30 using HEAL.Attic;
    3131using HeuristicLab.Problems.Instances;
    3232
     
    3535  [Creatable(CreatableAttribute.Categories.Problems, Priority = 95)]
    3636  [Item("Test Function (multi-objective)", "Test functions with real valued inputs and multiple objectives.")]
    37   public class MultiObjectiveTestFunctionProblem : MultiObjectiveBasicProblem<RealVectorEncoding>, IProblemInstanceConsumer<MOTFData> {
     37  public class MultiObjectiveTestFunctionProblem : MultiObjectiveProblem<RealVectorEncoding, RealVector>, IProblemInstanceConsumer<MOTFData> {
    3838
    3939    #region Parameter Properties
    40     public IValueParameter<BoolArray> MaximizationParameter {
    41       get { return (IValueParameter<BoolArray>)Parameters["Maximization"]; }
    42     }
    4340    public IFixedValueParameter<IntValue> ProblemSizeParameter {
    4441      get { return (IFixedValueParameter<IntValue>)Parameters["ProblemSize"]; }
     
    6562    public override bool[] Maximization {
    6663      get {
    67         if (!Parameters.ContainsKey("Maximization")) return new bool[2];
    68         return MaximizationParameter.Value.ToArray();
     64        //necessary because of virtual member call in base ctor
     65        if (!Parameters.ContainsKey("TestFunction")) return new bool[0];
     66        return TestFunction.Maximization(Objectives).ToArray();
    6967      }
    7068    }
     
    136134
    137135
    138     public override void Analyze(Individual[] individuals, double[][] qualities, ResultCollection results, IRandom random) {
    139       base.Analyze(individuals, qualities, results, random);
     136    public override void Analyze(RealVector[] solutions, double[][] qualities, ResultCollection results, IRandom random) {
     137      base.Analyze(solutions, qualities, results, random);
    140138      if (results.ContainsKey("Pareto Front")) {
    141139        ((DoubleMatrix)results["Pareto Front"].Value).SortableView = true;
     
    156154    }
    157155
    158     public double[] Evaluate(RealVector individual) {
    159       return TestFunction.Evaluate(individual, Objectives);
    160     }
    161 
    162     public override double[] Evaluate(Individual individual, IRandom random) {
    163       return Evaluate(individual.RealVector());
    164     }
     156    public override double[] Evaluate(RealVector solution, IRandom random) {
     157      return TestFunction.Evaluate(solution, Objectives);
     158    }
     159
    165160
    166161    public void Load(MOTFData data) {
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/Misc/Fonseca.cs

    r16723 r16807  
    2222using System;
    2323using System.Collections.Generic;
     24using HEAL.Attic;
    2425using HeuristicLab.Common;
    2526using HeuristicLab.Core;
    2627using HeuristicLab.Encodings.RealVectorEncoding;
    27 using HEAL.Attic;
    2828
    2929namespace HeuristicLab.Problems.TestFunctions.MultiObjective {
     
    3535    }
    3636
    37     protected override bool[] GetMaximization(int objecitves) {
     37    protected override bool[] GetMaximization(int objectives) {
    3838      return new bool[2];
    3939    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.Views/3.3/SingleObjectiveTestFunctionSolutionView.cs

    r16723 r16807  
    148148      pictureBox.Refresh();
    149149      DoubleMatrix bounds = Content.Bounds;
    150       if (bounds == null) bounds = Content.Evaluator.Bounds;
     150      if (bounds == null) bounds = Content.Bounds;
    151151      double xMin = bounds[0, 0], xMax = bounds[0, 1], yMin = bounds[1 % bounds.Rows, 0], yMax = bounds[1 % bounds.Rows, 1];
    152152      double xStep = backgroundImage.Width / (xMax - xMin), yStep = backgroundImage.Height / (yMax - yMin);
Note: See TracChangeset for help on using the changeset viewer.