Changeset 14044 for branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Analyzers/MOTFAnalyzer.cs
- Timestamp:
- 07/12/16 18:20:50 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Analyzers/MOTFAnalyzer.cs
r14030 r14044 20 20 #endregion 21 21 22 using System.Collections.Generic;23 using System.Linq;24 22 using HeuristicLab.Common; 25 23 using HeuristicLab.Core; … … 35 33 [StorableClass] 36 34 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; } } 41 36 42 37 public IScopeTreeLookupParameter<DoubleArray> QualitiesParameter { … … 49 44 50 45 public ILookupParameter<IMultiObjectiveTestFunction> TestFunctionParameter { 51 get { 52 return (ILookupParameter<IMultiObjectiveTestFunction>)Parameters["TestFunction"]; 53 } 46 get { return (ILookupParameter<IMultiObjectiveTestFunction>)Parameters["TestFunction"]; } 54 47 } 55 48 56 49 public ILookupParameter<DoubleMatrix> BestKnownFrontParameter { 57 get { 58 return (ILookupParameter<DoubleMatrix>)Parameters["BestKnownFront"]; 59 } 50 get { return (ILookupParameter<DoubleMatrix>)Parameters["BestKnownFront"]; } 60 51 } 61 52 62 protected MOTFAnalyzer(MOTFAnalyzer original, Cloner cloner) : base(original, cloner) { 63 } 53 protected MOTFAnalyzer(MOTFAnalyzer original, Cloner cloner) : base(original, cloner) { } 54 64 55 [StorableConstructor] 65 56 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() { 68 58 Parameters.Add(new ScopeTreeLookupParameter<DoubleArray>("Qualities", "The qualities of the parameter vector.")); 69 59 Parameters.Add(new LookupParameter<ResultCollection>("Results", "The results collection to write to.")); … … 71 61 Parameters.Add(new LookupParameter<DoubleMatrix>("BestKnownFront", "The currently best known Pareto front")); 72 62 } 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);97 63 } 98 64 }
Note: See TracChangeset
for help on using the changeset viewer.