Changeset 16398


Ignore:
Timestamp:
12/18/18 19:22:41 (7 months ago)
Author:
gkronber
Message:

#2925: small changes

Location:
branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/Problem.cs

    r16329 r16398  
    3939
    4040namespace HeuristicLab.Problems.DynamicalSystemsModelling {
    41 
    42 
    43 
    44 
    4541  // Eine weitere Möglichkeit ist spline-smoothing der Daten (über Zeit) um damit für jede Zielvariable
    4642  // einen bereinigten (Rauschen) Wert und die Ableitung dy/dt für alle Beobachtungen zu bekommen
     
    196192      // TODO: use training range as default training episode
    197193      // TODO: write back optimized parameters to solution?
     194      // TODO: optimization of starting values for latent variables in CVODES solver
    198195
    199196    }
     
    258255        }
    259256      }
    260       // init params randomly from Unif(-1e-5, 1e-5)
     257      // init params randomly
    261258      // theta contains parameter values for trees and then the initial values for latent variables (a separate vector for each episode)
    262259      // inital values for latent variables are also optimized
    263260      var theta = new double[paramNodes.Count + latentVariables.Length * episodes.Count()];
    264261      for (int i = 0; i < theta.Length; i++)
    265         theta[i] = random.NextDouble() * 2.0e-2 - 1.0e-2;
     262        theta[i] = random.NextDouble() * 2.0 - 1.0;
    266263
    267264      optTheta = new double[0];
     
    388385        results.Add(new Result("Models", typeof(VariableCollection)));
    389386      }
     387      if(!results.ContainsKey("SNMSE")) {
     388        results.Add(new Result("SNMSE", typeof(DoubleValue)));
     389      }
    390390
    391391      var bestIndividualAndQuality = this.GetBestIndividual(individuals, qualities);
    392392      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);
    393395
    394396      var problemData = ProblemData;
     
    646648    }
    647649
     650    #region CVODES
     651
    648652
    649653    /// <summary>
     
    769773      string[] calculatedVariables,
    770774      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
    774776      return (double t,
    775777              IntPtr y, // N_Vector, current value of y (input)
     
    942944        };
    943945    }
     946    #endregion
    944947
    945948    private static void IntegrateHL(
     
    994997          variableValues[kvp.Key] = newVal;
    995998        }
    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
    10001004            var varName = node.Symbol.Name;
    10011005            nodeValues[node] = variableValues[varName];
  • branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/Vector.cs

    r16395 r16398  
    1515      return new Vector(res);
    1616    }
     17
    1718    public static Vector operator -(Vector a, Vector b) {
    1819      if (b == Zero) return a;
Note: See TracChangeset for help on using the changeset viewer.