- Timestamp:
- 01/14/22 15:58:30 (3 years ago)
- Location:
- branches/3136_Structural_GP
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/StructuredSymbolicRegressionSingleObjectiveProblem.cs
r18198 r18199 30 30 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 31 31 using HeuristicLab.Optimization; 32 using HeuristicLab.Optimization.Operators;33 32 using HeuristicLab.Parameters; 34 33 using HeuristicLab.Problems.Instances; -
branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/StructureTemplate/StructureTemplate.cs
r18195 r18199 41 41 if (value == template) return; 42 42 43 var parsedTree = Parser.Parse(value); 44 //assignment must be done after successfully parsing the tree 43 45 template = value; 44 var parsedTree = Parser.Parse(template); 46 45 47 if (applyLinearScaling) 46 48 parsedTree = LinearScaling.AddLinearScalingTerms(parsedTree); … … 62 64 private set { 63 65 containsNumericParameters = null; 64 tree = value;65 66 66 var newFunctions = CreateSubFunctions( tree);67 var newFunctions = CreateSubFunctions(value); 67 68 var oldFunctions = subFunctions?.Intersect(newFunctions) 68 69 ?? Enumerable.Empty<SubFunction>(); … … 71 72 subFunctions = functionsToAdd.Concat(oldFunctions).ToList(); 72 73 RegisterSubFunctionEventHandlers(functionsToAdd); 74 75 tree = value; 73 76 } 74 77 } … … 104 107 105 108 protected InfixExpressionParser Parser { get; set; } = new InfixExpressionParser(); 106 107 109 #endregion 108 110 … … 150 152 subFunctions = new List<SubFunction>(); 151 153 tree = null; 154 containsNumericParameters = null; 152 155 Template = "f(_)"; 153 156 } … … 183 186 sf.Changed += (o, e) => OnChanged(); 184 187 } 185 } 188 } 186 189 } 187 190 } -
branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/StructureTemplate/SubFunction.cs
r18194 r18199 105 105 varSym.VariableNames = allowedInputVariables; 106 106 } else { 107 var vars = new List<string>(); 108 var exceptions = new List<Exception>(); 109 foreach (var arg in Arguments) { 110 if (allowedInputVariables.Contains(arg)) 111 vars.Add(arg); 112 else 113 exceptions.Add(new ArgumentException($"The argument '{arg}' for sub-function '{Name}' is not a valid variable.")); 114 } 115 if (exceptions.Any()) 116 throw new AggregateException(exceptions); 117 varSym.VariableNames = vars; 107 varSym.VariableNames = Arguments.ToList(); 118 108 } 119 109
Note: See TracChangeset
for help on using the changeset viewer.