THMMY's "Optimization Techniques" course assignments.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

47 lines
927 B

  1. %
  2. % Keeping epsilon fixed, test the iteration needed for different lambda
  3. % values.
  4. %
  5. % Clear workspace and load the functions and region
  6. clear
  7. funGivenEnv;
  8. % * epsilon: e = 0.001
  9. % * lambda: l > 2e = 0.001
  10. % * dl: A small step away from 2e
  11. % dl = 0.0001
  12. % * lambda_max: 0.1
  13. % * size: 25 points
  14. size = 25;
  15. epsilon = 0.001;
  16. dl = 0.0001;
  17. lambda_max= 0.1;
  18. lambda = linspace(2*epsilon + dl, lambda_max, size);
  19. k = zeros(1,size);
  20. %
  21. % * Call the bisection method for each lambda value for each function and
  22. % keep the number of iterations needed.
  23. % * Plot the iterations k(lambda) for each function
  24. %
  25. i = 0;
  26. for f = funs
  27. i = i + 1;
  28. j = 0;
  29. for l = lambda
  30. j = j + 1;
  31. [a, b, k(j)] = bisection(f, a_0, b_0, epsilon, l);
  32. end
  33. subplot(1, 3, i)
  34. plot(lambda, k, '-b', 'LineWidth', 1.0)
  35. title(titles(i), 'Interpreter', 'latex')
  36. xlabel('lambda')
  37. ylabel('Iterations')
  38. end