Octopus
minimizer_tests_oct_m Module Reference

This modules takes care of testing optimizers using standard test functions. More...

Detailed Description

This modules takes care of testing optimizers using standard test functions.

Functions/Subroutines

subroutine, public test_optimizers (namespace)
 Unit tests for different optimizers. More...
 
subroutine rosenbrock_gradient_2d (n, x, val, getgrad, grad)
 Gradient of the Rosenbrock function. More...
 
subroutine sphere_gradient_2d (n, x, val, getgrad, grad)
 Gradient of the sphere function. More...
 
subroutine rastrigin_gradient_2d (n, x, val, getgrad, grad)
 Gradient of the Rastrigin function. More...
 
subroutine write_iter_info (iter, n, val, maxdr, maxgrad, x)
 Helper function required by the minimizer. More...
 
subroutine set_log_file (name)
 Set the log‐file name before running each test. More...
 

Variables

character(len=:), allocatable current_log
 Name of the current log file for write_iter_info. More...
 

Function/Subroutine Documentation

◆ test_optimizers()

subroutine, public minimizer_tests_oct_m::test_optimizers ( type(namespace_t), intent(in)  namespace)

Unit tests for different optimizers.

At the moment

Definition at line 148 of file minimizer_tests.F90.

◆ rosenbrock_gradient_2d()

subroutine minimizer_tests_oct_m::rosenbrock_gradient_2d ( integer, intent(in)  n,
real(real64), dimension(n), intent(in)  x,
real(real64), intent(inout)  val,
integer, intent(in)  getgrad,
real(real64), dimension(n), intent(inout)  grad 
)
private

Gradient of the Rosenbrock function.

The function is given by \( f(x, y) = (a - x)^2 + b(y - x^2)^2 \). It has a global minimum at \((x,y)=(a,a^2)\).

See https:

Definition at line 231 of file minimizer_tests.F90.

◆ sphere_gradient_2d()

subroutine minimizer_tests_oct_m::sphere_gradient_2d ( integer, intent(in)  n,
real(real64), dimension(n), intent(in)  x,
real(real64), intent(inout)  val,
integer, intent(in)  getgrad,
real(real64), dimension(n), intent(inout)  grad 
)
private

Gradient of the sphere function.

Definition at line 255 of file minimizer_tests.F90.

◆ rastrigin_gradient_2d()

subroutine minimizer_tests_oct_m::rastrigin_gradient_2d ( integer, intent(in)  n,
real(real64), dimension(n), intent(in)  x,
real(real64), intent(inout)  val,
integer, intent(in)  getgrad,
real(real64), dimension(n), intent(inout)  grad 
)
private

Gradient of the Rastrigin function.

The function is given by \( f(\mathbf{x}) = A + \sum_{i=1}^{n}\Bigl(x_i^2 - A\cos(2\pi x_i)\Bigr)\).

The gradient is \( \nabla f(\mathbf{x}) = 2\mathbf{x} + 2\pi A \sin\bigl(2\pi\mathbf{x}\bigr) \).

Definition at line 280 of file minimizer_tests.F90.

◆ write_iter_info()

subroutine minimizer_tests_oct_m::write_iter_info ( integer, intent(in)  iter,
integer, intent(in)  n,
real(real64), intent(in)  val,
real(real64), intent(in)  maxdr,
real(real64), intent(in)  maxgrad,
real(real64), dimension(n), intent(in)  x 
)
private

Helper function required by the minimizer.

Outputs the details of the optimization steps into a file called optimization.log

Definition at line 305 of file minimizer_tests.F90.

◆ set_log_file()

subroutine minimizer_tests_oct_m::set_log_file ( character(len=*), intent(in)  name)
private

Set the log‐file name before running each test.

Definition at line 328 of file minimizer_tests.F90.

Variable Documentation

◆ current_log

character(len=:), allocatable minimizer_tests_oct_m::current_log
private

Name of the current log file for write_iter_info.

Definition at line 140 of file minimizer_tests.F90.