Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/17/11 09:12:25 (14 years ago)
Author:
svonolfe
Message:

Implemented review comments from swagner (#1392)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/SuccessfulOffspringAnalysis/SuccessfulOffspringAnalyzer.cs

    r5683 r5725  
    4040  [StorableClass]
    4141  public sealed class SuccessfulOffspringAnalyzer : SingleSuccessorOperator, IAnalyzer {
    42     public ValueParameter<StringValue> SuccessfulOffspringFlag {
     42    public ValueParameter<StringValue> SuccessfulOffspringFlagParameter {
    4343      get { return (ValueParameter<StringValue>)Parameters["SuccessfulOffspringFlag"]; }
    4444    }
    4545
    46     public ValueParameter<ItemCollection<StringValue>> CollectedValues {
     46    public ValueParameter<ItemCollection<StringValue>> CollectedValuesParameter {
    4747      get { return (ValueParameter<ItemCollection<StringValue>>)Parameters["CollectedValues"]; }
    4848    }
     
    5050    public ValueLookupParameter<ResultCollection> ResultsParameter {
    5151      get { return (ValueLookupParameter<ResultCollection>)Parameters["Results"]; }
     52    }
     53
     54    public LookupParameter<ResultCollection> SuccessfulOffspringAnalysisParameter {
     55      get { return (LookupParameter<ResultCollection>)Parameters["SuccessfulOffspringAnalysis"];  }
    5256    }
    5357
     
    7175        Parameters.Add(new ValueParameter<ItemCollection<StringValue>>("CollectedValues", "The properties of the successful offspring that should be collected.", new ItemCollection<StringValue>()));
    7276        Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the succedd progress analysis results should be stored."));
    73         Parameters.Add(new LookupParameter<IntValue>("Generations", "The current number of generations."));
     77        Parameters.Add(new LookupParameter<IntValue>("Generations", "The current number of generations.")); 
     78        Parameters.Add(new LookupParameter<ResultCollection>("SuccessfulOffspringAnalysis", "The successful offspring analysis which is created."));
    7479        Parameters.Add(new ValueParameter<IntValue>("Depth", "The depth of the individuals in the scope tree.", new IntValue(1)));
    7580    }
     
    8287        scopes = scopes.Select(x => (IEnumerable<IScope>)x.SubScopes).Aggregate((a, b) => a.Concat(b)).ToList();
    8388
    84       ItemCollection<StringValue> collectedValues = CollectedValues.Value;
     89      ItemCollection<StringValue> collectedValues = CollectedValuesParameter.Value;
    8590        foreach (StringValue collected in collectedValues) {
    8691          //collect the values of the successful offspring
     
    8893          for (int i = 0; i < scopes.Count; i++) {
    8994            IScope child = scopes[i];
    90             string successfulOffspringFlag = SuccessfulOffspringFlag.Value.Value;
     95            string successfulOffspringFlag = SuccessfulOffspringFlagParameter.Value.Value;
    9196            if (child.Variables.ContainsKey(collected.Value) &&
    9297                child.Variables.ContainsKey(successfulOffspringFlag) &&
     
    103108
    104109          //create a data table containing the collected values
     110          ResultCollection successfulOffspringAnalysis;
     111
     112          if (SuccessfulOffspringAnalysisParameter.ActualValue == null) {
     113            successfulOffspringAnalysis = new ResultCollection();
     114            SuccessfulOffspringAnalysisParameter.ActualValue = successfulOffspringAnalysis;
     115          } else {
     116            successfulOffspringAnalysis = SuccessfulOffspringAnalysisParameter.ActualValue;
     117          }
     118
     119          string resultKey = "SuccessfulOffspringAnalyzer Results";
     120          if (!results.ContainsKey(resultKey)) {
     121            results.Add(new Result(resultKey, successfulOffspringAnalysis));
     122          } else {
     123            results[resultKey].Value = successfulOffspringAnalysis;
     124          }             
     125
    105126          DataTable successProgressAnalysis;
    106           string resultKey = "Success Progress " + collected.Value;
    107           if (!results.ContainsKey(resultKey)) {
     127          if (!successfulOffspringAnalysis.ContainsKey(collected.Value)) {
    108128            successProgressAnalysis = new DataTable();
    109             successProgressAnalysis.Name = "Success Progress Analysis";
    110             results.Add(new Result(resultKey, successProgressAnalysis));
     129            successProgressAnalysis.Name = collected.Value;
     130            successfulOffspringAnalysis.Add(new Result(collected.Value, successProgressAnalysis));
    111131          } else {
    112             successProgressAnalysis = results[resultKey].Value as DataTable;
    113           }
     132            successProgressAnalysis = successfulOffspringAnalysis[collected.Value].Value as DataTable;
     133          }         
    114134
    115135          int successfulCount = 0;
Note: See TracChangeset for help on using the changeset viewer.