Free cookie consent management tool by TermsFeed Policy Generator

Changeset 17240


Ignore:
Timestamp:
09/10/19 11:58:49 (5 years ago)
Author:
gkronber
Message:

#2994: some minor improvements

Location:
branches/2994-AutoDiffForIntervals
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/2994-AutoDiffForIntervals/HeuristicLab.Problems.DataAnalysis.Regression.Symbolic.Extensions

    • Property svn:ignore
      •  

        old new  
        11Plugin.cs
         2nlopt-2.6.1
  • branches/2994-AutoDiffForIntervals/HeuristicLab.Problems.DataAnalysis.Regression.Symbolic.Extensions/ConstrainedNLSInternal.cs

    r17213 r17240  
    9898      var pred = interpreter.GetSymbolicExpressionTreeValues(expr, problemData.Dataset, trainingRows).ToArray();
    9999
     100      bestError = targetVariance;
     101
    100102      if (pred.Any(pi => double.IsInfinity(pi) || double.IsNaN(pi))) {
    101         bestError = targetVariance;
    102103        invalidProblem = true;
    103104      }
     
    106107      var predStDev = pred.StandardDeviationPop();
    107108      if (predStDev == 0) {
    108         bestError = targetVariance;
    109109        invalidProblem = true;
    110110      }
     
    170170
    171171
    172       var minVal = Math.Min(-100.0, thetaValues.Min());
    173       var maxVal = Math.Max(100.0, thetaValues.Max());
     172      var minVal = Math.Min(-1000.0, thetaValues.Min());
     173      var maxVal = Math.Max(1000.0, thetaValues.Max());
    174174      var lb = Enumerable.Repeat(minVal, thetaValues.Count).ToArray();
    175175      var up = Enumerable.Repeat(maxVal, thetaValues.Count).ToArray();
     
    213213      double minf = double.MaxValue; /* minimum objective value upon return */
    214214      var res = NLOpt.nlopt_optimize(nlopt, x, ref minf);
    215       bestSolution = x;
    216       bestError = minf;
    217215
    218216      if (res < 0 && res != NLOpt.nlopt_result.NLOPT_FORCED_STOP) {
    219         throw new InvalidOperationException($"NLOpt failed {res} {NLOpt.nlopt_get_errmsg(nlopt)}");
    220       } else {
     217        // throw new InvalidOperationException($"NLOpt failed {res} {NLOpt.nlopt_get_errmsg(nlopt)}");
     218        return;
     219      } else if(minf <= bestError) {
     220        bestSolution = x;
     221        bestError = minf;
     222
    221223        // calculate constraints of final solution
    222224        double[] _ = new double[x.Length];
     
    296298      }
    297299
    298       UpdateBestSolution(sse / target.Length, curX);
     300      // UpdateBestSolution(sse / target.Length, curX);
    299301      RaiseFunctionEvaluated();
    300302
    301       if (double.IsNaN(sse)) return double.MaxValue;
     303      if (double.IsNaN(sse)) {
     304        if(grad!=null) Array.Clear(grad, 0, grad.Length);
     305        return double.MaxValue;
     306      }
    302307      return sse / target.Length;
    303308    }
     
    364369      var constraintData = Marshal.PtrToStructure<ConstraintData>(data);
    365370
    366       if (grad != null) for (int j = 0; j < grad.Length; j++) grad[j] = 0; // clear grad
     371      if (grad != null) Array.Clear(grad, 0, grad.Length);
    367372
    368373      var interval = intervalEvaluator.Evaluate(constraintData.Tree, dataIntervals, constraintData.ParameterNodes,
     
    399404
    400405      UpdateConstraintViolations(constraintData.Idx, interval.UpperBound);
    401       if (double.IsNaN(interval.UpperBound)) return double.MaxValue;
    402       else return interval.UpperBound;
     406      if (double.IsNaN(interval.UpperBound)) {
     407        Array.Clear(grad, 0, grad.Length);
     408        return double.MaxValue;
     409      } else return interval.UpperBound;
    403410    }
    404411
  • branches/2994-AutoDiffForIntervals/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/Interpreter.cs

    r17216 r17240  
    781781  }
    782782
     783  // this is our own implementation of interval arithmetic
     784  // for a well worked out definition of interval operations for IEEE reals see:
     785  // Stahl: Interval Methods for Bounding the Range of Polynomials and Solving Systems of Nonlinear Equations, Dissertation, JKU, 1995
    783786  [DebuggerDisplay("[{low.Value}..{high.Value}]")]
    784787  public class AlgebraicInterval : IAlgebraicType<AlgebraicInterval> {
Note: See TracChangeset for help on using the changeset viewer.