Free cookie consent management tool by TermsFeed Policy Generator

Changeset 16275


Ignore:
Timestamp:
11/05/18 13:19:38 (6 years ago)
Author:
gkronber
Message:

#2925: changed random initialization of parameters and fixed two non-critical bugs in the implementation

File:
1 edited

Legend:

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

    r16268 r16275  
    259259      }
    260260      // init params randomly from Unif(-1e-5, 1e-5)
    261       var theta = paramNodes.Select(_ => random.NextDouble() * 2.0e-5 - 1.0e-5).ToArray();
     261      var theta = paramNodes.Select(_ => random.NextDouble() * 2.0e-2 - 1.0e-2).ToArray();
    262262
    263263      optTheta = new double[0];
     
    267267        alglib.minlbfgscreate(Math.Min(theta.Length, 5), theta, out state);
    268268        alglib.minlbfgssetcond(state, 0.0, 0.0, 0.0, MaximumParameterOptimizationIterations);
    269         alglib.minlbfgssetgradientcheck(state, 1e-6);
     269        //alglib.minlbfgssetgradientcheck(state, 1e-6);
    270270        alglib.minlbfgsoptimize(state, EvaluateObjectiveAndGradient, null,
    271271          new object[] { trees, targetVars, problemData, targetValues, episodes.ToArray(), NumericIntegrationSteps, latentVariables, OdeSolver }); //TODO: create a type
     
    491491        var models = new VariableCollection();    // to store target var names and original version of tree
    492492
     493        int nextParIdx = 0;
    493494        foreach (var tup in targetVars.Zip(trees, Tuple.Create)) {
    494495          var targetVarName = tup.Item1;
     
    496497
    497498          // when we reference HeuristicLab.Problems.DataAnalysis.Symbolic we can translate symbols
    498           int nextParIdx = 0;
    499499          var shownTree = new SymbolicExpressionTree(TranslateTreeNode(tree.Root, optTheta, ref nextParIdx));
    500500
     
    579579          prevT = t;
    580580
    581           if (variableValues.Count == targetVariables.Length) {
    582             // only return the target variables for calculation of errors
    583             var res = targetVariables
    584               .Select(targetVar => variableValues[targetVar])
    585               .ToArray();
    586             if (res.Any(ri => double.IsNaN(ri.Item1) || double.IsInfinity(ri.Item1))) yield break;
    587             yield return res;
    588           } else {
    589             yield break; // stop early on problems
    590           }
     581          // This check doesn't work with the HeuristicLab integrator if there are input variables
     582          //if (variableValues.Count == targetVariables.Length) {
     583          // only return the target variables for calculation of errors
     584          var res = targetVariables
     585            .Select(targetVar => variableValues[targetVar])
     586            .ToArray();
     587          if (res.Any(ri => double.IsNaN(ri.Item1) || double.IsInfinity(ri.Item1))) yield break;
     588          yield return res;
     589          //} else {
     590          //  yield break; // stop early on problems
     591          //}
    591592
    592593
Note: See TracChangeset for help on using the changeset viewer.