THMMY's "Optimization Techniques" course assignments.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

41 rinda
901 B

  1. %
  2. % Keeping l (accuracy) fixed, test the iteration needed for different
  3. % epsilon values.
  4. %
  5. % Clear workspace and load the functions and region
  6. clear
  7. addpath('..');
  8. GivenEnv;
  9. % * lambda = 0.01
  10. % * epsilon: e < lambda/2 = 0.005
  11. % * de: A small step away from zero and lambda/2
  12. % de = 0.0001
  13. % * N: 50 points
  14. N = 50;
  15. lambda = 0.01;
  16. de = 0.0001;
  17. epsilon = linspace(de, (lambda/2)-de, N);
  18. k = zeros(1,N); % preallocate k
  19. %
  20. % * Call the bisection method for each epsilon value for each function and
  21. % keep the number of iterations needed.
  22. % * Plot the iterations k(epsilon) for each function
  23. %
  24. for i = 1:size(funs,2)
  25. for j = 1:N
  26. [a, b, k(j)] = bisection(funs{i}, a_0, b_0, epsilon(j), lambda);
  27. end
  28. subplot(1, length(funs), i)
  29. plot(epsilon, k, '-b', 'LineWidth', 1.0)
  30. title(titles(i), 'Interpreter', 'latex')
  31. xlabel('epsilon')
  32. ylabel('Iterations')
  33. end