- Timestamp:
- 01/08/11 13:04:00 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/Analyzers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/Analyzers/BestSymbolicRegressionSolutionAnalyzer.cs
r4722 r5246 110 110 } 111 111 112 public static void UpdateBestSolutionResults(SymbolicRegressionSolution bestSolution, DataAnalysisProblemData problemData, ResultCollection results, IntValue currentGeneration, DataTable variableFrequencies) {113 RegressionSolutionAnalyzer.UpdateBestSolutionResults( bestSolution, problemData, results, currentGeneration);114 UpdateSymbolicRegressionBestSolutionResults( bestSolution, problemData, results, variableFrequencies);112 public static void UpdateBestSolutionResults(SymbolicRegressionSolution solution, DataAnalysisProblemData problemData, ResultCollection results, IntValue currentGeneration, DataTable variableFrequencies) { 113 RegressionSolutionAnalyzer.UpdateBestSolutionResults(solution, problemData, results, currentGeneration); 114 UpdateSymbolicRegressionBestSolutionResults(solution, problemData, results, variableFrequencies); 115 115 } 116 116 117 private static void UpdateSymbolicRegressionBestSolutionResults(SymbolicRegressionSolution bestSolution, DataAnalysisProblemData problemData, ResultCollection results, DataTable variableFrequencies) {117 private static void UpdateSymbolicRegressionBestSolutionResults(SymbolicRegressionSolution solution, DataAnalysisProblemData problemData, ResultCollection results, DataTable variableFrequencies) { 118 118 if (results.ContainsKey(BestSolutionInputvariableCountResultName)) { 119 results[BestSolutionInputvariableCountResultName].Value = new IntValue( bestSolution.Model.InputVariables.Count());119 results[BestSolutionInputvariableCountResultName].Value = new IntValue(solution.Model.InputVariables.Count()); 120 120 results[VariableImpactsResultName].Value = CalculateVariableImpacts(variableFrequencies); 121 121 } else { 122 results.Add(new Result(BestSolutionInputvariableCountResultName, new IntValue( bestSolution.Model.InputVariables.Count())));122 results.Add(new Result(BestSolutionInputvariableCountResultName, new IntValue(solution.Model.InputVariables.Count()))); 123 123 results.Add(new Result(VariableImpactsResultName, CalculateVariableImpacts(variableFrequencies))); 124 124 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/Analyzers/FixedValidationBestScaledSymbolicRegressionSolutionAnalyzer.cs
r5198 r5246 41 41 public sealed class FixedValidationBestScaledSymbolicRegressionSolutionAnalyzer : SymbolicRegressionValidationAnalyzer, ISymbolicRegressionAnalyzer { 42 42 private const string MaximizationParameterName = "Maximization"; 43 private const string CalculateSolutionComplexityParameterName = "CalculateSolutionComplexity"; 43 44 private const string BestSolutionParameterName = "Best solution (validation)"; 44 45 private const string BestSolutionQualityParameterName = "Best solution quality (validation)"; 46 private const string BestSolutionLengthParameterName = "Best solution length (validation)"; 47 private const string BestSolutionHeightParameterName = "Best solution height (validiation)"; 45 48 private const string CurrentBestValidationQualityParameterName = "Current best validation quality"; 46 49 private const string BestSolutionQualityValuesParameterName = "Validation Quality"; … … 54 57 get { return (ILookupParameter<BoolValue>)Parameters[MaximizationParameterName]; } 55 58 } 59 public IValueParameter<BoolValue> CalculateSolutionComplexityParameter { 60 get { return (IValueParameter<BoolValue>)Parameters[CalculateSolutionComplexityParameterName]; } 61 } 56 62 public ILookupParameter<SymbolicRegressionSolution> BestSolutionParameter { 57 63 get { return (ILookupParameter<SymbolicRegressionSolution>)Parameters[BestSolutionParameterName]; } … … 62 68 public ILookupParameter<DoubleValue> BestSolutionQualityParameter { 63 69 get { return (ILookupParameter<DoubleValue>)Parameters[BestSolutionQualityParameterName]; } 70 } 71 public ILookupParameter<IntValue> BestSolutionLengthParameter { 72 get { return (ILookupParameter<IntValue>)Parameters[BestSolutionLengthParameterName]; } 73 } 74 public ILookupParameter<IntValue> BestSolutionHeightParameter { 75 get { return (ILookupParameter<IntValue>)Parameters[BestSolutionHeightParameterName]; } 64 76 } 65 77 public ILookupParameter<ResultCollection> ResultsParameter { … … 78 90 get { return MaximizationParameter.ActualValue; } 79 91 } 92 public BoolValue CalculateSolutionComplexity { 93 get { return CalculateSolutionComplexityParameter.Value; } 94 set { CalculateSolutionComplexityParameter.Value = value; } 95 } 80 96 public ResultCollection Results { 81 97 get { return ResultsParameter.ActualValue; } … … 89 105 public DoubleValue BestSolutionQuality { 90 106 get { return BestSolutionQualityParameter.ActualValue; } 107 } 108 public IntValue BestSolutionLength { 109 get { return BestSolutionLengthParameter.ActualValue; } 110 set { BestSolutionLengthParameter.ActualValue = value; } 111 } 112 public IntValue BestSolutionHeight { 113 get { return BestSolutionHeightParameter.ActualValue; } 114 set { BestSolutionHeightParameter.ActualValue = value; } 91 115 } 92 116 … … 99 123 : base() { 100 124 Parameters.Add(new LookupParameter<BoolValue>(MaximizationParameterName, "The direction of optimization.")); 125 Parameters.Add(new ValueParameter<BoolValue>(CalculateSolutionComplexityParameterName, "Determines if the length and height of the validation best solution should be calculated.", new BoolValue(false))); 101 126 Parameters.Add(new LookupParameter<SymbolicRegressionSolution>(BestSolutionParameterName, "The best symbolic regression solution.")); 102 127 Parameters.Add(new LookupParameter<IntValue>(GenerationsParameterName, "The number of generations calculated so far.")); 103 128 Parameters.Add(new LookupParameter<DoubleValue>(BestSolutionQualityParameterName, "The quality of the best symbolic regression solution.")); 129 Parameters.Add(new LookupParameter<IntValue>(BestSolutionLengthParameterName, "The length of the best symbolic regression solution.")); 130 Parameters.Add(new LookupParameter<IntValue>(BestSolutionHeightParameterName, "The height of the best symbolic regression solution.")); 104 131 Parameters.Add(new LookupParameter<ResultCollection>(ResultsParameterName, "The result collection where the best symbolic regression solution should be stored.")); 105 132 Parameters.Add(new LookupParameter<DoubleValue>(BestKnownQualityParameterName, "The best known (validation) quality achieved on the data set.")); … … 120 147 Parameters.Add(new LookupParameter<BoolValue>(MaximizationParameterName, "The direction of optimization.")); 121 148 } 149 if (!Parameters.ContainsKey(CalculateSolutionComplexityParameterName)) { 150 Parameters.Add(new ValueParameter<BoolValue>(CalculateSolutionComplexityParameterName, "Determines if the length and height of the validation best solution should be calculated.", new BoolValue(false))); 151 } 152 if (!Parameters.ContainsKey(BestSolutionLengthParameterName)) { 153 Parameters.Add(new LookupParameter<IntValue>(BestSolutionLengthParameterName, "The length of the best symbolic regression solution.")); 154 } 155 if (!Parameters.ContainsKey(BestSolutionHeightParameterName)) { 156 Parameters.Add(new LookupParameter<IntValue>(BestSolutionHeightParameterName, "The height of the best symbolic regression solution.")); 157 } 122 158 #endregion 123 159 } 124 160 125 161 protected override void Analyze(SymbolicExpressionTree[] trees, double[] validationQuality) { 126 162 double bestQuality = Maximization.Value ? double.NegativeInfinity : double.PositiveInfinity; 127 163 SymbolicExpressionTree bestTree = null; 128 164 129 for (int i=0;i<trees.Length;i++) {165 for (int i = 0; i < trees.Length; i++) { 130 166 double quality = validationQuality[i]; 131 167 if ((Maximization.Value && quality > bestQuality) || … … 164 200 BestSolutionQualityParameter.ActualValue = new DoubleValue(bestQuality); 165 201 202 if (CalculateSolutionComplexity.Value) { 203 BestSolutionLength = new IntValue(solution.Model.SymbolicExpressionTree.Size); 204 BestSolutionHeight = new IntValue(solution.Model.SymbolicExpressionTree.Height); 205 if (!Results.ContainsKey(BestSolutionLengthParameterName)) { 206 Results.Add(new Result(BestSolutionLengthParameterName, "Length of the best solution on the validation set", new IntValue())); 207 Results.Add(new Result(BestSolutionHeightParameterName, "Height of the best solution on the validation set", new IntValue())); 208 } 209 Results[BestSolutionLengthParameterName].Value = BestSolutionLength; 210 Results[BestSolutionHeightParameterName].Value = BestSolutionHeight; 211 } 212 166 213 BestSymbolicRegressionSolutionAnalyzer.UpdateBestSolutionResults(solution, ProblemData, Results, Generations, VariableFrequencies); 167 214 } 168 169 215 170 216 if (!Results.ContainsKey(BestSolutionQualityValuesParameterName)) {
Note: See TracChangeset
for help on using the changeset viewer.