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

GivenEnv.asv 1014 B

123456789101112131415161718192021222324252627282930313233
  1. % Given environment
  2. clear;
  3. % Setup the function under test
  4. syms x [2 1] real;
  5. fexpr = (1/3)*x(1)^2 +3*x(2)^2;
  6. title_fun = "$f(x) = frac{1}{3}{x_1}^2 + 3{x_2}^2$";
  7. % Calculate the gradient and Hessian
  8. grad_fexpr = gradient(fexpr, x); % Gradient of f
  9. hessian_fexpr = hessian(fexpr, x); % Hessian of f
  10. % Convert symbolic expressions to MATLAB functions
  11. fun = matlabFunction(fexpr, 'Vars', {x}); % Function
  12. grad_fun = matlabFunction(grad_fexpr, 'Vars', {x}); % Gradient
  13. hessian_fun = matlabFunction(hessian_fexpr, 'Vars', {x}); % Hessian
  14. % Minimum reference
  15. %Freference = @(x) x(1).^5 .* exp(-x(1).^2 - x(2).^2);
  16. %[Xmin, Fmin] = fminsearch(Freference, [-1, -1]);
  17. % Amijo globals
  18. global amijo_beta; % Step reduction factor in [0.1, 0.5] (typical range: [0.1, 0.8])
  19. global amijo_sigma; % Sufficient decrease constant in [1e-5, 0.1] (typical range: [0.01, 0.3])
  20. %fixed step size globals
  21. global gamma_fixed_step
  22. global image_width,
  23. global image_height;
  24. image_width = 960;
  25. image_height = 640;