Changeset 16500 for branches/2974_Constants_Optimization/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Constants Optimization
- Timestamp:
- 01/04/19 17:37:13 (6 years ago)
- Location:
- branches/2974_Constants_Optimization
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2974_Constants_Optimization
- Property svn:ignore
-
old new 1 1 packages 2 TestResults
-
- Property svn:ignore
-
branches/2974_Constants_Optimization/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Constants Optimization/Util.cs
r16461 r16500 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 26 27 using static HeuristicLab.Problems.DataAnalysis.Symbolic.TreeToAutoDiffTermConverter; … … 48 49 } 49 50 50 public static Dictionary<DataForVariable, AutoDiff.Variable> ExtractParameters(IDataset dataset) {51 var parameters = new Dictionary<DataForVariable, AutoDiff.Variable>();51 public static List<DataForVariable> GenerateVariables(IDataset dataset) { 52 var variables = new List<DataForVariable>(); 52 53 foreach (var doubleVariable in dataset.DoubleVariables) { 53 54 var data = new DataForVariable(doubleVariable, string.Empty, 0); 54 var param = new AutoDiff.Variable(); 55 parameters.Add(data, param); 55 variables.Add(data); 56 56 } 57 57 … … 59 59 foreach (var stringValue in dataset.GetStringValues(stringVariable).Distinct()) { 60 60 var data = new DataForVariable(stringVariable, stringValue, 0); 61 var param = new AutoDiff.Variable(); 62 parameters.Add(data, param); 61 variables.Add(data); 63 62 } 64 63 } 65 return parameters; 64 return variables; 65 } 66 67 public static List<DataForVariable> ExtractLaggedVariables(ISymbolicExpressionTree tree) { 68 var variables = new HashSet<DataForVariable>(); 69 foreach (var laggedNode in tree.IterateNodesPrefix().OfType<ILaggedTreeNode>()) { 70 var laggedVariableTreeNode = laggedNode as LaggedVariableTreeNode; 71 if (laggedVariableTreeNode != null) { 72 var data = new DataForVariable(laggedVariableTreeNode.VariableName, string.Empty, laggedVariableTreeNode.Lag); 73 if (!variables.Contains(data)) variables.Add(data); 74 } 75 } 76 return variables.ToList(); 66 77 } 67 78 … … 79 90 for (int j = 0; j < factorVarTreeNode.Weights.Length; j++) 80 91 constants.Add(factorVarTreeNode.Weights[j]); 81 } 92 } else throw new NotSupportedException(string.Format("Terminal nodes of type {0} are not supported.", node.GetType().GetPrettyName())); 82 93 } 83 94 return constants.ToArray(); … … 97 108 for (int j = 0; j < factorVarTreeNode.Weights.Length; j++) 98 109 factorVarTreeNode.Weights[j] = constants[i++]; 99 } 110 } else throw new NotSupportedException(string.Format("Terminal nodes of type {0} are not supported.", node.GetType().GetPrettyName())); 100 111 } 101 112 }
Note: See TracChangeset
for help on using the changeset viewer.