Changeset 5492 for branches/SuccessProgressAnalysis/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3
- Timestamp:
- 02/16/11 14:50:59 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SuccessProgressAnalysis/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/SuccessProgressAnalysis/SuccessProgressAnalyzer.cs
r5379 r5492 40 40 [StorableClass] 41 41 public sealed class SuccessProgressAnalyzer: SingleSuccessorOperator, IAnalyzer { 42 public ScopeTreeLookupParameter<BoolValue> SuccessfulOffspring {43 get { return ( ScopeTreeLookupParameter<BoolValue>)Parameters["SuccessfulOffspring"]; }42 public ValueParameter<StringValue> SuccessfulOffspringFlag { 43 get { return (ValueParameter<StringValue>)Parameters["SuccessfulOffspringFlag"]; } 44 44 } 45 45 … … 64 64 public SuccessProgressAnalyzer() 65 65 : base() { 66 Parameters.Add(new ScopeTreeLookupParameter<BoolValue>("SuccessfulOffspring", "Indicates if the individual was successful."));66 Parameters.Add(new ValueParameter<StringValue>("SuccessfulOffspringFlag", "Indicates if the individual was successful.", new StringValue("SuccessfulOffspring"))); 67 67 Parameters.Add(new ValueParameter<ItemCollection<StringValue>>("CollectedValues", "The values that should be collected.", new ItemCollection<StringValue>())); 68 68 Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the succedd progress analysis results should be stored.")); … … 73 73 ResultCollection results = ResultsParameter.ActualValue; 74 74 75 ItemArray<BoolValue> successfulOffspring = SuccessfulOffspring.ActualValue;76 75 ItemCollection<StringValue> collectedValues = CollectedValues.Value; 77 78 int successfulCount = successfulOffspring.Where(s => s.Value).Count();79 if (successfulCount > 0 && collectedValues.Count > 0 && successfulOffspring.Length == ExecutionContext.Scope.SubScopes.Count) {80 76 foreach (StringValue collected in collectedValues) { 81 77 Dictionary<String, int> counts = new Dictionary<String, int>(); 82 78 for (int i = 0; i < ExecutionContext.Scope.SubScopes.Count; i++) { 83 79 IScope child = ExecutionContext.Scope.SubScopes[i]; 80 string successfulOffspringFlag = SuccessfulOffspringFlag.Value.Value; 81 if (child.Variables.ContainsKey(collected.Value) && 82 child.Variables.ContainsKey(successfulOffspringFlag) && 83 (child.Variables[successfulOffspringFlag].Value is BoolValue) && 84 (child.Variables[successfulOffspringFlag].Value as BoolValue).Value) { 85 String key = child.Variables[collected.Value].Value.ToString(); 84 86 85 if (successfulOffspring[i].Value && child.Variables.ContainsKey(collected.Value)) {86 String key = child.Variables[collected.Value].Value.ToString();87 88 87 if (!counts.ContainsKey(key)) 89 counts.Add(key, 1);88 counts.Add(key, 1); 90 89 else 91 counts[key]++;90 counts[key]++; 92 91 } 93 92 } … … 97 96 if (!results.ContainsKey(resultKey)) { 98 97 successProgressAnalysis = new DataTable(); 98 successProgressAnalysis.Name = "Success Progress Analysis"; 99 99 results.Add(new Result(resultKey, successProgressAnalysis)); 100 100 } else { 101 101 successProgressAnalysis = results[resultKey].Value as DataTable; 102 } 103 104 int successfulCount = 0; 105 foreach (string key in counts.Keys) { 106 successfulCount += counts[key]; 102 107 } 103 108 … … 108 113 int iterations = Generations.ActualValue.Value; 109 114 110 for (int i = 0; i < iterations; i++)115 for (int i = 1; i < iterations; i++) 111 116 row.Values.Add(0); 112 117 … … 124 129 } 125 130 } 126 }127 131 128 132 return base.Apply();
Note: See TracChangeset
for help on using the changeset viewer.