27 use,
intrinsic :: iso_fortran_env
50 type(namespace_t),
intent(in) :: namespace
52 real(real64),
dimension(2) :: x0, x, mass
53 real(real64),
parameter :: tol_grad = 1.0e-6_real64
54 real(real64) :: dt, energy
56 integer,
parameter :: max_iter = 1000
60 call io_rm(
"optimization.log", namespace)
64 x0 = [3.0_real64, 4.0_real64]
71 call minimize_fire(2, 2, x, dt, tol_grad, max_iter,
rosenbrock_gradient_2d,
write_iter_info, energy, ierr, mass, 1)
73 write(
message(1),
"(a,i6,a)")
"FIRE algorithm converged in ", -ierr,
" iterations"
74 write(
message(2),
"(a,2(f8.4,a))")
" The minimum is found to be at (", x(1),
", ", x(2),
")"
75 write(
message(3),
"(a)")
" Analytical minimum is (1,1)."
89 integer,
intent(in) :: n
90 real(real64),
intent(in) :: x(n)
91 real(real64),
intent(inout) :: val
92 integer,
intent(in) :: getgrad
93 real(real64),
intent(inout) :: grad(n)
95 real(real64),
parameter :: a =
m_one
96 real(real64),
parameter :: b = 100.0_real64
103 grad(1) = -
m_two * (a-x(1)) -
m_four * b * (x(2) -x(1)**2) * x(1)
104 grad(2) =
m_two * b * (x(2) -x(1)**2)
113 subroutine write_iter_info(iter, n, val, maxdr, maxgrad, x) !< output
for each iteration step
114 integer,
intent(in) :: iter
115 integer,
intent(in) :: n
116 real(real64),
intent(in) :: val
117 real(real64),
intent(in) :: maxdr
118 real(real64),
intent(in) :: maxgrad
119 real(real64),
intent(in) :: x(n)
126 write(iunit,
'(a10, 3a20)')
'# iter',
'x',
'y',
'max_force'
128 write(iunit,
'(i10,3f20.10)') iter, x(1), x(2), maxgrad
subroutine minimize_fire(dim, space_dim, x, step, tolgrad, maxiter, f, write_iter_info, en, ierr, mass, integrator)
Implementation of the Fast Inertial Relaxation Engine (FIRE)
real(real64), parameter, public m_two
real(real64), parameter, public m_four
real(real64), parameter, public m_one
subroutine, public io_close(iunit, grp)
subroutine, public io_rm(fname, namespace)
integer function, public io_open(file, namespace, action, status, form, position, die, recl, grp)
subroutine, public messages_info(no_lines, iunit, verbose_limit, stress, all_nodes, namespace)
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
This modules takes care of testing optimizers using standard test functions.
subroutine write_iter_info(iter, n, val, maxdr, maxgrad, x)
Helper function required by the minimizer.
subroutine rosenbrock_gradient_2d(n, x, val, getgrad, grad)
Gradient of the Rosenbrock function.
subroutine, public test_optimizers(namespace)
Unit tests for different optimizers.
logical function mpi_grp_is_root(grp)
Is the current MPI process of grpcomm, root.
type(mpi_grp_t), public mpi_world
type(namespace_t), public global_namespace
brief This module defines the class unit_t which is used by the unit_systems_oct_m module.
This module defines the unit system, used for input and output.