Changeset 3048 for trunk/sources/HeuristicLab.Analysis
- Timestamp:
- 03/15/10 23:49:54 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Analysis/3.3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Analysis/3.3/BestAverageWorstQualityCalculator.cs
r3017 r3048 34 34 [Creatable("Test")] 35 35 public sealed class BestAverageWorstQualityCalculator : SingleSuccessorOperator { 36 public IValueLookupParameter<Bool Data> MaximizationParameter {37 get { return (IValueLookupParameter<Bool Data>)Parameters["Maximization"]; }36 public IValueLookupParameter<BoolValue> MaximizationParameter { 37 get { return (IValueLookupParameter<BoolValue>)Parameters["Maximization"]; } 38 38 } 39 public ILookupParameter<ItemArray<Double Data>> QualityParameter {40 get { return (ILookupParameter<ItemArray<Double Data>>)Parameters["Quality"]; }39 public ILookupParameter<ItemArray<DoubleValue>> QualityParameter { 40 get { return (ILookupParameter<ItemArray<DoubleValue>>)Parameters["Quality"]; } 41 41 } 42 public IValueLookupParameter<Double Data> BestQualityParameter {43 get { return (IValueLookupParameter<Double Data>)Parameters["BestQuality"]; }42 public IValueLookupParameter<DoubleValue> BestQualityParameter { 43 get { return (IValueLookupParameter<DoubleValue>)Parameters["BestQuality"]; } 44 44 } 45 public IValueLookupParameter<Double Data> AverageQualityParameter {46 get { return (IValueLookupParameter<Double Data>)Parameters["AverageQuality"]; }45 public IValueLookupParameter<DoubleValue> AverageQualityParameter { 46 get { return (IValueLookupParameter<DoubleValue>)Parameters["AverageQuality"]; } 47 47 } 48 public IValueLookupParameter<Double Data> WorstQualityParameter {49 get { return (IValueLookupParameter<Double Data>)Parameters["WorstQuality"]; }48 public IValueLookupParameter<DoubleValue> WorstQualityParameter { 49 get { return (IValueLookupParameter<DoubleValue>)Parameters["WorstQuality"]; } 50 50 } 51 51 52 52 public BestAverageWorstQualityCalculator() 53 53 : base() { 54 Parameters.Add(new ValueLookupParameter<Bool Data>("Maximization", "True if the current problem is a maximization problem, otherwise false."));55 Parameters.Add(new SubScopesLookupParameter<Double Data>("Quality", "The value contained in each sub-scope which represents the solution quality."));56 Parameters.Add(new ValueLookupParameter<Double Data>("BestQuality", "The quality value of the best solution."));57 Parameters.Add(new ValueLookupParameter<Double Data>("AverageQuality", "The average quality of all solutions."));58 Parameters.Add(new ValueLookupParameter<Double Data>("WorstQuality", "The quality value of the worst solution."));54 Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "True if the current problem is a maximization problem, otherwise false.")); 55 Parameters.Add(new SubScopesLookupParameter<DoubleValue>("Quality", "The value contained in each sub-scope which represents the solution quality.")); 56 Parameters.Add(new ValueLookupParameter<DoubleValue>("BestQuality", "The quality value of the best solution.")); 57 Parameters.Add(new ValueLookupParameter<DoubleValue>("AverageQuality", "The average quality of all solutions.")); 58 Parameters.Add(new ValueLookupParameter<DoubleValue>("WorstQuality", "The quality value of the worst solution.")); 59 59 } 60 60 61 61 62 62 public override IOperation Apply() { 63 ItemArray<Double Data> qualities = QualityParameter.ActualValue;63 ItemArray<DoubleValue> qualities = QualityParameter.ActualValue; 64 64 bool maximization = MaximizationParameter.ActualValue.Value; 65 65 … … 77 77 } 78 78 79 Double Databest = BestQualityParameter.ActualValue;80 if (best == null) BestQualityParameter.ActualValue = new Double Data(max);79 DoubleValue best = BestQualityParameter.ActualValue; 80 if (best == null) BestQualityParameter.ActualValue = new DoubleValue(max); 81 81 else best.Value = max; 82 Double Dataaverage = AverageQualityParameter.ActualValue;83 if (average == null) AverageQualityParameter.ActualValue = new Double Data(sum / qualities.Length);82 DoubleValue average = AverageQualityParameter.ActualValue; 83 if (average == null) AverageQualityParameter.ActualValue = new DoubleValue(sum / qualities.Length); 84 84 else average.Value = sum / qualities.Length; 85 Double Dataworst = WorstQualityParameter.ActualValue;86 if (worst == null) WorstQualityParameter.ActualValue = new Double Data(min);85 DoubleValue worst = WorstQualityParameter.ActualValue; 86 if (worst == null) WorstQualityParameter.ActualValue = new DoubleValue(min); 87 87 else worst.Value = min; 88 88 } -
trunk/sources/HeuristicLab.Analysis/3.3/BestQualityMemorizer.cs
r3017 r3048 33 33 [StorableClass] 34 34 public class BestQualityMemorizer : SingleSuccessorOperator { 35 public IValueLookupParameter<Bool Data> MaximizationParameter {36 get { return (IValueLookupParameter<Bool Data>)Parameters["Maximization"]; }35 public IValueLookupParameter<BoolValue> MaximizationParameter { 36 get { return (IValueLookupParameter<BoolValue>)Parameters["Maximization"]; } 37 37 } 38 public ILookupParameter<ItemArray<Double Data>> QualityParameter {39 get { return (ILookupParameter<ItemArray<Double Data>>)Parameters["Quality"]; }38 public ILookupParameter<ItemArray<DoubleValue>> QualityParameter { 39 get { return (ILookupParameter<ItemArray<DoubleValue>>)Parameters["Quality"]; } 40 40 } 41 public IValueLookupParameter<Double Data> BestQualityParameter {42 get { return (IValueLookupParameter<Double Data>)Parameters["BestQuality"]; }41 public IValueLookupParameter<DoubleValue> BestQualityParameter { 42 get { return (IValueLookupParameter<DoubleValue>)Parameters["BestQuality"]; } 43 43 } 44 44 45 45 public BestQualityMemorizer() 46 46 : base() { 47 Parameters.Add(new ValueLookupParameter<Bool Data>("Maximization", "True if the current problem is a maximization problem, otherwise false."));48 Parameters.Add(new SubScopesLookupParameter<Double Data>("Quality", "The value contained in each sub-scope which represents the solution quality."));49 Parameters.Add(new ValueLookupParameter<Double Data>("BestQuality", "The quality value of the best solution."));47 Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "True if the current problem is a maximization problem, otherwise false.")); 48 Parameters.Add(new SubScopesLookupParameter<DoubleValue>("Quality", "The value contained in each sub-scope which represents the solution quality.")); 49 Parameters.Add(new ValueLookupParameter<DoubleValue>("BestQuality", "The quality value of the best solution.")); 50 50 } 51 51 52 52 public override IOperation Apply() { 53 ItemArray<Double Data> qualities = QualityParameter.ActualValue;53 ItemArray<DoubleValue> qualities = QualityParameter.ActualValue; 54 54 bool maximization = MaximizationParameter.ActualValue.Value; 55 Double Databest = BestQualityParameter.ActualValue;55 DoubleValue best = BestQualityParameter.ActualValue; 56 56 double max = (best != null) ? (best.Value) : ((maximization) ? (double.MinValue) : (double.MaxValue)); 57 57 58 foreach (Double Dataquality in qualities)58 foreach (DoubleValue quality in qualities) 59 59 if (IsBetter(maximization, quality.Value, max)) max = quality.Value; 60 60 61 if (best == null) BestQualityParameter.ActualValue = new Double Data(max);61 if (best == null) BestQualityParameter.ActualValue = new DoubleValue(max); 62 62 else best.Value = max; 63 63 return base.Apply(); -
trunk/sources/HeuristicLab.Analysis/3.3/DataTableValuesCollector.cs
r3017 r3048 52 52 53 53 foreach (IParameter param in CollectedValues) { 54 Double Data data = param.ActualValue as DoubleData;54 DoubleValue data = param.ActualValue as DoubleValue; 55 55 if (data == null) throw new InvalidOperationException("Only double data values can be collected by a DataTableValuesCollector."); 56 56
Note: See TracChangeset
for help on using the changeset viewer.