Steepest Descent Optimization Algorithm

template<int N>
struct SteepestDescentOptions

Configuration for steepest descent algorithm.

Controls convergence criteria and step size parameters. Uses backtracking line search with Armijo condition.

Template Parameters:

N – Number of optimization variables

Public Members

Kokkos::View<type_real[N], Kokkos::LayoutRight, Kokkos::HostSpace> x0

Initial guess.

int max_iterations = -1

Maximum iterations (-1 = 1000*N)

type_real tol_grad = 1.0e-6

Tolerance on gradient norm.

type_real tol_f = 1.0e-8

Tolerance on function value change.

type_real tol_x = 1.0e-8

Tolerance on step size.

type_real initial_step = 1.0

Initial step size for line search.

type_real armijo_c = 1.0e-4

Armijo condition constant (0 < c < 1)

type_real backtrack_rho = 0.5

Backtracking factor (0 < rho < 1)

int max_line_search = 50

Maximum line search iterations.

type_real grad_epsilon = std::sqrt(std::numeric_limits<type_real>::epsilon())

Finite difference step size

template<int N, typename Func>
OptimizationResult<N> specfem::optimization::optimize(SteepestDescent, Func &&objective, SteepestDescentOptions<N> options)

Steepest descent minimization with numerical gradient.

Convenience overload that computes the gradient numerically using central finite differences. For better performance and accuracy, prefer the overload that accepts an analytical gradient function.

// Minimize (x-1)^2 + (y-2)^2 with numerical gradient
auto f = [](auto x) { return (x(0)-1)*(x(0)-1) + (x(1)-2)*(x(1)-2); };
Kokkos::View<type_real[2], Kokkos::LayoutRight, Kokkos::HostSpace> x0("x0");
x0(0) = 0.0; x0(1) = 0.0;
SteepestDescentOptions<2> opts{x0};
auto result = optimize(SteepestDescent{}, f, opts);
// result.x(0) ≈ 1.0, result.x(1) ≈ 2.0

Template Parameters:
  • N – Problem dimension

  • Func – Callable with signature: type_real(View<type_real[N]>)

Parameters:
  • tag – Algorithm selector (SteepestDescent{})

  • objective – Function to minimize

  • options – Configuration with initial guess and tolerances

Returns:

OptimizationResult with solution, value, iterations, and convergence flag

template<int N, typename Func, typename GradFunc>
OptimizationResult<N> specfem::optimization::optimize(SteepestDescent, Func &&objective, GradFunc &&gradient, SteepestDescentOptions<N> options)

Steepest descent minimization with user-provided gradient.

First-order optimization method that iteratively moves in the direction of the negative gradient. Uses backtracking line search with Armijo condition to determine step size.

Convergence occurs when any of:

  • Gradient norm < tol_grad

  • Function value change < tol_f

  • Step size < tol_x

// Minimize (x-1)^2 + (y-2)^2 with analytical gradient
auto f = [](auto x) { return (x(0)-1)*(x(0)-1) + (x(1)-2)*(x(1)-2); };
auto grad_f = [](auto x, auto g) { g(0) = 2*(x(0)-1); g(1) = 2*(x(1)-2); };
Kokkos::View<type_real[2], Kokkos::LayoutRight, Kokkos::HostSpace> x0("x0");
x0(0) = 0.0; x0(1) = 0.0;
SteepestDescentOptions<2> opts{x0};
auto result = optimize(SteepestDescent{}, f, grad_f, opts);
// result.x(0) ≈ 1.0, result.x(1) ≈ 2.0
Template Parameters:
  • N – Problem dimension

  • Func – Callable with signature: type_real(View<type_real[N]>)

  • GradFunc – Callable with signature: void(View<type_real[N]> x, View<type_real[N]> grad_out)

Parameters:
  • tag – Algorithm selector (SteepestDescent{})

  • objective – Function to minimize

  • gradient – Function computing gradient: gradient(x, grad_out)

  • options – Configuration with initial guess and tolerances

Returns:

OptimizationResult with solution, value, iterations, and convergence flag