Changeset 16398 for branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/Problem.cs
- Timestamp:
- 12/18/18 19:22:41 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/Problem.cs
r16329 r16398 39 39 40 40 namespace HeuristicLab.Problems.DynamicalSystemsModelling { 41 42 43 44 45 41 // Eine weitere Möglichkeit ist spline-smoothing der Daten (über Zeit) um damit für jede Zielvariable 46 42 // einen bereinigten (Rauschen) Wert und die Ableitung dy/dt für alle Beobachtungen zu bekommen … … 196 192 // TODO: use training range as default training episode 197 193 // TODO: write back optimized parameters to solution? 194 // TODO: optimization of starting values for latent variables in CVODES solver 198 195 199 196 } … … 258 255 } 259 256 } 260 // init params randomly from Unif(-1e-5, 1e-5)257 // init params randomly 261 258 // theta contains parameter values for trees and then the initial values for latent variables (a separate vector for each episode) 262 259 // inital values for latent variables are also optimized 263 260 var theta = new double[paramNodes.Count + latentVariables.Length * episodes.Count()]; 264 261 for (int i = 0; i < theta.Length; i++) 265 theta[i] = random.NextDouble() * 2.0 e-2 - 1.0e-2;262 theta[i] = random.NextDouble() * 2.0 - 1.0; 266 263 267 264 optTheta = new double[0]; … … 388 385 results.Add(new Result("Models", typeof(VariableCollection))); 389 386 } 387 if(!results.ContainsKey("SNMSE")) { 388 results.Add(new Result("SNMSE", typeof(DoubleValue))); 389 } 390 390 391 391 var bestIndividualAndQuality = this.GetBestIndividual(individuals, qualities); 392 392 var trees = bestIndividualAndQuality.Item1.Values.Select(v => v.Value).OfType<ISymbolicExpressionTree>().ToArray(); // extract all trees from individual 393 394 results["SNMSE"].Value = new DoubleValue(bestIndividualAndQuality.Item2); 393 395 394 396 var problemData = ProblemData; … … 646 648 } 647 649 650 #region CVODES 651 648 652 649 653 /// <summary> … … 769 773 string[] calculatedVariables, 770 774 double[] parameterValues) { 771 // we don't need to calculate a gradient here -> no nodes are selected for 772 // --> no nodes are selected to be included in the gradient calculation 773 var nodeIdx = new Dictionary<ISymbolicExpressionTreeNode, int>(); 775 // we don't need to calculate a gradient here 774 776 return (double t, 775 777 IntPtr y, // N_Vector, current value of y (input) … … 942 944 }; 943 945 } 946 #endregion 944 947 945 948 private static void IntegrateHL( … … 994 997 variableValues[kvp.Key] = newVal; 995 998 } 996 // update nodeValues from variableValues 997 // TODO: perf using dictionary with list of nodes for each variable 998 foreach (var tree in trees) { 999 foreach (var node in tree.Root.IterateNodesPrefix().Where(n => IsVariableNode(n))) { 999 1000 1001 foreach(var node in nodeValues.Keys.ToArray()) { 1002 if(node.SubtreeCount == 0 && !IsConstantNode(node)) { 1003 // update values for (latent) variables 1000 1004 var varName = node.Symbol.Name; 1001 1005 nodeValues[node] = variableValues[varName];
Note: See TracChangeset
for help on using the changeset viewer.