Changeset 17240 for branches/2994-AutoDiffForIntervals
- Timestamp:
- 09/10/19 11:58:49 (5 years ago)
- 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 1 1 Plugin.cs 2 nlopt-2.6.1
-
- Property svn:ignore
-
branches/2994-AutoDiffForIntervals/HeuristicLab.Problems.DataAnalysis.Regression.Symbolic.Extensions/ConstrainedNLSInternal.cs
r17213 r17240 98 98 var pred = interpreter.GetSymbolicExpressionTreeValues(expr, problemData.Dataset, trainingRows).ToArray(); 99 99 100 bestError = targetVariance; 101 100 102 if (pred.Any(pi => double.IsInfinity(pi) || double.IsNaN(pi))) { 101 bestError = targetVariance;102 103 invalidProblem = true; 103 104 } … … 106 107 var predStDev = pred.StandardDeviationPop(); 107 108 if (predStDev == 0) { 108 bestError = targetVariance;109 109 invalidProblem = true; 110 110 } … … 170 170 171 171 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()); 174 174 var lb = Enumerable.Repeat(minVal, thetaValues.Count).ToArray(); 175 175 var up = Enumerable.Repeat(maxVal, thetaValues.Count).ToArray(); … … 213 213 double minf = double.MaxValue; /* minimum objective value upon return */ 214 214 var res = NLOpt.nlopt_optimize(nlopt, x, ref minf); 215 bestSolution = x;216 bestError = minf;217 215 218 216 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 221 223 // calculate constraints of final solution 222 224 double[] _ = new double[x.Length]; … … 296 298 } 297 299 298 UpdateBestSolution(sse / target.Length, curX);300 // UpdateBestSolution(sse / target.Length, curX); 299 301 RaiseFunctionEvaluated(); 300 302 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 } 302 307 return sse / target.Length; 303 308 } … … 364 369 var constraintData = Marshal.PtrToStructure<ConstraintData>(data); 365 370 366 if (grad != null) for (int j = 0; j < grad.Length; j++) grad[j] = 0; // clear grad371 if (grad != null) Array.Clear(grad, 0, grad.Length); 367 372 368 373 var interval = intervalEvaluator.Evaluate(constraintData.Tree, dataIntervals, constraintData.ParameterNodes, … … 399 404 400 405 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; 403 410 } 404 411 -
branches/2994-AutoDiffForIntervals/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/Interpreter.cs
r17216 r17240 781 781 } 782 782 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 783 786 [DebuggerDisplay("[{low.Value}..{high.Value}]")] 784 787 public class AlgebraicInterval : IAlgebraicType<AlgebraicInterval> {
Note: See TracChangeset
for help on using the changeset viewer.