THMMY's "Optimization Techniques" course assignments.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 

36 行
659 B

  1. function [a, b, k] = min_bisection_der(fun_expression, alpha, beta, epsilon, lambda)
  2. %
  3. % Detailed explanation goes here
  4. %
  5. %
  6. % Error checking
  7. if lambda <= 0
  8. error ('Convergence criteria not met')
  9. end
  10. % Init output vectors
  11. a = alpha;
  12. b = beta;
  13. dfun = matlabFunction(diff(fun_expression));
  14. k=1;
  15. while b(k) - a(k) > lambda
  16. % bisect [a,b]
  17. x_mid = (a(k) + b(k)) / 2;
  18. % set new search interval
  19. k = k + 1;
  20. df = dfun(x_mid);
  21. if df < 0
  22. a(k) = x_mid;
  23. b(k) = b(k-1);
  24. elseif df > 0
  25. a(k) = a(k-1);
  26. b(k) = x_mid;
  27. else % df == 0
  28. a(k) = x_mid;
  29. b(k) = x_mid;
  30. break;
  31. end
  32. end