Changeset 13336 for branches/ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/SingleObjectiveAnalyzer.cs
- Timestamp:
- 11/23/15 15:15:27 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/SingleObjectiveAnalyzer.cs
r11961 r13336 33 33 [Item("Single-objective Analyzer", "Calls the script's Analyze method to be able to write into the results collection.")] 34 34 [StorableClass] 35 public sealed class SingleObjectiveAnalyzer : SingleSuccessorOperator, ISingleObjectiveAnalysisOperator, IAnalyzer, IStochasticOperator { 35 public sealed class SingleObjectiveAnalyzer<TSolution> : SingleSuccessorOperator, ISingleObjectiveAnalysisOperator<TSolution>, IAnalyzer, IStochasticOperator 36 where TSolution : class, ISolution { 36 37 public bool EnabledByDefault { get { return true; } } 37 38 38 public ILookupParameter<IEncoding > EncodingParameter {39 get { return (ILookupParameter<IEncoding >)Parameters["Encoding"]; }39 public ILookupParameter<IEncoding<TSolution>> EncodingParameter { 40 get { return (ILookupParameter<IEncoding<TSolution>>)Parameters["Encoding"]; } 40 41 } 41 42 … … 52 53 } 53 54 54 public Action< Individual[], double[], ResultCollection, IRandom> AnalyzeAction { get; set; }55 public Action<TSolution[], double[], ResultCollection, IRandom> AnalyzeAction { get; set; } 55 56 56 57 [StorableConstructor] 57 58 private SingleObjectiveAnalyzer(bool deserializing) : base(deserializing) { } 58 private SingleObjectiveAnalyzer(SingleObjectiveAnalyzer original, Cloner cloner) : base(original, cloner) { }59 private SingleObjectiveAnalyzer(SingleObjectiveAnalyzer<TSolution> original, Cloner cloner) : base(original, cloner) { } 59 60 public SingleObjectiveAnalyzer() { 60 Parameters.Add(new LookupParameter<IEncoding >("Encoding", "An item that holds the problem's encoding."));61 Parameters.Add(new LookupParameter<IEncoding<TSolution>>("Encoding", "An item that holds the problem's encoding.")); 61 62 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The quality of the parameter vector.")); 62 63 Parameters.Add(new LookupParameter<ResultCollection>("Results", "The results collection to write to.")); … … 65 66 66 67 public override IDeepCloneable Clone(Cloner cloner) { 67 return new SingleObjectiveAnalyzer (this, cloner);68 return new SingleObjectiveAnalyzer<TSolution>(this, cloner); 68 69 } 69 70 … … 77 78 scopes = scopes.Select(x => (IEnumerable<IScope>)x.SubScopes).Aggregate((a, b) => a.Concat(b)); 78 79 79 var individuals = scopes.Select( encoding.GetIndividual).ToArray();80 var individuals = scopes.Select(s => ScopeUtil.GetSolution(s, encoding)).ToArray(); 80 81 AnalyzeAction(individuals, QualityParameter.ActualValue.Select(x => x.Value).ToArray(), results, random); 81 82 return base.Apply();
Note: See TracChangeset
for help on using the changeset viewer.