Changeset 9152
- Timestamp:
- 01/14/13 13:14:22 (12 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisMultiObjectiveTrainingBestSolutionAnalyzer.cs
r7259 r9152 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using System.Linq; … … 26 27 using HeuristicLab.Data; 27 28 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 28 using HeuristicLab.Operators;29 29 using HeuristicLab.Optimization; 30 30 using HeuristicLab.Parameters; 31 31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 32 using System;33 32 34 33 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 42 41 private const string TrainingBestSolutionsParameterName = "Best training solutions"; 43 42 private const string TrainingBestSolutionQualitiesParameterName = "Best training solution qualities"; 43 private const string UpdateAlwaysParameterName = "Always update best solutions"; 44 44 45 45 #region parameter properties … … 49 49 public ILookupParameter<ItemList<DoubleArray>> TrainingBestSolutionQualitiesParameter { 50 50 get { return (ILookupParameter<ItemList<DoubleArray>>)Parameters[TrainingBestSolutionQualitiesParameterName]; } 51 } 52 public IFixedValueParameter<BoolValue> UpdateAlwaysParameter { 53 get { return (IFixedValueParameter<BoolValue>)Parameters[UpdateAlwaysParameterName]; } 51 54 } 52 55 #endregion … … 60 63 set { TrainingBestSolutionQualitiesParameter.ActualValue = value; } 61 64 } 65 public BoolValue UpdateAlways { 66 get { return UpdateAlwaysParameter.Value; } 67 } 62 68 #endregion 63 69 … … 69 75 Parameters.Add(new LookupParameter<ItemList<T>>(TrainingBestSolutionsParameterName, "The training best (Pareto-optimal) symbolic data analysis solutions.")); 70 76 Parameters.Add(new LookupParameter<ItemList<DoubleArray>>(TrainingBestSolutionQualitiesParameterName, "The qualities of the training best (Pareto-optimal) solutions.")); 77 Parameters.Add(new FixedValueParameter<BoolValue>(UpdateAlwaysParameterName, "Determines if the best training solutions should always be updated regardless of its quality.", new BoolValue(false))); 78 UpdateAlwaysParameter.Hidden = true; 79 } 80 81 [StorableHook(HookType.AfterDeserialization)] 82 private void AfterDeserialization() { 83 if (!Parameters.ContainsKey(UpdateAlwaysParameterName)) { 84 Parameters.Add(new FixedValueParameter<BoolValue>(UpdateAlwaysParameterName, "Determines if the best training solutions should always be updated regardless of its quality.", new BoolValue(false))); 85 UpdateAlwaysParameter.Hidden = true; 86 } 71 87 } 72 88 … … 81 97 } 82 98 83 IList<double[]> trainingBestQualities = TrainingBestSolutionQualities 84 .Select(x => x.ToArray()) 85 .ToList(); 99 //if the pareto front of best solutions shall be updated regardless of the quality, the list initialized empty to discard old solutions 100 IList<double[]> trainingBestQualities; 101 if (UpdateAlways.Value) { 102 trainingBestQualities = new List<double[]>(); 103 } else { 104 trainingBestQualities = TrainingBestSolutionQualities.Select(x => x.ToArray()).ToList(); 105 } 86 106 87 107 #region find best trees … … 131 151 public bool Equals(double[] x, double[] y) { 132 152 if (y.Length != x.Length) throw new ArgumentException(); 133 for (int i = 0; i < x.Length; i++) {153 for (int i = 0; i < x.Length; i++) { 134 154 if (!x[i].IsAlmost(y[i])) return false; 135 155 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisMultiObjectiveValidationBestSolutionAnalyzer.cs
r7259 r9152 44 44 private const string ValidationBestSolutionsParameterName = "Best validation solutions"; 45 45 private const string ValidationBestSolutionQualitiesParameterName = "Best validation solution qualities"; 46 private const string UpdateAlwaysParameterName = "Always update best solutions"; 46 47 47 48 #region parameter properties … … 51 52 public ILookupParameter<ItemList<DoubleArray>> ValidationBestSolutionQualitiesParameter { 52 53 get { return (ILookupParameter<ItemList<DoubleArray>>)Parameters[ValidationBestSolutionQualitiesParameterName]; } 54 } 55 public IFixedValueParameter<BoolValue> UpdateAlwaysParameter { 56 get { return (IFixedValueParameter<BoolValue>)Parameters[UpdateAlwaysParameterName]; } 53 57 } 54 58 #endregion … … 62 66 set { ValidationBestSolutionQualitiesParameter.ActualValue = value; } 63 67 } 68 public BoolValue UpdateAlways { 69 get { return UpdateAlwaysParameter.Value; } 70 } 64 71 #endregion 65 72 … … 71 78 Parameters.Add(new LookupParameter<ItemList<S>>(ValidationBestSolutionsParameterName, "The validation best (Pareto-optimal) symbolic data analysis solutions.")); 72 79 Parameters.Add(new LookupParameter<ItemList<DoubleArray>>(ValidationBestSolutionQualitiesParameterName, "The qualities of the validation best (Pareto-optimal) solutions.")); 80 Parameters.Add(new FixedValueParameter<BoolValue>(UpdateAlwaysParameterName, "Determines if the best validation solutions should always be updated regardless of its quality.", new BoolValue(false))); 81 UpdateAlwaysParameter.Hidden = true; 82 } 83 84 [StorableHook(HookType.AfterDeserialization)] 85 private void AfterDeserialization() { 86 if (!Parameters.ContainsKey(UpdateAlwaysParameterName)) { 87 Parameters.Add(new FixedValueParameter<BoolValue>(UpdateAlwaysParameterName, "Determines if the best training solutions should always be updated regardless of its quality.", new BoolValue(false))); 88 UpdateAlwaysParameter.Hidden = true; 89 } 73 90 } 74 91 … … 86 103 } 87 104 88 IList<double[]> trainingBestQualities = ValidationBestSolutionQualities 89 .Select(x => x.ToArray()) 90 .ToList(); 105 //if the pareto front of best solutions shall be updated regardless of the quality, the list initialized empty to discard old solutions 106 IList<double[]> trainingBestQualities; 107 if (UpdateAlways.Value) { 108 trainingBestQualities = new List<double[]>(); 109 } else { 110 trainingBestQualities = ValidationBestSolutionQualities.Select(x => x.ToArray()).ToList(); 111 } 91 112 92 113 #region find best trees -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveTrainingBestSolutionAnalyzer.cs
r8798 r9152 20 20 #endregion 21 21 22 using System.Collections.Generic;23 22 using System.Linq; 24 23 using HeuristicLab.Common; … … 26 25 using HeuristicLab.Data; 27 26 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 28 using HeuristicLab.Operators;29 27 using HeuristicLab.Optimization; 30 28 using HeuristicLab.Parameters; … … 41 39 private const string TrainingBestSolutionParameterName = "Best training solution"; 42 40 private const string TrainingBestSolutionQualityParameterName = "Best training solution quality"; 41 private const string UpdateAlwaysParameterName = "Always update best solution"; 43 42 44 43 #region parameter properties … … 48 47 public ILookupParameter<DoubleValue> TrainingBestSolutionQualityParameter { 49 48 get { return (ILookupParameter<DoubleValue>)Parameters[TrainingBestSolutionQualityParameterName]; } 49 } 50 public IFixedValueParameter<BoolValue> UpdateAlwaysParameter { 51 get { return (IFixedValueParameter<BoolValue>)Parameters[UpdateAlwaysParameterName]; } 50 52 } 51 53 #endregion … … 59 61 set { TrainingBestSolutionQualityParameter.ActualValue = value; } 60 62 } 63 public BoolValue UpdateAlways { 64 get { return UpdateAlwaysParameter.Value; } 65 } 61 66 #endregion 62 67 … … 68 73 Parameters.Add(new LookupParameter<T>(TrainingBestSolutionParameterName, "The training best symbolic data analyis solution.")); 69 74 Parameters.Add(new LookupParameter<DoubleValue>(TrainingBestSolutionQualityParameterName, "The quality of the training best symbolic data analysis solution.")); 75 Parameters.Add(new FixedValueParameter<BoolValue>(UpdateAlwaysParameterName, "Determines if the best training solution should always be updated regardless of its quality.", new BoolValue(false))); 76 UpdateAlwaysParameter.Hidden = true; 77 } 78 79 [StorableHook(HookType.AfterDeserialization)] 80 private void AfterDeserialization() { 81 if (!Parameters.ContainsKey(UpdateAlwaysParameterName)) { 82 Parameters.Add(new FixedValueParameter<BoolValue>(UpdateAlwaysParameterName, "Determines if the best training solution should always be updated regardless of its quality.", new BoolValue(false))); 83 UpdateAlwaysParameter.Hidden = true; 84 } 70 85 } 71 86 … … 85 100 86 101 var results = ResultCollection; 87 if (bestTree != null && ( TrainingBestSolutionQuality == null ||102 if (bestTree != null && (UpdateAlways.Value || TrainingBestSolutionQuality == null || 88 103 IsBetter(bestQuality, TrainingBestSolutionQuality.Value, Maximization.Value))) { 89 104 TrainingBestSolution = CreateSolution(bestTree, bestQuality); -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveValidationBestSolutionAnalyzer.cs
r7721 r9152 43 43 private const string ValidationBestSolutionParameterName = "Best validation solution"; 44 44 private const string ValidationBestSolutionQualityParameterName = "Best validation solution quality"; 45 private const string UpdateAlwaysParameterName = "Always update best solution"; 45 46 46 47 #region parameter properties … … 50 51 public ILookupParameter<DoubleValue> ValidationBestSolutionQualityParameter { 51 52 get { return (ILookupParameter<DoubleValue>)Parameters[ValidationBestSolutionQualityParameterName]; } 53 } 54 public IFixedValueParameter<BoolValue> UpdateAlwaysParameter { 55 get { return (IFixedValueParameter<BoolValue>)Parameters[UpdateAlwaysParameterName]; } 52 56 } 53 57 #endregion … … 61 65 set { ValidationBestSolutionQualityParameter.ActualValue = value; } 62 66 } 67 public BoolValue UpdateAlways { 68 get { return UpdateAlwaysParameter.Value; } 69 } 63 70 #endregion 64 71 … … 70 77 Parameters.Add(new LookupParameter<S>(ValidationBestSolutionParameterName, "The validation best symbolic data analyis solution.")); 71 78 Parameters.Add(new LookupParameter<DoubleValue>(ValidationBestSolutionQualityParameterName, "The quality of the validation best symbolic data analysis solution.")); 79 Parameters.Add(new FixedValueParameter<BoolValue>(UpdateAlwaysParameterName, "Determines if the best validation solution should always be updated regardless of its quality.", new BoolValue(false))); 80 UpdateAlwaysParameter.Hidden = true; 81 } 82 83 [StorableHook(HookType.AfterDeserialization)] 84 private void AfterDeserialization() { 85 if (!Parameters.ContainsKey(UpdateAlwaysParameterName)) { 86 Parameters.Add(new FixedValueParameter<BoolValue>(UpdateAlwaysParameterName, "Determines if the best training solution should always be updated regardless of its quality.", new BoolValue(false))); 87 UpdateAlwaysParameter.Hidden = true; 88 } 72 89 } 73 90 … … 117 134 118 135 var results = ResultCollection; 119 if ( ValidationBestSolutionQuality == null ||136 if (UpdateAlways.Value || ValidationBestSolutionQuality == null || 120 137 IsBetter(bestValidationQuality, ValidationBestSolutionQuality.Value, Maximization.Value)) { 121 138 ValidationBestSolution = CreateSolution(bestTree, bestValidationQuality);
Note: See TracChangeset
for help on using the changeset viewer.