Changeset 18152
- Timestamp:
- 12/17/21 15:02:57 (3 years ago)
- Location:
- branches/3136_Structural_GP
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/StructuredSymbolicRegressionSingleObjectiveProblem.cs
r18151 r18152 80 80 var shapeConstraintProblemData = new ShapeConstrainedRegressionProblemData(problemData); 81 81 82 var targetInterval = shapeConstraintProblemData.VariableRanges.GetInterval(shapeConstraintProblemData.TargetVariable);83 var estimationWidth = targetInterval.Width * 10;84 85 82 var structureTemplate = new StructureTemplate(); 86 83 … … 109 106 Parameters.Add(new FixedValueParameter<DoubleLimit>( 110 107 EstimationLimitsParameterName, 111 new DoubleLimit( targetInterval.LowerBound - estimationWidth, targetInterval.UpperBound + estimationWidth)) { Hidden = true });108 new DoubleLimit(double.NegativeInfinity, double.PositiveInfinity)) { Hidden = true }); 112 109 113 110 Parameters.Add(new ResultParameter<ISymbolicRegressionSolution>(BestTrainingSolutionParameterName, "") { Hidden = true }); … … 173 170 foreach (var f in StructureTemplate.SubFunctions) { 174 171 SetupVariables(f); 175 if (!Encoding.Encodings.Any(x => x.Name == f.Name)) // to prevent the same encoding twice 176 Encoding.Add(new SymbolicExpressionTreeEncoding( 177 f.Name, 178 f.Grammar, 179 f.MaximumSymbolicExpressionTreeLength, 180 f.MaximumSymbolicExpressionTreeDepth)); 181 } 172 // to prevent the same encoding twice 173 if (!Encoding.Encodings.Any(x => x.Name == f.Name)) 174 Encoding.Add(CreateEncoding(f)); 175 } 176 177 ParameterizeEncoding(); 182 178 } 183 179 … … 261 257 } 262 258 259 private SymbolicExpressionTreeEncoding CreateEncoding(SubFunction subFunction) { 260 var encoding = new SymbolicExpressionTreeEncoding( 261 subFunction.Name, 262 subFunction.Grammar, 263 subFunction.MaximumSymbolicExpressionTreeLength, 264 subFunction.MaximumSymbolicExpressionTreeDepth); 265 return encoding; 266 } 267 268 private void ParameterizeEncoding() { 269 var manipulator = (IParameterizedItem)Encoding.Operators.OfType<MultiEncodingManipulator>().FirstOrDefault(); 270 if (manipulator != null) { 271 foreach (var param in manipulator.Parameters.OfType<ConstrainedValueParameter<IManipulator>>()) { 272 var m = param.ValidValues.OfType<MultiSymbolicExpressionTreeManipulator>().FirstOrDefault(); 273 param.Value = m == null ? param.ValidValues.First() : m; 274 } 275 } 276 } 263 277 private void SetupVariables(SubFunction subFunction) { 264 278 var varSym = (Variable)subFunction.Grammar.GetSymbol(VariableName); … … 296 310 public void Load(IRegressionProblemData data) { 297 311 ProblemData = data; 298 StructureTemplate.Template = "f(_)";299 312 } 300 313 } -
branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/StructureTemplate/StructureTemplate.cs
r18151 r18152 93 93 treeWithoutLinearScaling = null; 94 94 treeWithLinearScaling = null; 95 template = "";96 95 applyLinearScaling = false; 96 Template = "f(_)"; 97 97 OnChanged(); 98 98 }
Note: See TracChangeset
for help on using the changeset viewer.