|
- % Define environment (functions, gradients etc...)
- GivenEnv
-
- % Settings
- max_iter = 1000; % Maximum iterations
-
- % Define parameters
- % =========================================================================
- x0 = [8, -10]';
- gamma = 0.2;
- sk_step = 0.1;
- tol = 0.01; % Tolerance
-
-
-
- point_str = "[" + x0(1) + ", " + x0(2) + "]";
- f = fun(x0);
- gf = grad_fun(x0);
- hf = hessian_fun(x0);
- fprintf('Initial point (%d, %d), f = %f, grad = [%f;%f], hessian = [%f %f ; %f %f]=> Method applicable\n', x0, f, gf, hf);
-
-
- gamma_fixed_step = gamma;
- [x_fixed, f_fixed, kk] = method_SteepDesc_Proj(fun, grad_fun, x0, sk_step, XSetLimmits, tol, max_iter, 'fixed');
- fprintf('Fixed step g=%f: Initial point (%f, %f), steps:%d, Final (x1,x2)=(%f, %f), f(x1,x2)=%f\n', gamma_fixed_step, x0, kk, x_fixed(:, end), f_fixed(end));
- plotPointsOverContour(x_fixed, fun, XSetLimmits(1, :), XSetLimmits(2, :), 100, point_str + ": Steepest descent proj $s_k$ = " + sk_step + ", $\gamma$ = " + gamma_fixed_step, "figures/StDesProj_sk_" + sk_step + "_gamma_" + gamma + ".png");
|