Changeset 5685 for branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/SymbolicRegressionSingleObjectiveProblem.cs
- Timestamp:
- 03/15/11 12:35:14 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/SymbolicRegressionSingleObjectiveProblem.cs
r5623 r5685 24 24 using HeuristicLab.Core; 25 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 using HeuristicLab.Parameters; 27 using HeuristicLab.Data; 26 28 27 29 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression { … … 31 33 public class SymbolicRegressionSingleObjectiveProblem : SymbolicDataAnalysisSingleObjectiveProblem<IRegressionProblemData, ISymbolicRegressionSingleObjectiveEvaluator, ISymbolicDataAnalysisSolutionCreator> { 32 34 private const double PunishmentFactor = 10; 33 35 private const int InitialMaximumTreeDepth = 8; 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."; 41 42 #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]; } 48 } 49 #endregion 50 #region properties 51 public DoubleValue LowerEstimationLimit { 52 get { return LowerEstimationLimitParameter.Value; } 53 } 54 public DoubleValue UpperEstimationLimit { 55 get { return UpperEstimationLimitParameter.Value; } 56 } 57 #endregion 34 58 [StorableConstructor] 35 59 protected SymbolicRegressionSingleObjectiveProblem(bool deserializing) : base(deserializing) { } … … 39 63 public SymbolicRegressionSingleObjectiveProblem() 40 64 : base(new RegressionProblemData(), new SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator(), new SymbolicDataAnalysisExpressionTreeCreator()) { 65 Parameters.Add(new FixedValueParameter<DoubleValue>(LowerEstimationLimitParameterName, LowerEstimationLimitParameterDescription, new DoubleValue())); 66 Parameters.Add(new FixedValueParameter<DoubleValue>(UpperEstimationLimitParameterName, UpperEstimationLimitParameterDescription, new DoubleValue())); 67 41 68 Maximization.Value = true; 42 MaximumSymbolicExpressionTreeDepth.Value = 8; 43 MaximumSymbolicExpressionTreeLength.Value = 25; 69 MaximumSymbolicExpressionTreeDepth.Value = InitialMaximumTreeDepth; 70 MaximumSymbolicExpressionTreeLength.Value = InitialMaximumTreeLength; 71 72 InitializeOperators(); 44 73 } 45 74 46 protected override void UpdateEstimationLimits() { 75 private void InitializeOperators() { 76 Operators.Add(new SymbolicRegressionSingleObjectiveTrainingBestSolutionAnalyzer()); 77 Operators.Add(new SymbolicRegressionSingleObjectiveValidationBestSolutionAnalyzer()); 78 ParameterizeOperators(); 79 } 80 81 private void UpdateEstimationLimits() { 47 82 if (ProblemData.TrainingPartitionStart.Value < ProblemData.TrainingPartitionEnd.Value) { 48 83 var targetValues = ProblemData.Dataset.GetVariableValues(ProblemData.TargetVariable, ProblemData.TrainingPartitionStart.Value, ProblemData.TrainingPartitionEnd.Value); … … 54 89 } 55 90 91 protected override void OnProblemDataChanged() { 92 base.OnProblemDataChanged(); 93 UpdateEstimationLimits(); 94 } 95 96 protected override void ParameterizeOperators() { 97 base.ParameterizeOperators(); 98 var operators = Parameters.OfType<IValueParameter>().Select(p => p.Value).OfType<IOperator>().Union(Operators); 99 foreach (var op in operators.OfType<ISymbolicDataAnalysisBoundedEvaluator<IRegressionProblemData>>()) { 100 op.LowerEstimationLimitParameter.ActualName = LowerEstimationLimitParameterName; 101 op.UpperEstimationLimitParameter.ActualName = UpperEstimationLimitParameterName; 102 } 103 } 104 56 105 public override void ImportProblemDataFromFile(string fileName) { 57 106 RegressionProblemData problemData = RegressionProblemData.ImportFromFile(fileName);
Note: See TracChangeset
for help on using the changeset viewer.