optmod Module

Module implementing the optimization methods and main procedures for reading the "main.txt" file, launching the optimization, and reporting results.

When adding more optimization methods, variables nb_methods and method_names must updated.

When adding more report parameters, variables nb_rprt_params and rport_params) must be updated.


Uses


Variables

Type Visibility Attributes Name Initial
integer, public, parameter :: nb_methods = 2

Number of methods implemented

character(len=20), public, parameter, dimension(nb_methods) :: method_names = (/"GD     ", "NR     "/)

The names of the methods themselves

integer, public, parameter :: nb_rprt_params = 3

Number of report parameters.

character(len=256), public, parameter, dimension(nb_rprt_params) :: rprt_params = (/"freq  ", "format", "print "/)

Names of the report parameters.


Subroutines

public subroutine GD(format_str, output_str)

GRADIENT DESCENT

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=20) :: format_str

formatting string

character(len=1000) :: output_str

Actual x and y values for reportting.

public subroutine handle_main_file(nb_methods, nb_rprt_params, method_names, rprt_params)

Subroutine for handling the optimization runs.

Read more…

Arguments

Type IntentOptional Attributes Name
integer :: nb_methods

The total number of optimization methods currently implemented

integer :: nb_rprt_params

Number of report parameters currently implemented.

character(len=20), dimension(nb_methods) :: method_names

Array of optimization methods' names/labels.

character(len=256), dimension(nb_rprt_params) :: rprt_params

Array of report parameters' names/labels.

public subroutine handle_hyp_file(nb_hprparams, size_hprdata, hprnames, hprdata, hprdim, hprbool, requiredbool)

Subroutine for handling the method's hyper parameters.

Read more…

Arguments

Type IntentOptional Attributes Name
integer :: nb_hprparams

The total number of hyper parameters possible for the optimization method.

integer :: size_hprdata

Size of hprdata second dimension (usually dimx, extended for generality).

character(len=256), dimension(nb_hprparams) :: hprnames

Array of hyper parameter names/labels.

real(kind=8), dimension(nb_hprparams, size_hprdata) :: hprdata

Array of data (each hyperparameter value). Will have a lot of unused elements, since not all hyper parameters will have the same dimension. Each line is a different hyper parameter, in the same order as in hprnames.

integer, dimension(nb_hprparams) :: hprdim

Dimension of each hyper parameter, again in order.

logical, dimension(nb_hprparams) :: hprbool

Boolean array indicating which hyper parameters have been informed by the user (.true.) and which weren't (.false.).

logical, dimension(nb_hprparams) :: requiredbool

Which hyper parameters are required (.true.) and which are optional (.false.). This argument is not used in this subroutine, but directly in check_hprparams, which is called directly at the end of this subroutine, but was separated solely for clarity.

public subroutine check_status(filestatus, errormsg)

Subroutine for handling file reading errors.

Read more…

Arguments

Type IntentOptional Attributes Name
integer :: filestatus

File reading status (indicates errors)

character(len=256) :: errormsg

Error message and read line

public subroutine check_hprparams(nb_hprparams, hprnames, hprdata, hprdim, hprbool, requiredbool)

Subroutine for checking which hyper parameters were informed by the user.

Read more…

Arguments

Type IntentOptional Attributes Name
integer :: nb_hprparams
character(len=256), dimension(nb_hprparams) :: hprnames

Hyperparameter names.

real(kind=8), dimension(nb_hprparams, dimx) :: hprdata

Where data will be saved

integer, dimension(nb_hprparams) :: hprdim

Dimension of each hprparam.

logical, dimension(nb_hprparams) :: hprbool

Bool array: hprparam present or not

logical, dimension(nb_hprparams) :: requiredbool

Bool array: hprparam optional or not

public subroutine format_data(x, y, format_str, value_str)

Small function for formatting data according to a format string. Argument value_str is the output string containing the x and y values.

Arguments

Type IntentOptional Attributes Name
real(kind=8), intent(in), dimension(dimx) :: x

Input variable

real(kind=8), intent(in) :: y

Function value at x

character(len=20) :: format_str

Formatting string

character(len=1000) :: value_str

Output string