- Timestamp:
- 10/14/21 17:59:53 (3 years ago)
- Location:
- branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Importer/InfixExpressionParser.cs
r18065 r18067 81 81 internal static readonly BidirectionalLookup<string, ISymbol> 82 82 knownSymbols = new BidirectionalLookup<string, ISymbol>(StringComparer.InvariantCulture, new SymbolComparer()); 83 internal static readonly SubFunctionSymbol subFunctionSymbol = new SubFunctionSymbol(); 83 84 84 85 private Constant constant = new Constant(); … … 137 138 { "XOR", new Xor()}, 138 139 { "DIFF", new Derivative()}, 139 { "LAG", new LaggedVariable() } ,140 { "F", new SubFunctionSymbol() } 140 { "LAG", new LaggedVariable() }/*, 141 { "F", new SubFunctionSymbol() }*/ 141 142 }; 142 143 … … 341 342 342 343 private ISymbol GetSymbol(string tok) { 343 var symb = knownSymbols.GetByFirst(tok).FirstOrDefault(); 344 if (symb == null) throw new ArgumentException(string.Format("Unknown token {0} found.", tok)); 345 return symb; 344 if(knownSymbols.ContainsFirst(tok)) 345 return knownSymbols.GetByFirst(tok).FirstOrDefault(); 346 else 347 return subFunctionSymbol; 346 348 } 347 349 … … 453 455 laggedVarNode.Lag = (int)Math.Round(sign * lagToken.doubleVal); 454 456 laggedVarNode.Weight = 1.0; 455 } else if (funcNode.Symbol is SubFunctionSymbol) { 457 } else if (funcNode.Symbol is SubFunctionSymbol) { // SubFunction 456 458 var subFunction = funcNode as SubFunctionTreeNode; 459 subFunction.Name = next.strVal; 457 460 // input arguments 458 461 var args = ParseArgList(tokens); 459 IList<string> functionArguments = new List<string>();462 IList<string> arguments = new List<string>(); 460 463 foreach (var arg in args) 461 464 if(arg is VariableTreeNode varTreeNode) 462 functionArguments.Add(varTreeNode.VariableName);463 subFunction. FunctionArguments = functionArguments;465 arguments.Add(varTreeNode.VariableName); 466 subFunction.Arguments = arguments; 464 467 } else { 465 468 // functions -
branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/StructureTemplate/StructureTemplate.cs
r18066 r18067 62 62 if (node is SubFunctionTreeNode subFunctionTreeNode) { 63 63 var subFunction = new SubFunction() { 64 Name = $"f{count++}({string.Join(",", subFunctionTreeNode. FunctionArguments)})",65 FunctionArguments = subFunctionTreeNode. FunctionArguments64 Name = $"f{count++}({string.Join(",", subFunctionTreeNode.Arguments)})", 65 FunctionArguments = subFunctionTreeNode.Arguments 66 66 }; 67 67 subFunctionTreeNode.SubFunction = subFunction; -
branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/StructureTemplate/SubFunction.cs
r18065 r18067 44 44 } 45 45 46 public IEnumerable<string> FunctionArguments { 46 public IEnumerable<string> FunctionArguments { // TODO: gehört weg 47 47 get => FunctionArgumentsParameter.Value.Select(x => x.Value); 48 48 set { -
branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/SubFunctionTreeNode.cs
r18066 r18067 10 10 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 11 11 [StorableType("05130B5F-0125-4367-A4E9-C42D1085024E")] 12 public class SubFunctionTreeNode : SymbolicExpressionTreeNode { 12 public class SubFunctionTreeNode : SymbolicExpressionTreeNode { //TODO: as TerminalNode? -> but has children in a fully builded tree 13 13 14 14 #region Properties 15 15 public new SubFunctionSymbol Symbol => (SubFunctionSymbol)base.Symbol; 16 16 17 public IEnumerable<string> FunctionArguments { get; set; } = Enumerable.Empty<string>();17 public IEnumerable<string> Arguments { get; set; } = Enumerable.Empty<string>(); 18 18 19 19 public SubFunction SubFunction { get; set; } 20 21 public string Name { get; set; } 20 22 #endregion 21 23 … … 34 36 public override IDeepCloneable Clone(Cloner cloner) => new SubFunctionTreeNode(this, cloner); 35 37 #endregion 38 39 public override string ToString() { 40 if (string.IsNullOrEmpty(Name)) 41 return base.ToString(); 42 return Name; 43 } 44 36 45 } 37 46 }
Note: See TracChangeset
for help on using the changeset viewer.