Changeset 5770 for branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective
- Timestamp:
- 03/21/11 00:19:08 (14 years ago)
- Location:
- branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectiveMeanSquaredErrorTreeSizeEvaluator.cs
r5759 r5770 46 46 public override Core.IOperation Apply() { 47 47 IEnumerable<int> rows = GenerateRowsToEvaluate(); 48 double[] qualities = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, SymbolicExpressionTreeParameter.ActualValue, LowerEstimationLimitParameter.ActualValue.Value, UpperEstimationLimitParameter.ActualValue.Value, ProblemDataParameter.ActualValue, rows);48 double[] qualities = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, SymbolicExpressionTreeParameter.ActualValue, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows); 49 49 QualitiesParameter.ActualValue = new DoubleArray(qualities); 50 50 return base.Apply(); … … 61 61 public override double[] Evaluate(IExecutionContext context, ISymbolicExpressionTree tree, IRegressionProblemData problemData, IEnumerable<int> rows) { 62 62 SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = context; 63 LowerEstimationLimitParameter.ExecutionContext = context; 64 UpperEstimationLimitParameter.ExecutionContext = context; 63 EstimationLimitsParameter.ExecutionContext = context; 65 64 66 double[] quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, LowerEstimationLimitParameter.ActualValue.Value, UpperEstimationLimitParameter.ActualValue.Value, problemData, rows);65 double[] quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows); 67 66 68 67 SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = null; 69 LowerEstimationLimitParameter.ExecutionContext = null; 70 UpperEstimationLimitParameter.ExecutionContext = null; 68 EstimationLimitsParameter.ExecutionContext = null; 71 69 72 70 return quality; -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectivePearsonRSquaredTreeSizeEvaluator.cs
r5759 r5770 47 47 public override IOperation Apply() { 48 48 IEnumerable<int> rows = GenerateRowsToEvaluate(); 49 double[] qualities = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, SymbolicExpressionTreeParameter.ActualValue, LowerEstimationLimitParameter.ActualValue.Value, UpperEstimationLimitParameter.ActualValue.Value, ProblemDataParameter.ActualValue, rows);49 double[] qualities = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, SymbolicExpressionTreeParameter.ActualValue, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows); 50 50 QualitiesParameter.ActualValue = new DoubleArray(qualities); 51 51 return base.Apply(); … … 67 67 public override double[] Evaluate(IExecutionContext context, ISymbolicExpressionTree tree, IRegressionProblemData problemData, IEnumerable<int> rows) { 68 68 SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = context; 69 LowerEstimationLimitParameter.ExecutionContext = context; 70 UpperEstimationLimitParameter.ExecutionContext = context; 69 EstimationLimitsParameter.ExecutionContext = context; 71 70 72 double[] quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, LowerEstimationLimitParameter.ActualValue.Value, UpperEstimationLimitParameter.ActualValue.Value, problemData, rows);71 double[] quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows); 73 72 74 73 SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = null; 75 LowerEstimationLimitParameter.ExecutionContext = null; 76 UpperEstimationLimitParameter.ExecutionContext = null; 74 EstimationLimitsParameter.ExecutionContext = null; 77 75 78 76 return quality; -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectiveProblem.cs
r5759 r5770 35 35 private const int InitialMaximumTreeDepth = 8; 36 36 private const int InitialMaximumTreeLength = 25; 37 private const string LowerEstimationLimitParameterName = "LowerEstimationLimit"; 38 private const string UpperEstimationLimitParameterName = "UpperEstimationLimit"; 39 private const string LowerEstimationLimitParameterDescription = "The lower limit for the estimated value that can be returned by the symbolic regression model."; 40 private const string UpperEstimationLimitParameterDescription = "The upper limit for the estimated value that can be returned by the symbolic regression model."; 37 private const string EstimationLimitsParameterName = "EstimationLimits"; 38 private const string EstimationLimitsParameterDescription = "The lower and upper limit for the estimated value that can be returned by the symbolic regression model."; 41 39 42 40 #region parameter properties 43 public IFixedValueParameter<DoubleValue> LowerEstimationLimitParameter { 44 get { return (IFixedValueParameter<DoubleValue>)Parameters[LowerEstimationLimitParameterName]; } 45 } 46 public IFixedValueParameter<DoubleValue> UpperEstimationLimitParameter { 47 get { return (IFixedValueParameter<DoubleValue>)Parameters[UpperEstimationLimitParameterName]; } 41 public IFixedValueParameter<DoubleLimit> EstimationLimitsParameter { 42 get { return (IFixedValueParameter<DoubleLimit>)Parameters[EstimationLimitsParameterName]; } 48 43 } 49 44 #endregion 45 50 46 #region properties 51 public Double Value LowerEstimationLimit{52 get { return LowerEstimationLimitParameter.Value; }47 public DoubleLimit EstimationLimits { 48 get { return EstimationLimitsParameter.Value; } 53 49 } 54 public DoubleValue UpperEstimationLimit { 55 get { return UpperEstimationLimitParameter.Value; } 56 } 50 57 51 #endregion 52 58 53 [StorableConstructor] 59 54 protected SymbolicRegressionMultiObjectiveProblem(bool deserializing) : base(deserializing) { } … … 63 58 public SymbolicRegressionMultiObjectiveProblem() 64 59 : base(new RegressionProblemData(), new SymbolicRegressionMultiObjectivePearsonRSquaredTreeSizeEvaluator(), new SymbolicDataAnalysisExpressionTreeCreator()) { 65 Parameters.Add(new FixedValueParameter<DoubleValue>(LowerEstimationLimitParameterName, LowerEstimationLimitParameterDescription, new DoubleValue())); 66 Parameters.Add(new FixedValueParameter<DoubleValue>(UpperEstimationLimitParameterName, UpperEstimationLimitParameterDescription, new DoubleValue())); 60 Parameters.Add(new FixedValueParameter<DoubleLimit>(EstimationLimitsParameterName, EstimationLimitsParameterDescription, new DoubleLimit())); 67 61 68 62 Maximization = new BoolArray(new bool[] { true, false }); … … 85 79 var mean = targetValues.Average(); 86 80 var range = targetValues.Max() - targetValues.Min(); 87 UpperEstimationLimit.Value= mean + PunishmentFactor * range;88 LowerEstimationLimit.Value= mean - PunishmentFactor * range;81 EstimationLimits.Upper = mean + PunishmentFactor * range; 82 EstimationLimits.Lower = mean - PunishmentFactor * range; 89 83 } 90 84 } … … 97 91 protected override void ParameterizeOperators() { 98 92 base.ParameterizeOperators(); 99 var operators = Parameters.OfType<IValueParameter>().Select(p => p.Value).OfType<IOperator>().Union(Operators); 100 foreach (var op in operators.OfType<ISymbolicDataAnalysisBoundedOperator>()) { 101 op.LowerEstimationLimitParameter.ActualName = LowerEstimationLimitParameterName; 102 op.UpperEstimationLimitParameter.ActualName = UpperEstimationLimitParameterName; 93 if (Parameters.ContainsKey(EstimationLimitsParameterName)) { 94 var operators = Parameters.OfType<IValueParameter>().Select(p => p.Value).OfType<IOperator>().Union(Operators); 95 foreach (var op in operators.OfType<ISymbolicDataAnalysisBoundedOperator>()) { 96 op.EstimationLimitsParameter.ActualName = EstimationLimitsParameter.Name; 97 } 103 98 } 104 99 } -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectiveTrainingBestSolutionAnalyzer.cs
r5747 r5770 20 20 #endregion 21 21 22 using System.Collections.Generic;23 using System.Linq;24 22 using HeuristicLab.Common; 25 23 using HeuristicLab.Core; 26 24 using HeuristicLab.Data; 27 25 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 28 using HeuristicLab.Operators;29 using HeuristicLab.Optimization;30 26 using HeuristicLab.Parameters; 31 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 41 37 private const string ProblemDataParameterName = "ProblemData"; 42 38 private const string SymbolicDataAnalysisTreeInterpreterParameterName = "SymbolicDataAnalysisTreeInterpreter"; 43 private const string UpperEstimationLimitParameterName = "UpperEstimationLimit"; 44 private const string LowerEstimationLimitParameterName = "LowerEstimationLimit"; 39 private const string EstimationLimitsParameterName = "EstimationLimits"; 45 40 private const string ApplyLinearScalingParameterName = "ApplyLinearScaling"; 46 41 #region parameter properties … … 51 46 get { return (ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>)Parameters[SymbolicDataAnalysisTreeInterpreterParameterName]; } 52 47 } 53 public IValueLookupParameter<DoubleValue> UpperEstimationLimitParameter { 54 get { return (IValueLookupParameter<DoubleValue>)Parameters[UpperEstimationLimitParameterName]; } 55 } 56 57 public IValueLookupParameter<DoubleValue> LowerEstimationLimitParameter { 58 get { return (IValueLookupParameter<DoubleValue>)Parameters[LowerEstimationLimitParameterName]; } 48 public IValueLookupParameter<DoubleLimit> EstimationLimitsParameter { 49 get { return (IValueLookupParameter<DoubleLimit>)Parameters[EstimationLimitsParameterName]; } 59 50 } 60 51 public IValueParameter<BoolValue> ApplyLinearScalingParameter { … … 64 55 65 56 #region properties 66 public IRegressionProblemData ProblemData {67 get { return ProblemDataParameter.ActualValue; }68 }69 public ISymbolicDataAnalysisExpressionTreeInterpreter SymbolicDataAnalysisTreeInterpreter {70 get { return SymbolicDataAnalysisTreeInterpreterParameter.ActualValue; }71 }72 public DoubleValue UpperEstimationLimit {73 get { return UpperEstimationLimitParameter.ActualValue; }74 }75 public DoubleValue LowerEstimationLimit {76 get { return LowerEstimationLimitParameter.ActualValue; }77 }78 57 public BoolValue ApplyLinearScaling { 79 58 get { return ApplyLinearScalingParameter.Value; } … … 88 67 Parameters.Add(new LookupParameter<IRegressionProblemData>(ProblemDataParameterName, "The problem data for the symbolic regression solution.")); 89 68 Parameters.Add(new LookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>(SymbolicDataAnalysisTreeInterpreterParameterName, "The symbolic data analysis tree interpreter for the symbolic expression tree.")); 90 Parameters.Add(new ValueLookupParameter<DoubleValue>(UpperEstimationLimitParameterName, "The upper limit for the estimated values produced by the symbolic regression model.")); 91 Parameters.Add(new ValueLookupParameter<DoubleValue>(LowerEstimationLimitParameterName, "The lower limit for the estimated values produced by the symbolic regression model.")); 69 Parameters.Add(new ValueLookupParameter<DoubleLimit>(EstimationLimitsParameterName, "The lower and upper limit for the estimated values produced by the symbolic regression model.")); 92 70 Parameters.Add(new ValueParameter<BoolValue>(ApplyLinearScalingParameterName, "Flag that indicates if the produced symbolic regression solution should be linearly scaled.", new BoolValue(true))); 93 71 } … … 98 76 99 77 protected override ISymbolicRegressionSolution CreateSolution(ISymbolicExpressionTree bestTree, double[] bestQuality) { 100 var model = new SymbolicRegressionModel(bestTree, SymbolicDataAnalysisTreeInterpreter , LowerEstimationLimit.Value, UpperEstimationLimit.Value);101 var solution = new SymbolicRegressionSolution(model, ProblemData );78 var model = new SymbolicRegressionModel(bestTree, SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper); 79 var solution = new SymbolicRegressionSolution(model, ProblemDataParameter.ActualValue); 102 80 if (ApplyLinearScaling.Value) 103 81 solution.ScaleModel(); -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectiveValidationBestSolutionAnalyzer.cs
r5759 r5770 35 35 public sealed class SymbolicRegressionMultiObjectiveValidationBestSolutionAnalyzer : SymbolicDataAnalysisMultiObjectiveValidationBestSolutionAnalyzer<ISymbolicRegressionSolution, ISymbolicRegressionMultiObjectiveEvaluator, IRegressionProblemData>, 36 36 ISymbolicDataAnalysisBoundedOperator { 37 private const string UpperEstimationLimitParameterName = "UpperEstimationLimit"; 38 private const string LowerEstimationLimitParameterName = "LowerEstimationLimit"; 37 private const string EstimationLimitsParameterName = "EstimationLimits"; 39 38 private const string ApplyLinearScalingParameterName = "ApplyLinearScaling"; 40 39 41 40 #region parameter properties 42 public IValueLookupParameter<DoubleValue> UpperEstimationLimitParameter { 43 get { return (IValueLookupParameter<DoubleValue>)Parameters[UpperEstimationLimitParameterName]; } 44 } 45 46 public IValueLookupParameter<DoubleValue> LowerEstimationLimitParameter { 47 get { return (IValueLookupParameter<DoubleValue>)Parameters[LowerEstimationLimitParameterName]; } 41 public IValueLookupParameter<DoubleLimit> EstimationLimitsParameter { 42 get { return (IValueLookupParameter<DoubleLimit>)Parameters[EstimationLimitsParameterName]; } 48 43 } 49 44 public IValueParameter<BoolValue> ApplyLinearScalingParameter { … … 62 57 public SymbolicRegressionMultiObjectiveValidationBestSolutionAnalyzer() 63 58 : base() { 64 Parameters.Add(new ValueLookupParameter<DoubleValue>(UpperEstimationLimitParameterName, "The upper limit for the estimated values produced by the symbolic regression model.")); 65 Parameters.Add(new ValueLookupParameter<DoubleValue>(LowerEstimationLimitParameterName, "The lower limit for the estimated values produced by the symbolic regression model.")); 59 Parameters.Add(new ValueLookupParameter<DoubleLimit>(EstimationLimitsParameterName, "The lower and upper limit for the estimated values produced by the symbolic regression model.")); 66 60 Parameters.Add(new ValueParameter<BoolValue>(ApplyLinearScalingParameterName, "Flag that indicates if the produced symbolic regression solution should be linearly scaled.", new BoolValue(true))); 67 61 } … … 71 65 72 66 protected override ISymbolicRegressionSolution CreateSolution(ISymbolicExpressionTree bestTree, double[] bestQuality) { 73 var model = new SymbolicRegressionModel(bestTree, SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, LowerEstimationLimitParameter.ActualValue.Value, UpperEstimationLimitParameter.ActualValue.Value);67 var model = new SymbolicRegressionModel(bestTree, SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper); 74 68 var solution = new SymbolicRegressionSolution(model, ProblemDataParameter.ActualValue); 75 69 if (ApplyLinearScaling.Value)
Note: See TracChangeset
for help on using the changeset viewer.