Changeset 16751 for branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/SingleObjectiveAnalyzer.cs
- Timestamp:
- 04/03/19 15:37:38 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/SingleObjectiveAnalyzer.cs
r16723 r16751 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HEAL.Attic; 25 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; … … 28 29 using HeuristicLab.Operators; 29 30 using HeuristicLab.Parameters; 30 using HEAL.Attic;31 31 32 32 namespace HeuristicLab.Optimization { 33 33 [Item("Single-objective Analyzer", "Calls the script's Analyze method to be able to write into the results collection.")] 34 34 [StorableType("3D20F8E2-CE11-4021-A05B-CFCB02C0FD6F")] 35 public sealed class SingleObjectiveAnalyzer<T Solution> : SingleSuccessorOperator, ISingleObjectiveAnalysisOperator<TSolution>, IAnalyzer, IStochasticOperator36 where T Solution : class, ISolution {35 public sealed class SingleObjectiveAnalyzer<TEncodedSolution> : SingleSuccessorOperator, ISingleObjectiveAnalysisOperator<TEncodedSolution>, IAnalyzer, IStochasticOperator 36 where TEncodedSolution : class, IEncodedSolution { 37 37 public bool EnabledByDefault { get { return true; } } 38 38 39 public ILookupParameter<IEncoding<T Solution>> EncodingParameter {40 get { return (ILookupParameter<IEncoding<T Solution>>)Parameters["Encoding"]; }39 public ILookupParameter<IEncoding<TEncodedSolution>> EncodingParameter { 40 get { return (ILookupParameter<IEncoding<TEncodedSolution>>)Parameters["Encoding"]; } 41 41 } 42 42 … … 53 53 } 54 54 55 public Action<T Solution[], double[], ResultCollection, IRandom> AnalyzeAction { get; set; }55 public Action<TEncodedSolution[], double[], ResultCollection, IRandom> AnalyzeAction { get; set; } 56 56 57 57 [StorableConstructor] 58 58 private SingleObjectiveAnalyzer(StorableConstructorFlag _) : base(_) { } 59 private SingleObjectiveAnalyzer(SingleObjectiveAnalyzer<T Solution> original, Cloner cloner) : base(original, cloner) { }59 private SingleObjectiveAnalyzer(SingleObjectiveAnalyzer<TEncodedSolution> original, Cloner cloner) : base(original, cloner) { } 60 60 public SingleObjectiveAnalyzer() { 61 Parameters.Add(new LookupParameter<IEncoding<T Solution>>("Encoding", "An item that holds the problem's encoding."));61 Parameters.Add(new LookupParameter<IEncoding<TEncodedSolution>>("Encoding", "An item that holds the problem's encoding.")); 62 62 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The quality of the parameter vector.")); 63 63 Parameters.Add(new LookupParameter<ResultCollection>("Results", "The results collection to write to.")); … … 66 66 67 67 public override IDeepCloneable Clone(Cloner cloner) { 68 return new SingleObjectiveAnalyzer<T Solution>(this, cloner);68 return new SingleObjectiveAnalyzer<TEncodedSolution>(this, cloner); 69 69 } 70 70 … … 78 78 scopes = scopes.Select(x => (IEnumerable<IScope>)x.SubScopes).Aggregate((a, b) => a.Concat(b)); 79 79 80 var individuals = scopes.Select(s => ScopeUtil.Get Solution(s, encoding)).ToArray();80 var individuals = scopes.Select(s => ScopeUtil.GetEncodedSolution(s, encoding)).ToArray(); 81 81 AnalyzeAction(individuals, QualityParameter.ActualValue.Select(x => x.Value).ToArray(), results, random); 82 82 return base.Apply();
Note: See TracChangeset
for help on using the changeset viewer.