Changeset 18081 for branches/3136_Structural_GP
- Timestamp:
- 11/12/21 17:10:22 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/StructuredSymbolicRegressionSingleObjectiveProblem.cs
r18076 r18081 21 21 22 22 #region Constants 23 private const string TreeEvaluatorParameterName = "TreeEvaluator"; 23 24 private const string ProblemDataParameterName = "ProblemData"; 24 25 private const string StructureTemplateParameterName = "Structure Template"; … … 37 38 38 39 #region Parameters 40 public IConstrainedValueParameter<SymbolicRegressionSingleObjectiveEvaluator> TreeEvaluatorParameter => (IConstrainedValueParameter<SymbolicRegressionSingleObjectiveEvaluator>)Parameters[TreeEvaluatorParameterName]; 39 41 public IValueParameter<IRegressionProblemData> ProblemDataParameter => (IValueParameter<IRegressionProblemData>)Parameters[ProblemDataParameterName]; 40 42 public IFixedValueParameter<StructureTemplate> StructureTemplateParameter => (IFixedValueParameter<StructureTemplate>)Parameters[StructureTemplateParameterName]; … … 45 47 46 48 #region Properties 49 47 50 public IRegressionProblemData ProblemData { 48 51 get => ProblemDataParameter.Value; … … 62 65 public DoubleLimit EstimationLimits => EstimationLimitsParameter.Value; 63 66 64 public override bool Maximization => true;67 public override bool Maximization => false; 65 68 #endregion 66 69 … … 79 82 structureTemplate.Changed += OnTemplateChanged; 80 83 84 var evaluators = new ItemSet<SymbolicRegressionSingleObjectiveEvaluator>( 85 ApplicationManager.Manager.GetInstances<SymbolicRegressionSingleObjectiveEvaluator>() 86 .Where(x => x.Maximization == Maximization)); 87 88 Parameters.Add(new ConstrainedValueParameter<SymbolicRegressionSingleObjectiveEvaluator>( 89 TreeEvaluatorParameterName, 90 evaluators, 91 evaluators.First())); 92 81 93 Parameters.Add(new ValueParameter<IRegressionProblemData>( 82 94 ProblemDataParameterName, 83 95 problemData)); 96 ProblemDataParameter.ValueChanged += ProblemDataParameterValueChanged; 97 84 98 Parameters.Add(new FixedValueParameter<StructureTemplate>( 85 99 StructureTemplateParameterName, 86 100 StructureTemplateDescriptionText, 87 101 structureTemplate)); 102 88 103 Parameters.Add(new ValueParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>( 89 104 InterpreterParameterName, 90 105 new SymbolicDataAnalysisExpressionTreeInterpreter()) { Hidden = true }); 106 91 107 Parameters.Add(new FixedValueParameter<DoubleLimit>( 92 108 EstimationLimitsParameterName, 93 109 new DoubleLimit(targetInterval.LowerBound - estimationWidth, targetInterval.UpperBound + estimationWidth))); 110 EstimationLimitsParameter.Hidden = true; 111 94 112 Parameters.Add(new ResultParameter<ISymbolicRegressionSolution>(BestTrainingSolutionParameterName, "")); 95 96 ProblemDataParameter.ValueChanged += ProblemDataParameterValueChanged; 113 this.BestTrainingSolutionParameter.Hidden = true; 114 115 this.EvaluatorParameter.Hidden = true; 116 117 97 118 98 119 Operators.Add(new SymbolicDataAnalysisVariableFrequencyAnalyzer()); … … 167 188 individual[SymbolicExpressionTreeName] = tree; 168 189 169 var quality = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate( 190 //TreeEvaluatorParameter.Value.EstimationLimitsParameter.ActualValue = EstimationLimits; 191 //TreeEvaluatorParameter.Value.EstimationLimitsParameter.Value = EstimationLimits; 192 //var quality = TreeEvaluatorParameter.Value.Evaluate(new ExecutionContext(null, this, new Scope("Test")), tree, ProblemData, ProblemData.TrainingIndices); 193 194 var quality = double.MaxValue; 195 var evaluatorGUID = TreeEvaluatorParameter.Value.GetType().GUID; 196 197 // TODO: use Evaluate method instead of static Calculate -> a fake ExecutionContext is needed 198 if (evaluatorGUID == typeof(NMSESingleObjectiveConstraintsEvaluator).GUID) { 199 quality = NMSESingleObjectiveConstraintsEvaluator.Calculate( 200 Interpreter, tree, 201 EstimationLimits.Lower, EstimationLimits.Upper, 202 ProblemData, ProblemData.TrainingIndices, new IntervalArithBoundsEstimator()); 203 } else if (evaluatorGUID == typeof(SymbolicRegressionLogResidualEvaluator).GUID) { 204 quality = SymbolicRegressionLogResidualEvaluator.Calculate( 205 Interpreter, tree, 206 EstimationLimits.Lower, EstimationLimits.Upper, 207 ProblemData, ProblemData.TrainingIndices); 208 } else if (evaluatorGUID == typeof(SymbolicRegressionMeanRelativeErrorEvaluator).GUID) { 209 quality = SymbolicRegressionMeanRelativeErrorEvaluator.Calculate( 210 Interpreter, tree, 211 EstimationLimits.Lower, EstimationLimits.Upper, 212 ProblemData, ProblemData.TrainingIndices); 213 } else if (evaluatorGUID == typeof(SymbolicRegressionSingleObjectiveMaxAbsoluteErrorEvaluator).GUID) { 214 quality = SymbolicRegressionSingleObjectiveMaxAbsoluteErrorEvaluator.Calculate( 170 215 Interpreter, tree, 171 216 EstimationLimits.Lower, EstimationLimits.Upper, 172 217 ProblemData, ProblemData.TrainingIndices, false); 173 218 } else if (evaluatorGUID == typeof(SymbolicRegressionSingleObjectiveMeanAbsoluteErrorEvaluator).GUID) { 219 quality = SymbolicRegressionSingleObjectiveMeanAbsoluteErrorEvaluator.Calculate( 220 Interpreter, tree, 221 EstimationLimits.Lower, EstimationLimits.Upper, 222 ProblemData, ProblemData.TrainingIndices, false); 223 } else { // SymbolicRegressionSingleObjectiveMeanSquaredErrorEvaluator 224 quality = SymbolicRegressionSingleObjectiveMeanSquaredErrorEvaluator.Calculate( 225 Interpreter, tree, 226 EstimationLimits.Lower, EstimationLimits.Upper, 227 ProblemData, ProblemData.TrainingIndices, false); 228 } 229 174 230 return quality; 175 231 }
Note: See TracChangeset
for help on using the changeset viewer.