Changeset 5685
- Timestamp:
- 03/15/11 12:35:14 (14 years ago)
- Location:
- branches/DataAnalysis Refactoring
- Files:
-
- 4 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification-3.4.csproj
r5649 r5685 109 109 <ItemGroup> 110 110 <Compile Include="Interfaces\ISymbolicDiscriminantFunctionClassificationModel.cs" /> 111 <Compile Include="MultiObjective\SymbolicClassificationMultiObjectiveValidationBestSolutionAnalyzer.cs" /> 112 <Compile Include="SingleObjective\SymbolicClassificationSingleObjectiveValidationBestSolutionAnalyzer.cs" /> 111 113 <Compile Include="SymbolicDiscriminantFunctionClassificationModel.cs" /> 112 114 <Compile Include="SymbolicDiscriminantFunctionClassificationSolution.cs" /> -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/MultiObjective/SymbolicClassificationMultiObjectiveProblem.cs
r5623 r5685 24 24 using HeuristicLab.Data; 25 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 using HeuristicLab.Parameters; 26 27 27 28 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification { … … 31 32 public class SymbolicClassificationMultiObjectiveProblem : SymbolicDataAnalysisMultiObjectiveProblem<IClassificationProblemData, ISymbolicClassificationMultiObjectiveEvaluator, ISymbolicDataAnalysisSolutionCreator> { 32 33 private const double PunishmentFactor = 10; 34 private const int InitialMaximumTreeDepth = 8; 35 private const int InitialMaximumTreeLength = 25; 36 private const string LowerEstimationLimitParameterName = "LowerEstimationLimit"; 37 private const string UpperEstimationLimitParameterName = "UpperEstimationLimit"; 38 private const string LowerEstimationLimitParameterDescription = "The lower limit for the estimated value that can be returned by the symbolic classification model."; 39 private const string UpperEstimationLimitParameterDescription = "The upper limit for the estimated value that can be returned by the symbolic classification model."; 33 40 41 #region parameter properties 42 public IFixedValueParameter<DoubleValue> LowerEstimationLimitParameter { 43 get { return (IFixedValueParameter<DoubleValue>)Parameters[LowerEstimationLimitParameterName]; } 44 } 45 public IFixedValueParameter<DoubleValue> UpperEstimationLimitParameter { 46 get { return (IFixedValueParameter<DoubleValue>)Parameters[UpperEstimationLimitParameterName]; } 47 } 48 #endregion 49 #region properties 50 public DoubleValue LowerEstimationLimit { 51 get { return LowerEstimationLimitParameter.Value; } 52 } 53 public DoubleValue UpperEstimationLimit { 54 get { return UpperEstimationLimitParameter.Value; } 55 } 56 #endregion 34 57 [StorableConstructor] 35 58 protected SymbolicClassificationMultiObjectiveProblem(bool deserializing) : base(deserializing) { } … … 39 62 public SymbolicClassificationMultiObjectiveProblem() 40 63 : base(new ClassificationProblemData(), new SymbolicClassificationMultiObjectiveMeanSquaredErrorTreeSizeEvaluator(), new SymbolicDataAnalysisExpressionTreeCreator()) { 64 Parameters.Add(new FixedValueParameter<DoubleValue>(LowerEstimationLimitParameterName, LowerEstimationLimitParameterDescription, new DoubleValue())); 65 Parameters.Add(new FixedValueParameter<DoubleValue>(UpperEstimationLimitParameterName, UpperEstimationLimitParameterDescription, new DoubleValue())); 66 41 67 Maximization = new BoolArray(new bool[] { false, false }); 42 MaximumSymbolicExpressionTreeDepth.Value = 8; 43 MaximumSymbolicExpressionTreeLength.Value = 25; 68 MaximumSymbolicExpressionTreeDepth.Value = InitialMaximumTreeDepth; 69 MaximumSymbolicExpressionTreeLength.Value = InitialMaximumTreeLength; 70 71 InitializeOperators(); 44 72 } 45 73 46 protected override void UpdateEstimationLimits() { 74 private void InitializeOperators() { 75 Operators.Add(new SymbolicClassificationMultiObjectiveTrainingBestSolutionAnalyzer()); 76 Operators.Add(new SymbolicClassificationMultiObjectiveValidationBestSolutionAnalyzer()); 77 ParameterizeOperators(); 78 } 79 80 private void UpdateEstimationLimits() { 47 81 if (ProblemData.TrainingPartitionStart.Value < ProblemData.TrainingPartitionEnd.Value) { 48 82 var targetValues = ProblemData.Dataset.GetVariableValues(ProblemData.TargetVariable, ProblemData.TrainingPartitionStart.Value, ProblemData.TrainingPartitionEnd.Value); … … 54 88 } 55 89 90 protected override void OnProblemDataChanged() { 91 base.OnProblemDataChanged(); 92 UpdateEstimationLimits(); 93 } 94 95 protected new void ParameterizeOperators() { 96 base.ParameterizeOperators(); 97 var operators = Parameters.OfType<IValueParameter>().Select(p => p.Value).OfType<IOperator>().Union(Operators); 98 foreach (var op in operators.OfType<ISymbolicDataAnalysisBoundedEvaluator<IClassificationProblemData>>()) { 99 op.LowerEstimationLimitParameter.ActualName = LowerEstimationLimitParameterName; 100 op.UpperEstimationLimitParameter.ActualName = UpperEstimationLimitParameterName; 101 } 102 } 103 56 104 public override void ImportProblemDataFromFile(string fileName) { 57 105 ClassificationProblemData problemData = ClassificationProblemData.ImportFromFile(fileName); -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/MultiObjective/SymbolicClassificationMultiObjectiveTrainingBestSolutionAnalyzer.cs
r5681 r5685 63 63 : base() { 64 64 Parameters.Add(new LookupParameter<IClassificationProblemData>(ProblemDataParameterName, "The problem data for the symbolic classification solution.")); 65 Parameters.Add(new LookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>(SymbolicDataAnalysisTreeInterpreterParameterName, "The symbolic data analysis tree interpreter for the symbolic expression tree.")); 65 66 } 66 67 public override IDeepCloneable Clone(Cloner cloner) { … … 77 78 var model = new SymbolicDiscriminantFunctionClassificationModel(bestTree, SymbolicDataAnalysisTreeInterpreter, classValues, thresholds); 78 79 return new SymbolicDiscriminantFunctionClassificationSolution(model, ProblemData); 79 } 80 } 80 81 } 81 82 } -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SingleObjective/SymbolicClassificationSingleObjectiveProblem.cs
r5623 r5685 23 23 using HeuristicLab.Core; 24 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 25 using HeuristicLab.Parameters; 26 using HeuristicLab.Data; 25 27 26 28 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification { … … 30 32 public class SymbolicClassificationSingleObjectiveProblem : SymbolicDataAnalysisSingleObjectiveProblem<IClassificationProblemData, ISymbolicClassificationSingleObjectiveEvaluator, ISymbolicDataAnalysisSolutionCreator> { 31 33 private const double PunishmentFactor = 10; 34 private const int InitialMaximumTreeDepth = 8; 35 private const int InitialMaximumTreeLength = 25; 36 private const string LowerEstimationLimitParameterName = "LowerEstimationLimit"; 37 private const string UpperEstimationLimitParameterName = "UpperEstimationLimit"; 38 private const string LowerEstimationLimitParameterDescription = "The lower limit for the estimated value that can be returned by the symbolic classification model."; 39 private const string UpperEstimationLimitParameterDescription = "The upper limit for the estimated value that can be returned by the symbolic classification model."; 32 40 41 #region parameter properties 42 public IFixedValueParameter<DoubleValue> LowerEstimationLimitParameter { 43 get { return (IFixedValueParameter<DoubleValue>)Parameters[LowerEstimationLimitParameterName]; } 44 } 45 public IFixedValueParameter<DoubleValue> UpperEstimationLimitParameter { 46 get { return (IFixedValueParameter<DoubleValue>)Parameters[UpperEstimationLimitParameterName]; } 47 } 48 #endregion 49 #region properties 50 public DoubleValue LowerEstimationLimit { 51 get { return LowerEstimationLimitParameter.Value; } 52 } 53 public DoubleValue UpperEstimationLimit { 54 get { return UpperEstimationLimitParameter.Value; } 55 } 56 #endregion 33 57 [StorableConstructor] 34 58 protected SymbolicClassificationSingleObjectiveProblem(bool deserializing) : base(deserializing) { } … … 38 62 public SymbolicClassificationSingleObjectiveProblem() 39 63 : base(new ClassificationProblemData(), new SymbolicClassificationSingleObjectiveMeanSquaredErrorEvaluator(), new SymbolicDataAnalysisExpressionTreeCreator()) { 40 MaximumSymbolicExpressionTreeDepth.Value = 8; 41 MaximumSymbolicExpressionTreeLength.Value = 25; 64 Parameters.Add(new FixedValueParameter<DoubleValue>(LowerEstimationLimitParameterName, LowerEstimationLimitParameterDescription, new DoubleValue())); 65 Parameters.Add(new FixedValueParameter<DoubleValue>(UpperEstimationLimitParameterName, UpperEstimationLimitParameterDescription, new DoubleValue())); 66 67 MaximumSymbolicExpressionTreeDepth.Value = InitialMaximumTreeDepth; 68 MaximumSymbolicExpressionTreeLength.Value = InitialMaximumTreeLength; 69 70 InitializeOperators(); 42 71 } 43 72 44 protected override void UpdateEstimationLimits() { 73 private void InitializeOperators() { 74 Operators.Add(new SymbolicClassificationSingleObjectiveTrainingBestSolutionAnalyzer()); 75 Operators.Add(new SymbolicClassificationSingleObjectiveValidationBestSolutionAnalyzer()); 76 ParameterizeOperators(); 77 } 78 79 private void UpdateEstimationLimits() { 45 80 if (ProblemData.TrainingPartitionStart.Value < ProblemData.TrainingPartitionEnd.Value) { 46 81 var targetValues = ProblemData.Dataset.GetVariableValues(ProblemData.TargetVariable, ProblemData.TrainingPartitionStart.Value, ProblemData.TrainingPartitionEnd.Value); … … 52 87 } 53 88 89 protected override void OnProblemDataChanged() { 90 base.OnProblemDataChanged(); 91 UpdateEstimationLimits(); 92 } 93 94 protected override void ParameterizeOperators() { 95 base.ParameterizeOperators(); 96 var operators = Parameters.OfType<IValueParameter>().Select(p => p.Value).OfType<IOperator>().Union(Operators); 97 foreach (var op in operators.OfType<ISymbolicDataAnalysisBoundedEvaluator<IClassificationProblemData>>()) { 98 op.LowerEstimationLimitParameter.ActualName = LowerEstimationLimitParameterName; 99 op.UpperEstimationLimitParameter.ActualName = UpperEstimationLimitParameterName; 100 } 101 } 102 54 103 public override void ImportProblemDataFromFile(string fileName) { 55 104 ClassificationProblemData problemData = ClassificationProblemData.ImportFromFile(fileName); -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SingleObjective/SymbolicClassificationSingleObjectiveTrainingBestSolutionAnalyzer.cs
r5681 r5685 62 62 public SymbolicClassificationSingleObjectiveTrainingBestSolutionAnalyzer() 63 63 : base() { 64 Parameters.Add(new LookupParameter<IClassificationProblemData>(ProblemDataParameterName, "The problem data for the symbolic classification solution.")); 65 Parameters.Add(new LookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>(SymbolicDataAnalysisTreeInterpreterParameterName, "The symbolic data analysis tree interpreter for the symbolic expression tree.")); 64 66 } 65 67 public override IDeepCloneable Clone(Cloner cloner) { -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.csproj
r5624 r5685 108 108 </ItemGroup> 109 109 <ItemGroup> 110 <Compile Include="MultiObjective\SymbolicRegressionMultiObjectiveValidationBestSolutionAnalyzer.cs" /> 110 111 <Compile Include="SymbolicRegressionModel.cs" /> 111 112 <Compile Include="Interfaces\ISymbolicRegressionModel.cs" /> -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectiveProblem.cs
r5623 r5685 25 25 using HeuristicLab.Data; 26 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 using HeuristicLab.Parameters; 27 28 28 29 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression { … … 32 33 public class SymbolicRegressionMultiObjectiveProblem : SymbolicDataAnalysisMultiObjectiveProblem<IRegressionProblemData, ISymbolicRegressionMultiObjectiveEvaluator, ISymbolicDataAnalysisSolutionCreator> { 33 34 private const double PunishmentFactor = 10; 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."; 34 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 35 58 [StorableConstructor] 36 59 protected SymbolicRegressionMultiObjectiveProblem(bool deserializing) : base(deserializing) { } … … 40 63 public SymbolicRegressionMultiObjectiveProblem() 41 64 : base(new RegressionProblemData(), new SymbolicRegressionMultiObjectivePearsonRSquaredTreeSizeEvaluator(), new SymbolicDataAnalysisExpressionTreeCreator()) { 42 Maximization = new BoolArray(new bool[] { true, false }); 43 MaximumSymbolicExpressionTreeDepth.Value = 8; 44 MaximumSymbolicExpressionTreeLength.Value = 25; 65 Parameters.Add(new FixedValueParameter<DoubleValue>(LowerEstimationLimitParameterName, LowerEstimationLimitParameterDescription, new DoubleValue())); 66 Parameters.Add(new FixedValueParameter<DoubleValue>(UpperEstimationLimitParameterName, UpperEstimationLimitParameterDescription, new DoubleValue())); 67 68 Maximization = new BoolArray(new bool[] { false, false }); 69 MaximumSymbolicExpressionTreeDepth.Value = InitialMaximumTreeDepth; 70 MaximumSymbolicExpressionTreeLength.Value = InitialMaximumTreeLength; 71 72 InitializeOperators(); 45 73 } 46 74 47 protected override void UpdateEstimationLimits() { 75 private void InitializeOperators() { 76 Operators.Add(new SymbolicRegressionMultiObjectiveTrainingBestSolutionAnalyzer()); 77 Operators.Add(new SymbolicRegressionMultiObjectiveValidationBestSolutionAnalyzer()); 78 ParameterizeOperators(); 79 } 80 81 private void UpdateEstimationLimits() { 48 82 if (ProblemData.TrainingPartitionStart.Value < ProblemData.TrainingPartitionEnd.Value) { 49 83 var targetValues = ProblemData.Dataset.GetVariableValues(ProblemData.TargetVariable, ProblemData.TrainingPartitionStart.Value, ProblemData.TrainingPartitionEnd.Value); … … 55 89 } 56 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 57 105 public override void ImportProblemDataFromFile(string fileName) { 58 106 RegressionProblemData problemData = RegressionProblemData.ImportFromFile(fileName); -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectiveTrainingBestSolutionAnalyzer.cs
r5557 r5685 37 37 [Item("SymbolicRegressionMultiObjectiveTrainingBestSolutionAnalyzer", "An operator that analyzes the training best symbolic regression solution for multi objective symbolic regression problems.")] 38 38 [StorableClass] 39 public sealed class SymbolicRegressionMultiObjectiveTrainingBestSolutionAnalyzer : SymbolicDataAnalysisMultiObjectiveTrainingBestSolutionAnalyzer<ISymbolicRegressionSolution> { 39 public sealed class SymbolicRegressionMultiObjectiveTrainingBestSolutionAnalyzer : SymbolicDataAnalysisMultiObjectiveTrainingBestSolutionAnalyzer<ISymbolicRegressionSolution>, 40 ISymbolicDataAnalysisInterpreterOperator { 41 private const string ProblemDataParameterName = "ProblemData"; 42 private const string SymbolicDataAnalysisTreeInterpreterParameterName = "SymbolicDataAnalysisTreeInterpreter"; 43 44 #region parameter properties 45 public ILookupParameter<IRegressionProblemData> ProblemDataParameter { 46 get { return (ILookupParameter<IRegressionProblemData>)Parameters[ProblemDataParameterName]; } 47 } 48 public ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter> SymbolicDataAnalysisTreeInterpreterParameter { 49 get { return (ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>)Parameters[SymbolicDataAnalysisTreeInterpreterParameterName]; } 50 } 51 #endregion 52 53 #region properties 54 public IRegressionProblemData ProblemData { 55 get { return ProblemDataParameter.ActualValue; } 56 } 57 public ISymbolicDataAnalysisExpressionTreeInterpreter SymbolicDataAnalysisTreeInterpreter { 58 get { return SymbolicDataAnalysisTreeInterpreterParameter.ActualValue; } 59 } 60 #endregion 61 40 62 [StorableConstructor] 41 63 private SymbolicRegressionMultiObjectiveTrainingBestSolutionAnalyzer(bool deserializing) : base(deserializing) { } … … 43 65 public SymbolicRegressionMultiObjectiveTrainingBestSolutionAnalyzer() 44 66 : base() { 67 Parameters.Add(new LookupParameter<IRegressionProblemData>(ProblemDataParameterName, "The problem data for the symbolic regression solution.")); 68 Parameters.Add(new LookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>(SymbolicDataAnalysisTreeInterpreterParameterName, "The symbolic data analysis tree interpreter for the symbolic expression tree.")); 45 69 } 70 46 71 public override IDeepCloneable Clone(Cloner cloner) { 47 72 return new SymbolicRegressionMultiObjectiveTrainingBestSolutionAnalyzer(this, cloner); 48 73 } 49 74 50 51 75 protected override ISymbolicRegressionSolution CreateSolution(ISymbolicExpressionTree bestTree, double[] bestQuality) { 52 throw new System.NotImplementedException();76 return new SymbolicRegressionSolution(new SymbolicRegressionModel(bestTree, SymbolicDataAnalysisTreeInterpreter), ProblemData); 53 77 } 54 78 } -
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); -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/SymbolicRegressionSingleObjectiveTrainingBestSolutionAnalyzer.cs
r5557 r5685 37 37 [Item("SymbolicRegressionSingleObjectiveTrainingBestSolutionAnalyzer", "An operator that analyzes the training best symbolic regression solution for single objective symbolic regression problems.")] 38 38 [StorableClass] 39 public sealed class SymbolicRegressionSingleObjectiveTrainingBestSolutionAnalyzer : SymbolicDataAnalysisSingleObjectiveTrainingBestSolutionAnalyzer<ISymbolicRegressionSolution> { 39 public sealed class SymbolicRegressionSingleObjectiveTrainingBestSolutionAnalyzer : SymbolicDataAnalysisSingleObjectiveTrainingBestSolutionAnalyzer<ISymbolicRegressionSolution>, 40 ISymbolicDataAnalysisInterpreterOperator { 41 private const string ProblemDataParameterName = "ProblemData"; 42 private const string SymbolicDataAnalysisTreeInterpreterParameterName = "SymbolicDataAnalysisTreeInterpreter"; 43 #region parameter properties 44 public ILookupParameter<IRegressionProblemData> ProblemDataParameter { 45 get { return (ILookupParameter<IRegressionProblemData>)Parameters[ProblemDataParameterName]; } 46 } 47 public ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter> SymbolicDataAnalysisTreeInterpreterParameter { 48 get { return (ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>)Parameters[SymbolicDataAnalysisTreeInterpreterParameterName]; } 49 } 50 #endregion 51 #region properties 52 public IRegressionProblemData ProblemData { 53 get { return ProblemDataParameter.ActualValue; } 54 } 55 public ISymbolicDataAnalysisExpressionTreeInterpreter SymbolicDataAnalysisTreeInterpreter { 56 get { return SymbolicDataAnalysisTreeInterpreterParameter.ActualValue; } 57 } 58 #endregion 40 59 [StorableConstructor] 41 60 private SymbolicRegressionSingleObjectiveTrainingBestSolutionAnalyzer(bool deserializing) : base(deserializing) { } … … 43 62 public SymbolicRegressionSingleObjectiveTrainingBestSolutionAnalyzer() 44 63 : base() { 64 Parameters.Add(new LookupParameter<IRegressionProblemData>(ProblemDataParameterName, "The problem data for the symbolic regression solution.")); 65 Parameters.Add(new LookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>(SymbolicDataAnalysisTreeInterpreterParameterName, "The symbolic data analysis tree interpreter for the symbolic expression tree.")); 45 66 } 46 67 public override IDeepCloneable Clone(Cloner cloner) { … … 49 70 50 71 protected override ISymbolicRegressionSolution CreateSolution(ISymbolicExpressionTree bestTree, double bestQuality) { 51 throw new System.NotImplementedException();72 return new SymbolicRegressionSolution(new SymbolicRegressionModel(bestTree, SymbolicDataAnalysisTreeInterpreter), ProblemData); 52 73 } 53 74 } -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/SymbolicRegressionSingleObjectiveValidationBestSolutionAnalyzer.cs
r5613 r5685 49 49 50 50 protected override ISymbolicRegressionSolution CreateSolution(ISymbolicExpressionTree bestTree, double bestQuality) { 51 throw new System.NotImplementedException();51 return new SymbolicRegressionSolution(new SymbolicRegressionModel(bestTree, SymbolicDataAnalysisTreeInterpreter), ProblemData); 52 52 } 53 53 } -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisValidationAnalyzer.cs
r5607 r5685 42 42 private const string ProblemDataParameterName = "ProblemData"; 43 43 private const string EvaluatorParameterName = "Evaluator"; 44 private const string SymbolicDataAnalysisTreeInterpreterParameterName = "SymbolicDataAnalysisTreeInterpreter"; 44 45 private const string ValidationSamplesStartParameterName = "ValidationSamplesStart"; 45 46 private const string ValidationSamplesEndParameterName = "ValidationSamplesEnd"; … … 52 53 get { return (ILookupParameter<T>)Parameters[EvaluatorParameterName]; } 53 54 } 55 public ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter> SymbolicDataAnalysisTreeInterpreterParameter { 56 get { return (ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>)Parameters[SymbolicDataAnalysisTreeInterpreterParameterName]; } 57 } 54 58 public IValueLookupParameter<IntValue> ValidationSamplesStartParameter { 55 59 get { return (IValueLookupParameter<IntValue>)Parameters[ValidationSamplesStartParameterName]; } … … 59 63 } 60 64 #endregion 65 61 66 #region properties 62 67 public U ProblemData { get { return ProblemDataParameter.ActualValue; } } 63 68 public T Evaluator { get { return EvaluatorParameter.ActualValue; } } 69 public ISymbolicDataAnalysisExpressionTreeInterpreter SymbolicDataAnalysisTreeInterpreter { get { return SymbolicDataAnalysisTreeInterpreterParameter.ActualValue; } } 64 70 public IntValue ValidationSamplesStart { get { return ValidationSamplesStartParameter.ActualValue; } } 65 71 public IntValue ValidationSamplesEnd { get { return ValidationSamplesEndParameter.ActualValue; } } 66 72 #endregion 73 67 74 [StorableConstructor] 68 75 protected SymbolicDataAnalysisValidationAnalyzer(bool deserializing) : base(deserializing) { } … … 74 81 Parameters.Add(new LookupParameter<U>(ProblemDataParameterName, "The problem data of the symbolic data analysis problem.")); 75 82 Parameters.Add(new LookupParameter<T>(EvaluatorParameterName, "The operator to use for fitness evaluation on the validation partition.")); 83 Parameters.Add(new LookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>(SymbolicDataAnalysisTreeInterpreterParameterName, "The interpreter for symbolic data analysis expression trees.")); 76 84 Parameters.Add(new ValueLookupParameter<IntValue>(ValidationSamplesStartParameterName, "The start index of the validation partition.")); 77 85 Parameters.Add(new ValueLookupParameter<IntValue>(ValidationSamplesEndParameterName, "The end index of the validation partition.")); -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj
r5624 r5685 108 108 </ItemGroup> 109 109 <ItemGroup> 110 <Compile Include="Analyzers\SymbolicDataAnalysisMultiObjectiveValidationBestSolutionAnalyzer.cs" /> 110 111 <Compile Include="Analyzers\SymbolicDataAnalysisSingleObjectiveValidationBestSolutionAnalyzer.cs" /> 111 112 <Compile Include="Analyzers\SymbolicDataAnalysisValidationAnalyzer.cs" /> -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisMultiObjectiveProblem.cs
r5618 r5685 58 58 [StorableConstructor] 59 59 protected SymbolicDataAnalysisMultiObjectiveProblem(bool deserializing) : base(deserializing) { } 60 protected SymbolicDataAnalysisMultiObjectiveProblem(SymbolicDataAnalysisMultiObjectiveProblem<T, U, V> original, Cloner cloner) : base(original, cloner) { } 60 protected SymbolicDataAnalysisMultiObjectiveProblem(SymbolicDataAnalysisMultiObjectiveProblem<T, U, V> original, Cloner cloner) 61 : base(original, cloner) { 62 RegisterEventHandler(); 63 } 61 64 62 65 public SymbolicDataAnalysisMultiObjectiveProblem(T problemData, U evaluator, V solutionCreator) 63 66 : base(problemData, evaluator, solutionCreator) { 64 67 Parameters.Add(new ValueParameter<BoolArray>(MaximizationParameterName, "Set to false if the problem should be minimized.")); 68 69 ParameterizeOperators(); 70 RegisterEventHandler(); 71 } 72 73 [StorableHook(HookType.AfterDeserialization)] 74 private void AfterDeserialization() { 75 RegisterEventHandler(); 76 } 77 78 private void RegisterEventHandler() { 79 Evaluator.QualitiesParameter.ActualNameChanged += new System.EventHandler(QualitiesParameter_ActualNameChanged); 65 80 } 66 81 67 82 protected override void OnEvaluatorChanged() { 68 83 base.OnEvaluatorChanged(); 84 Evaluator.QualitiesParameter.ActualNameChanged += new System.EventHandler(QualitiesParameter_ActualNameChanged); 69 85 Maximization = new BoolArray(Evaluator.Maximization.ToArray()); 86 ParameterizeOperators(); 87 } 88 89 private void QualitiesParameter_ActualNameChanged(object sender, System.EventArgs e) { 90 ParameterizeOperators(); 91 } 92 93 protected override void ParameterizeOperators() { 94 base.ParameterizeOperators(); 95 foreach (var op in Operators.OfType<ISymbolicDataAnalysisMultiObjectiveAnalyzer>()) { 96 op.QualitiesParameter.ActualName = Evaluator.QualitiesParameter.ActualName; 97 op.MaximizationParameter.ActualName = MaximizationParameterName; 98 } 70 99 } 71 100 } -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisProblem.cs
r5624 r5685 47 47 private const string SymbolicExpressionTreeGrammarParameterName = "SymbolicExpressionTreeGrammar"; 48 48 private const string SymbolicExpressionTreeInterpreterParameterName = "SymbolicExpressionTreeInterpreter"; 49 private const string LowerEstimationLimitParameterName = "LowerEstimationLimit";50 private const string UpperEstimationLimitParameterName = "UpperEstimationLimit";51 49 private const string MaximumSymbolicExpressionTreeDepthParameterName = "MaximumSymbolicExpressionTreeDepth"; 52 50 private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength"; … … 57 55 private const string SymbolicExpressionTreeGrammarParameterDescription = "The grammar that should be used for symbolic expression tree."; 58 56 private const string SymoblicExpressionTreeInterpreterParameterDescription = "The interpreter that should be used to evaluate the symbolic expression tree."; 59 private const string LowerEstimationLimitParameterDescription = "The lower limit for the estimated value that can be returned by the symbolic data analysis model.";60 private const string UpperEstimationLimitParameterDescription = "The upper limit for the estimated value that can be returned by the symbolic data analysis model.";61 57 private const string MaximumSymbolicExpressionTreeDepthParameterDescription = "Maximal depth of the symbolic expression. The minimum depth needed for the algorithm is 3 because two levels are reserved for the ProgramRoot and the Start symbol."; 62 58 private const string MaximumSymbolicExpressionTreeLengthParameterDescription = "Maximal length of the symbolic expression."; … … 78 74 get { return (IValueParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>)Parameters[SymbolicExpressionTreeInterpreterParameterName]; } 79 75 } 80 public IFixedValueParameter<DoubleValue> LowerEstimationLimitParameter {81 get { return (IFixedValueParameter<DoubleValue>)Parameters[LowerEstimationLimitParameterName]; }82 }83 public IFixedValueParameter<DoubleValue> UpperEstimationLimitParameter {84 get { return (IFixedValueParameter<DoubleValue>)Parameters[UpperEstimationLimitParameterName]; }85 }86 76 public IFixedValueParameter<IntValue> MaximumSymbolicExpressionTreeDepthParameter { 87 77 get { return (IFixedValueParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeDepthParameterName]; } … … 117 107 get { return SymbolicExpressionTreeInterpreterParameter.Value; } 118 108 set { SymbolicExpressionTreeInterpreterParameter.Value = value; } 119 }120 121 public DoubleValue LowerEstimationLimit {122 get { return LowerEstimationLimitParameter.Value; }123 }124 public DoubleValue UpperEstimationLimit {125 get { return UpperEstimationLimitParameter.Value; }126 109 } 127 110 … … 156 139 Parameters.Add(new ValueParameter<ISymbolicDataAnalysisGrammar>(SymbolicExpressionTreeGrammarParameterName, SymbolicExpressionTreeGrammarParameterDescription)); 157 140 Parameters.Add(new ValueParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>(SymbolicExpressionTreeInterpreterParameterName, SymoblicExpressionTreeInterpreterParameterDescription)); 158 Parameters.Add(new FixedValueParameter<DoubleValue>(LowerEstimationLimitParameterName, LowerEstimationLimitParameterDescription, new DoubleValue()));159 Parameters.Add(new FixedValueParameter<DoubleValue>(UpperEstimationLimitParameterName, UpperEstimationLimitParameterDescription, new DoubleValue()));160 141 Parameters.Add(new FixedValueParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName, MaximumSymbolicExpressionTreeDepthParameterDescription, new IntValue())); 161 142 Parameters.Add(new FixedValueParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, MaximumSymbolicExpressionTreeLengthParameterDescription, new IntValue())); … … 167 148 168 149 UpdateGrammar(); 169 Update EstimationLimits();150 UpdateDatasetPartitions(); 170 151 RegisterEventHandlers(); 171 152 InitializeOperators(); 172 153 } 173 154 174 protected abstract void UpdateEstimationLimits(); 155 protected virtual void UpdateDatasetPartitions() { 156 Evaluator.SamplesStartParameter.Value.Value = ProblemData.TrainingPartitionStart.Value; 157 Evaluator.SamplesEndParameter.Value.Value = ProblemData.TrainingPartitionEnd.Value; 158 159 foreach (var analyzer in Operators.OfType<ISymbolicDataAnalysisValidationAnalyzer<U, T>>()) { 160 analyzer.ValidationSamplesStartParameter.Value = new IntValue(ProblemData.TrainingPartitionStart.Value); 161 analyzer.ValidationSamplesEndParameter.Value = new IntValue(ProblemData.TrainingPartitionEnd.Value); 162 } 163 } 164 165 protected virtual void UpdateGrammar() { 166 foreach (var varSymbol in SymbolicExpressionTreeGrammar.Symbols.OfType<HeuristicLab.Problems.DataAnalysis.Symbolic.Variable>()) { 167 varSymbol.VariableNames = ProblemData.AllowedInputVariables; 168 } 169 foreach (var varSymbol in SymbolicExpressionTreeGrammar.Symbols.OfType<HeuristicLab.Problems.DataAnalysis.Symbolic.VariableCondition>()) { 170 varSymbol.VariableNames = ProblemData.AllowedInputVariables; 171 } 172 } 175 173 176 174 private void InitializeOperators() { 177 175 Operators.AddRange(ApplicationManager.Manager.GetInstances<ISymbolicExpressionTreeOperator>()); 178 176 Operators.Add(new SymbolicExpressionSymbolFrequencyAnalyzer()); 177 Operators.Add(new SymbolicDataAnalysisVariableFrequencyAnalyzer()); 179 178 Operators.Add(new MinAverageMaxSymbolicExpressionTreeLengthAnalyzer()); 180 179 ParameterizeOperators(); 181 180 } 182 181 183 private void ProblemDataParameter_ValueChanged(object sender, EventArgs e) { 184 ProblemDataParameter.Value.Changed += (object s, EventArgs args) => OnProblemDataChanged(); 185 186 OnProblemDataChanged(); 187 } 182 #region events 188 183 private void RegisterEventHandlers() { 189 184 ProblemDataParameter.ValueChanged += new EventHandler(ProblemDataParameter_ValueChanged); … … 195 190 } 196 191 192 private void ProblemDataParameter_ValueChanged(object sender, EventArgs e) { 193 ProblemDataParameter.Value.Changed += (object s, EventArgs args) => OnProblemDataChanged(); 194 OnProblemDataChanged(); 195 } 196 197 197 private void ArchitectureParameterValue_ValueChanged(object sender, EventArgs e) { 198 198 UpdateGrammar(); 199 }200 protected virtual void UpdateGrammar() {201 foreach (var varSymbol in SymbolicExpressionTreeGrammar.Symbols.OfType<HeuristicLab.Problems.DataAnalysis.Symbolic.Variable>()) {202 varSymbol.VariableNames = ProblemData.AllowedInputVariables;203 }204 foreach (var varSymbol in SymbolicExpressionTreeGrammar.Symbols.OfType<HeuristicLab.Problems.DataAnalysis.Symbolic.VariableCondition>()) {205 varSymbol.VariableNames = ProblemData.AllowedInputVariables;206 }207 199 } 208 200 … … 217 209 ParameterizeOperators(); 218 210 } 211 219 212 private void SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged(object sender, EventArgs e) { 220 213 ParameterizeOperators(); … … 223 216 protected override void OnEvaluatorChanged() { 224 217 base.OnEvaluatorChanged(); 218 ParameterizeOperators(); 225 219 } 226 220 … … 228 222 protected virtual void OnProblemDataChanged() { 229 223 UpdateGrammar(); 230 UpdateEstimationLimits(); 224 UpdateDatasetPartitions(); 225 ParameterizeOperators(); 226 231 227 var handler = ProblemDataChanged; 232 228 if (handler != null) handler(this, EventArgs.Empty); … … 234 230 OnReset(); 235 231 } 236 237 private void ParameterizeOperators() { 232 #endregion 233 234 protected virtual void ParameterizeOperators() { 238 235 var operators = Parameters.OfType<IValueParameter>().Select(p => p.Value).OfType<IOperator>().Union(Operators); 239 236 240 237 foreach (var op in operators.OfType<ISymbolicExpressionTreeGrammarBasedOperator>()) { 241 op.SymbolicExpressionTreeGrammarParameter.ActualName = SymbolicExpressionTreeGrammarParameter .Name;238 op.SymbolicExpressionTreeGrammarParameter.ActualName = SymbolicExpressionTreeGrammarParameterName; 242 239 } 243 240 foreach (var op in operators.OfType<ISymbolicExpressionTreeSizeConstraintOperator>()) { 244 op.MaximumSymbolicExpressionTreeDepthParameter.ActualName = MaximumSymbolicExpressionTreeDepthParameter .Name;245 op.MaximumSymbolicExpressionTreeLengthParameter.ActualName = MaximumSymbolicExpressionTreeLengthParameter .Name;241 op.MaximumSymbolicExpressionTreeDepthParameter.ActualName = MaximumSymbolicExpressionTreeDepthParameterName; 242 op.MaximumSymbolicExpressionTreeLengthParameter.ActualName = MaximumSymbolicExpressionTreeLengthParameterName; 246 243 } 247 244 foreach (var op in operators.OfType<ISymbolicExpressionTreeArchitectureAlteringOperator>()) { 248 op.MaximumFunctionArgumentsParameter.ActualName = MaximumFunctionArgumentsParameter .Name;249 op.MaximumFunctionDefinitionsParameter.ActualName = MaximumFunctionDefinitionsParameter .Name;245 op.MaximumFunctionArgumentsParameter.ActualName = MaximumFunctionArgumentsParameterName; 246 op.MaximumFunctionDefinitionsParameter.ActualName = MaximumFunctionDefinitionsParameterName; 250 247 } 251 248 foreach (var op in operators.OfType<ISymbolicDataAnalysisEvaluator<T>>()) { 252 op.ProblemDataParameter.ActualName = ProblemDataParameter .Name;249 op.ProblemDataParameter.ActualName = ProblemDataParameterName; 253 250 op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName; 254 251 op.SamplesStartParameter.Value.Value = ProblemData.TrainingPartitionStart.Value; 255 252 op.SamplesEndParameter.Value.Value = ProblemData.TrainingPartitionEnd.Value; 256 }257 foreach (var op in operators.OfType<ISymbolicDataAnalysisBoundedEvaluator<T>>()) {258 op.LowerEstimationLimitParameter.ActualName = LowerEstimationLimitParameter.Name;259 op.UpperEstimationLimitParameter.ActualName = UpperEstimationLimitParameter.Name;260 253 } 261 254 foreach (var op in operators.OfType<ISymbolicExpressionTreeCrossover>()) { … … 269 262 op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName; 270 263 } 264 foreach (var op in operators.OfType<ISymbolicDataAnalysisInterpreterOperator>()) { 265 op.SymbolicDataAnalysisTreeInterpreterParameter.ActualName = SymbolicExpressionTreeInterpreterParameterName; 266 } 267 foreach (var op in operators.OfType<ISymbolicDataAnalysisAnalyzer>()) { 268 op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName; 269 } 271 270 } 272 271 -
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisSingleObjectiveProblem.cs
r5618 r5685 20 20 #endregion 21 21 22 using System.Linq; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; … … 26 27 using HeuristicLab.Parameters; 27 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 using System; 28 30 29 31 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 65 67 [StorableConstructor] 66 68 protected SymbolicDataAnalysisSingleObjectiveProblem(bool deserializing) : base(deserializing) { } 67 protected SymbolicDataAnalysisSingleObjectiveProblem(SymbolicDataAnalysisSingleObjectiveProblem<T, U, V> original, Cloner cloner) : base(original, cloner) { } 69 protected SymbolicDataAnalysisSingleObjectiveProblem(SymbolicDataAnalysisSingleObjectiveProblem<T, U, V> original, Cloner cloner) 70 : base(original, cloner) { 71 RegisterEventHandler(); 72 } 68 73 69 74 public SymbolicDataAnalysisSingleObjectiveProblem(T problemData, U evaluator, V solutionCreator) … … 71 76 Parameters.Add(new FixedValueParameter<BoolValue>(MaximizationParameterName, "Set to false if the problem should be minimized.", new BoolValue())); 72 77 Parameters.Add(new FixedValueParameter<DoubleValue>(BestKnownQualityParameterName, "The quality of the best known solution of this problem.", new DoubleValue())); 78 79 RegisterEventHandler(); 80 } 81 82 [StorableHook(HookType.AfterDeserialization)] 83 private void AfterDeserialization() { 84 RegisterEventHandler(); 85 } 86 87 private void RegisterEventHandler() { 88 Evaluator.QualityParameter.ActualNameChanged += new EventHandler(QualityParameter_ActualNameChanged); 73 89 } 74 90 75 91 protected override void OnEvaluatorChanged() { 76 92 base.OnEvaluatorChanged(); 93 Evaluator.QualityParameter.ActualNameChanged += new EventHandler(QualityParameter_ActualNameChanged); 77 94 Maximization.Value = base.Evaluator.Maximization; 95 ParameterizeOperators(); 96 } 97 98 private void QualityParameter_ActualNameChanged(object sender, EventArgs e) { 99 ParameterizeOperators(); 100 } 101 102 protected override void ParameterizeOperators() { 103 base.ParameterizeOperators(); 104 105 foreach (var op in Operators.OfType<ISymbolicDataAnalysisSingleObjectiveAnalyzer>()) { 106 op.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName; 107 op.MaximizationParameter.ActualName = MaximizationParameterName; 108 } 78 109 } 79 110 }
Note: See TracChangeset
for help on using the changeset viewer.