Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/12/16 18:20:50 (8 years ago)
Author:
mkommend
Message:

#1087: Refactored and improved analyzers for multi-objective test functions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Analyzers/MOTFAnalyzer.cs

    r14030 r14044  
    2020#endregion
    2121
    22 using System.Collections.Generic;
    23 using System.Linq;
    2422using HeuristicLab.Common;
    2523using HeuristicLab.Core;
     
    3533  [StorableClass]
    3634  public abstract class MOTFAnalyzer : SingleSuccessorOperator, IMultiObjectiveTestFunctionAnalyzer {
    37 
    38     public ILookupParameter<IEncoding> EncodingParameter {
    39       get { return (ILookupParameter<IEncoding>)Parameters["Encoding"]; }
    40     }
     35    public bool EnabledByDefault { get { return true; } }
    4136
    4237    public IScopeTreeLookupParameter<DoubleArray> QualitiesParameter {
     
    4944
    5045    public ILookupParameter<IMultiObjectiveTestFunction> TestFunctionParameter {
    51       get {
    52         return (ILookupParameter<IMultiObjectiveTestFunction>)Parameters["TestFunction"];
    53       }
     46      get { return (ILookupParameter<IMultiObjectiveTestFunction>)Parameters["TestFunction"]; }
    5447    }
    5548
    5649    public ILookupParameter<DoubleMatrix> BestKnownFrontParameter {
    57       get {
    58         return (ILookupParameter<DoubleMatrix>)Parameters["BestKnownFront"];
    59       }
     50      get { return (ILookupParameter<DoubleMatrix>)Parameters["BestKnownFront"]; }
    6051    }
    6152
    62     protected MOTFAnalyzer(MOTFAnalyzer original, Cloner cloner) : base(original, cloner) {
    63     }
     53    protected MOTFAnalyzer(MOTFAnalyzer original, Cloner cloner) : base(original, cloner) { }
     54
    6455    [StorableConstructor]
    6556    protected MOTFAnalyzer(bool deserializing) : base(deserializing) { }
    66     public MOTFAnalyzer() {
    67       Parameters.Add(new LookupParameter<IEncoding>("Encoding", "An item that holds the problem's encoding."));
     57    protected MOTFAnalyzer() {
    6858      Parameters.Add(new ScopeTreeLookupParameter<DoubleArray>("Qualities", "The qualities of the parameter vector."));
    6959      Parameters.Add(new LookupParameter<ResultCollection>("Results", "The results collection to write to."));
     
    7161      Parameters.Add(new LookupParameter<DoubleMatrix>("BestKnownFront", "The currently best known Pareto front"));
    7262    }
    73     [StorableHook(HookType.AfterDeserialization)]
    74     private void AfterDeserialization() {
    75     }
    76 
    77     public bool EnabledByDefault {
    78       get { return true; }
    79     }
    80 
    81     public override IOperation Apply() {
    82       var encoding = EncodingParameter.ActualValue;
    83       var results = ResultsParameter.ActualValue;
    84 
    85       IEnumerable<IScope> scopes = new[] { ExecutionContext.Scope };
    86       for (var i = 0; i < QualitiesParameter.Depth; i++)
    87         scopes = scopes.Select(x => (IEnumerable<IScope>)x.SubScopes).Aggregate((a, b) => a.Concat(b));
    88 
    89       var individuals = scopes.Select(encoding.GetIndividual).ToArray();
    90       if (individuals.Length > 0) {
    91         Analyze(individuals, QualitiesParameter.ActualValue.Select(x => x.ToArray()).ToArray(), results);
    92       }
    93       return base.Apply();
    94     }
    95 
    96     public abstract void Analyze(Individual[] individuals, double[][] qualities, ResultCollection results);
    9763  }
    9864}
Note: See TracChangeset for help on using the changeset viewer.