Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/23/15 15:15:27 (8 years ago)
Author:
mkommend
Message:

#2521: Refactored encodings and problems.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Operators/SingleObjectiveAnalyzer.cs

    r11961 r13336  
    3333  [Item("Single-objective Analyzer", "Calls the script's Analyze method to be able to write into the results collection.")]
    3434  [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 {
    3637    public bool EnabledByDefault { get { return true; } }
    3738
    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"]; }
    4041    }
    4142
     
    5253    }
    5354
    54     public Action<Individual[], double[], ResultCollection, IRandom> AnalyzeAction { get; set; }
     55    public Action<TSolution[], double[], ResultCollection, IRandom> AnalyzeAction { get; set; }
    5556
    5657    [StorableConstructor]
    5758    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) { }
    5960    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."));
    6162      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The quality of the parameter vector."));
    6263      Parameters.Add(new LookupParameter<ResultCollection>("Results", "The results collection to write to."));
     
    6566
    6667    public override IDeepCloneable Clone(Cloner cloner) {
    67       return new SingleObjectiveAnalyzer(this, cloner);
     68      return new SingleObjectiveAnalyzer<TSolution>(this, cloner);
    6869    }
    6970
     
    7778        scopes = scopes.Select(x => (IEnumerable<IScope>)x.SubScopes).Aggregate((a, b) => a.Concat(b));
    7879
    79       var individuals = scopes.Select(encoding.GetIndividual).ToArray();
     80      var individuals = scopes.Select(s => ScopeUtil.GetSolution(s, encoding)).ToArray();
    8081      AnalyzeAction(individuals, QualityParameter.ActualValue.Select(x => x.Value).ToArray(), results, random);
    8182      return base.Apply();
Note: See TracChangeset for help on using the changeset viewer.