multidimensional optimizations single dimensional and
play

Multidimensional Optimizations Single Dimensional and Biostatistics - PowerPoint PPT Presentation

. . March 21th, 2011 Biostatistics 615/815 - Lecture 18 Hyun Min Kang March 21th, 2011 Hyun Min Kang Multidimensional Optimizations Single Dimensional and Biostatistics 615/815 Lecture 18: . . . . . . Summary . Introduction . .


  1. . . March 21th, 2011 Biostatistics 615/815 - Lecture 18 Hyun Min Kang March 21th, 2011 Hyun Min Kang Multidimensional Optimizations Single Dimensional and Biostatistics 615/815 Lecture 18: . . . . . . Summary . Introduction . . . . . . . . . . . Parabola Brent Mixture Simplex 1 / 39 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

  2. . . . . . . . . Thursday March 24th . . . . . . . . Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 . . . Homework and Grading . . . . . . . . . . . Introduction Parabola Brent Mixture Simplex Summary Annoucements . 2 / 39 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . • Homework #5 annouced • Homework grading is still pending • Mary Kate Trost will introduce us a very useful C++ library

  3. . Brent March 21th, 2011 Biostatistics 615/815 - Lecture 18 Hyun Min Kang . Recap : Root Finding with C++ Summary Simplex Mixture 3 / 39 Introduction Parabola . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . double binaryZero(myFunc foo, double lo, double hi, double e) { for (int i=0;; ++i) { double d = hi - lo; // f(lo) < 0, f(hi) > 0, d can be positive or negative double point = lo + d * 0.5; // d is + for increasing func, - for decreasing func. double fpoint = foo(point); // evaluate the value of the function if (fpoint < 0.0) { d = lo - point; lo = point; // } else { d = point - hi; hi = point; } // e is tolerance level (higher e makes it faster but less accruate) if (fabs(d) < e || fpoint == 0.0) { std::cout << "Iteration " << i << ", point = " << point << ", d = " << d << std::endl; return point; } } }

  4. . . . . . . . . Root Finding Strategy . . . . . . . . Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 . . . Approximation using linear interpolation . . . . . . . . . . . Introduction Parabola Brent Mixture Simplex Summary Recap : Improvements to Root Finding . 4 / 39 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . f ∗ ( x ) = f ( a ) + ( x − a ) f ( b ) − f ( a ) b − a • Select a new trial point such that f ∗ ( x ) = 0

  5. . Simplex March 21th, 2011 Biostatistics 615/815 - Lecture 18 Hyun Min Kang 2 Then search for minimum by . . 1 Find 3 points such that . . Recap : Detailed Minimization Strategy Summary . 5 / 39 Introduction . Brent Parabola . . Mixture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . • a < b < c • f ( b ) < f ( a ) and f ( b ) < f ( c ) • Selecting trial point in the interval • Keep minimum and flanking points

  6. . . March 21th, 2011 Biostatistics 615/815 - Lecture 18 Hyun Min Kang Recap : The Golden Search Summary Simplex Mixture Brent Parabola Introduction . . . . . . . . . . . 6 / 39 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

  7. . Brent March 21th, 2011 Biostatistics 615/815 - Lecture 18 Hyun Min Kang . Recap : Golden Search Summary Simplex Mixture 7 / 39 Introduction Parabola . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . double goldenSearch(myFunc foo, double a, double b, double c, double e) { int i = 0; double fb = foo(b); while ( fabs(c-a) > fabs(b*e) ) { double x = b + goldenStep(a, b, c); double fx = foo(x); if ( fx < fb ) { (x > b) ? ( a = b ) : ( c = b); b = x; fb = fx; } else { (x < b) ? ( a = x ) : ( c = x ); } ++i; } std::cout << "i = " << i << ", b = " << b << ", f(b) = " << foo(b) << std::endl; return b; }

  8. . . . . . . . . Multi-dimensional optimization . . . . . . . . Hyun Min Kang Biostatistics 615/815 - Lecture 18 March 21th, 2011 . . . A better single-dimensional optimization . . . . . . . . . . . Introduction Parabola Brent Mixture Simplex Summary Today . 8 / 39 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . • Parabolic interpolation • Adaptive method • Simplex algorithm

  9. . Mixture March 21th, 2011 Biostatistics 615/815 - Lecture 18 Hyun Min Kang optimization results most well-defined functions Better optimization using local approximation Summary . Simplex Brent . . . . . . . . . . . 9 / 39 Introduction Parabola . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . • Root finding example • Binary search reduces the search space by constant factor 1/2 • Linear approximation may reduce the search space more rapidly for • Minimization problem • Golden search reduces the search space by 38% • Using a quadratic approximation of the function may achieve better

  10. . . March 21th, 2011 Biostatistics 615/815 - Lecture 18 Hyun Min Kang Approximation using parabola Summary Simplex Mixture Brent Parabola Introduction . . . . . . . . . . . 10 / 39 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

  11. . Mixture March 21th, 2011 Biostatistics 615/815 - Lecture 18 Hyun Min Kang This strategy is called ”inverse parabolic interpolation” Parabolic Approximation Summary Simplex . 11 / 39 Brent . Parabola . Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . f ∗ ( x ) = Ax + Bx + C The value minimizes f ∗ ( x ) is x min = − B 2 A

  12. . Mixture March 21th, 2011 Biostatistics 615/815 - Lecture 18 Hyun Min Kang A B C . Fitting a parabola Summary Simplex 12 / 39 . Brent Parabola Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . • Can be fitted with three points • Points must not be co-linear • f ∗ ( x 1 ) = f ( x 1 ) , f ∗ ( x 2 ) = f ( x 2 ) , f ∗ ( x 3 ) = f ( x 3 ) . f ( x 1 ) − Ax 2 = 1 − Bx 1 A ( x 2 2 − x 2 1 ) + f ( x 1 ) − f ( x 2 ) = x 1 − x 2 f ( x 3 ) − f ( x 2 ) f ( x 1 ) − f ( x 2 ) = ( x 3 − x 2 )( x 3 − x 1 ) − ( x 1 − x 2 )( x 3 − x 1 )

  13. . Mixture March 21th, 2011 Biostatistics 615/815 - Lecture 18 Hyun Min Kang three points Minimum for a Parabola Summary Simplex . 13 / 39 Brent . . . . . . . . . . . Introduction Parabola . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . • General expression for finding minimum of a parabola fitted through ( x 2 − x 1 ) 2 ( f ( x 2 ) − f ( x 1 )) − ( x 2 − x 3 ) 2 ( f ( x 2 ) − f ( x 1 )) x min = x 2 − 1 2 ( x 2 − x 1 )( f ( x 2 ) − f ( x 1 )) − ( x 2 − x 3 )( f ( x 2 ) − f ( x 1 ))

  14. . Brent March 21th, 2011 Biostatistics 615/815 - Lecture 18 Hyun Min Kang . Summary Simplex Mixture Fitting a Parabola 14 / 39 Parabola . . Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . // Returns the distance between b and the abscissa for the // fitted minimum using parabolic interpolation double parabola_step (double a, double fa, double b, double fb, double c, double fc) { // Quantities for placing minimum of fitted parabola double p = (b - a) * (fb - fc); double q = (b - c) * (fb - fa); double x = (b - c) * q - (b - a) * p; double y = 2.0 * (p - q); // Check that q is not zero if (fabs(y) < ZEPS) return golden_step (a, b, c); else return x / y; }

  15. . Brent March 21th, 2011 Biostatistics 615/815 - Lecture 18 Hyun Min Kang points Avoiding degenerate case Summary Simplex . Mixture Introduction Parabola . . . . . . . . . . . 15 / 39 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . • Fitted minimum could overlap with one of original points • Ensure that each new point is distinct from previously examined

  16. . Brent March 21th, 2011 Biostatistics 615/815 - Lecture 18 Hyun Min Kang Avoiding degenerate steps Summary . Simplex Mixture 16 / 39 Parabola Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . double adjust_step(double a, double b, double c, double step, double e) { double min_step = fabs(e * b) + ZEPS; if (fabs(step) < min_step) return step > 0 ? min_step : 0-min_step; // If the step ends up to close to previous points, // return zero to force a golden ratio step ... if (fabs(b + step - a) <= e || fabs(b + step - c) <= e) return 0.0; return step; }

  17. . Brent March 21th, 2011 Biostatistics 615/815 - Lecture 18 Hyun Min Kang section Generating New Points Summary Simplex . Mixture Introduction Parabola . . . . . . . . . . . 17 / 39 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . • Use parabolic interpolation by default • Check whether improvement is slow • If step sizes are not decreasing rapidly enough, switch to golden

  18. . Brent March 21th, 2011 Biostatistics 615/815 - Lecture 18 Hyun Min Kang Adaptive calculation of step size Summary . Mixture Simplex 18 / 39 Parabola . . Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . double calculate_step(double a, double fa, double b, double fb, double c, double fc, double last_step, double e) { double step = parabola_step(a, fa, b, fb, c, fc); step = adjust_step(a, b, c, step, e); if (fabs(step) > fabs(0.5 * last_step) || step == 0.0) step = golden_step(a, b, c); return step; }

Recommend


More recommend