Changeset 13046 for branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/Analyzers/OldestAverageYoungestAgeCalculator.cs
- Timestamp:
- 10/21/15 17:42:18 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/Analyzers/OldestAverageYoungestAgeCalculator.cs
r12570 r13046 31 31 [StorableClass] 32 32 public sealed class OldestAverageYoungestAgeCalculator : SingleSuccessorOperator { 33 public IScopeTreeLookupParameter< IntValue> AgeParameter {34 get { return (IScopeTreeLookupParameter< IntValue>)Parameters["Age"]; }33 public IScopeTreeLookupParameter<DoubleValue> AgeParameter { 34 get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters["Age"]; } 35 35 } 36 public IValueLookupParameter< IntValue> OldestAgeParameter {37 get { return (IValueLookupParameter< IntValue>)Parameters["OldestAge"]; }36 public IValueLookupParameter<DoubleValue> OldestAgeParameter { 37 get { return (IValueLookupParameter<DoubleValue>)Parameters["OldestAge"]; } 38 38 } 39 public IValueLookupParameter< IntValue> AverageAgeParameter {40 get { return (IValueLookupParameter< IntValue>)Parameters["AverageAge"]; }39 public IValueLookupParameter<DoubleValue> AverageAgeParameter { 40 get { return (IValueLookupParameter<DoubleValue>)Parameters["AverageAge"]; } 41 41 } 42 public IValueLookupParameter< IntValue> YoungestAgeParameter {43 get { return (IValueLookupParameter< IntValue>)Parameters["YoungestAge"]; }42 public IValueLookupParameter<DoubleValue> YoungestAgeParameter { 43 get { return (IValueLookupParameter<DoubleValue>)Parameters["YoungestAge"]; } 44 44 } 45 45 … … 55 55 public OldestAverageYoungestAgeCalculator() 56 56 : base() { 57 Parameters.Add(new ScopeTreeLookupParameter< IntValue>("Age", "The value contained in the scope tree which represents the solution age."));58 Parameters.Add(new ValueLookupParameter< IntValue>("OldestAge", "The age value of the oldest solution."));59 Parameters.Add(new ValueLookupParameter< IntValue>("AverageAge", "The average age of all solutions."));60 Parameters.Add(new ValueLookupParameter< IntValue>("YoungestAge", "The age value of the youngest solution."));57 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Age", "The value contained in the scope tree which represents the solution age.")); 58 Parameters.Add(new ValueLookupParameter<DoubleValue>("OldestAge", "The age value of the oldest solution.")); 59 Parameters.Add(new ValueLookupParameter<DoubleValue>("AverageAge", "The average age of all solutions.")); 60 Parameters.Add(new ValueLookupParameter<DoubleValue>("YoungestAge", "The age value of the youngest solution.")); 61 61 62 62 OldestAgeParameter.Hidden = true; … … 69 69 70 70 if (ages.Length > 0) { 71 int min = int.MaxValue, max = int.MinValue, sum = 0;71 double min = double.MaxValue, max = double.MinValue, sum = 0; 72 72 for (int i = 0; i < ages.Length; i++) { 73 73 if (ages[i].Value < min) min = ages[i].Value; … … 77 77 78 78 var oldest = OldestAgeParameter.ActualValue; 79 if (oldest == null) OldestAgeParameter.ActualValue = new IntValue(max);79 if (oldest == null) OldestAgeParameter.ActualValue = new DoubleValue(max); 80 80 else oldest.Value = max; 81 81 var average = AverageAgeParameter.ActualValue; 82 if (average == null) AverageAgeParameter.ActualValue = new IntValue(sum / ages.Length);82 if (average == null) AverageAgeParameter.ActualValue = new DoubleValue(sum / ages.Length); 83 83 else average.Value = sum / ages.Length; 84 84 var youngest = YoungestAgeParameter.ActualValue; 85 if (youngest == null) YoungestAgeParameter.ActualValue = new IntValue(min);85 if (youngest == null) YoungestAgeParameter.ActualValue = new DoubleValue(min); 86 86 else youngest.Value = min; 87 87 }
Note: See TracChangeset
for help on using the changeset viewer.