| Procedure {ao} | R Documentation |
Procedure Object
Description
This object specifies alternating optimization procedure.
Active bindings
npar(
integer(1))
The length of the target argument.partition(
character(1)orlist())
Defines the parameter partition, and can be either-
"sequential"for treating each parameter separately, -
"random"for a random partition in each iteration, -
"none"for no partition (which is equivalent to joint optimization), or a
listof vectors of parameter indices, specifying a custom partition for the alternating optimization process.
-
new_block_probability(
numeric(1))
Only relevant ifpartition = "random". The probability for a new parameter block when creating a random partitions. Values close to 0 result in larger parameter blocks, values close to 1 result in smaller parameter blocks.minimum_block_number(
integer(1))
Only relevant ifpartition = "random". The minimum number of blocks in random partitions.verbose(
logical(1))
Whether to print tracing details during the alternating optimization process.minimize(
logical(1))
Whether to minimize during the alternating optimization process. IfFALSE, maximization is performed.iteration_limit(
integer(1)orInf)
The maximum number of iterations through the parameter partition before the alternating optimization process is terminated. Can also beInffor no iteration limit.seconds_limit(
numeric(1))
The time limit in seconds before the alternating optimization process is terminated. Can also beInffor no time limit. Note that this stopping criteria is only checked after a sub-problem is solved and not within solving a sub-problem, so the actual process time can exceed this limit.tolerance_value(
numeric(1))
A non-negative tolerance value. The alternating optimization terminates if the absolute difference between the current function value and the one beforetolerance_historyiterations is smaller thantolerance_value.Can be
0for no value threshold.tolerance_parameter(
numeric(1))
A non-negative tolerance value. The alternating optimization terminates if the distance between the current estimate and the beforetolerance_historyiterations is smaller thantolerance_parameter.Can be
0for no parameter threshold.By default, the distance is measured using the euclidean norm, but another norm can be specified via the
tolerance_parameter_normfield.tolerance_parameter_norm(
function)
The norm that measures the distance between the current estimate and the one from the last iteration. If the distance is smaller thantolerance_parameter, the procedure is terminated.It must be of the form
function(x, y)for two vector inputsxandy, and return a singlenumericvalue. By default, the euclidean normfunction(x, y) sqrt(sum((x - y)^2))is used.tolerance_history(
integer(1))
The number of iterations to look back to determine whethertolerance_valueortolerance_parameterhas been reached.iteration(
integer(1))
The current iteration number.block(
integer())
The currently active parameter block, represented as parameter indices.output(
list(), read-only)
The output of the alternating optimization procedure, which is alistwith the following elements:-
estimateis the parameter vector at termination. -
valueis the function value at termination. -
detailsis adata.framewith full information about the procedure: For each iteration (columniteration) it contains the function value (columnvalue), parameter values (columns starting withpfollowed by the parameter index), the active parameter block (columns starting withbfollowed by the parameter index, where1stands for a parameter contained in the active parameter block and0if not), and computation times in seconds (columnseconds) -
secondsis the overall computation time in seconds. -
stopping_reasonis a message why the procedure has terminated.
-
Methods
Public methods
Method new()
Creates a new object of this R6 class.
Usage
Procedure$new( npar = integer(), partition = "sequential", new_block_probability = 0.3, minimum_block_number = 2, verbose = FALSE, minimize = TRUE, iteration_limit = Inf, seconds_limit = Inf, tolerance_value = 1e-06, tolerance_parameter = 1e-06, tolerance_parameter_norm = function(x, y) sqrt(sum((x - y)^2)), tolerance_history = 1 )
Arguments
npar(
integer(1))
The (total) length of the target argument(s).partition(
character(1)orlist())
Defines the parameter partition, and can be either-
"sequential"for treating each parameter separately, -
"random"for a random partition in each iteration, -
"none"for no partition (which is equivalent to joint optimization), or a
listof vectors of parameter indices, specifying a custom partition for the alternating optimization process.
-
new_block_probability(
numeric(1))
Only relevant ifpartition = "random". The probability for a new parameter block when creating a random partitions. Values close to 0 result in larger parameter blocks, values close to 1 result in smaller parameter blocks.minimum_block_number(
integer(1))
Only relevant ifpartition = "random". The minimum number of blocks in random partitions.verbose(
logical(1))
Whether to print tracing details during the alternating optimization process.minimize(
logical(1))
Whether to minimize during the alternating optimization process. IfFALSE, maximization is performed.iteration_limit(
integer(1)orInf)
The maximum number of iterations through the parameter partition before the alternating optimization process is terminated. Can also beInffor no iteration limit.seconds_limit(
numeric(1))
The time limit in seconds before the alternating optimization process is terminated. Can also beInffor no time limit. Note that this stopping criteria is only checked after a sub-problem is solved and not within solving a sub-problem, so the actual process time can exceed this limit.tolerance_value(
numeric(1))
A non-negative tolerance value. The alternating optimization terminates if the absolute difference between the current function value and the one beforetolerance_historyiterations is smaller thantolerance_value.Can be
0for no value threshold.tolerance_parameter(
numeric(1))
A non-negative tolerance value. The alternating optimization terminates if the distance between the current estimate and the beforetolerance_historyiterations is smaller thantolerance_parameter.Can be
0for no parameter threshold.By default, the distance is measured using the euclidean norm, but another norm can be specified via the
tolerance_parameter_normfield.tolerance_parameter_norm(
function)
The norm that measures the distance between the current estimate and the one from the last iteration. If the distance is smaller thantolerance_parameter, the procedure is terminated. It must be of the formfunction(x, y)for two vector inputsxandy, and return a singlenumericvalue. By default, the euclidean normfunction(x, y) sqrt(sum((x - y)^2))is used.tolerance_history(
integer(1))
The number of iterations to look back to determine whethertolerance_valueortolerance_parameterhas been reached.
Method print_status()
Prints a status message.
Usage
Procedure$print_status(message, message_type = 8, verbose = self$verbose)
Arguments
message(
character(1))
The status message.message_type(
integer(1))
The type of the message, one of the following:-
1forcli::cli_h1() -
2forcli::cli_h2() -
3forcli::cli_h3() -
4forcli::cli_alert_success() -
5forcli::cli_alert_info() -
6forcli::cli_alert_warning() -
7forcli::cli_alert_danger() -
8forcli::cat_line()
-
verbose(
logical(1))
Whether to print tracing details during the alternating optimization process.
Method initialize_details()
Initializes the details part of the output.
Usage
Procedure$initialize_details(initial_parameter, initial_value)
Arguments
initial_parameter(
numeric())
The starting parameter values for the procedure.initial_value(
numeric(1))
The function value at the initial parameters.
Method update_details()
Updates the details part of the output.
Usage
Procedure$update_details( value, parameter_block, seconds, error, block = self$block )
Arguments
value(
numeric(1))
The updated function value.parameter_block(
numeric())
The updated parameter values for the active parameter block.seconds(
numeric(1))
The time in seconds for solving the sub-problem.error(
logical(1))
Whether solving the sub-problem resulted in an error.block(
integer())
The currently active parameter block, represented as parameter indices.
Method get_partition()
Get a parameter partition.
Usage
Procedure$get_partition()
Method get_details()
Get the details part of the output.
Usage
Procedure$get_details(
which_iteration = NULL,
which_block = NULL,
which_column = c("iteration", "value", "parameter", "block", "seconds")
)Arguments
which_iteration(
integer())
Selects the iteration(s). Can also beNULLto select all iterations.which_block(
character(1)orinteger())
Selects the parameter block in the partition and can be one of-
"first"for the first parameter block, -
"last"for the last parameter block, an
integervector of parameter indices,or
NULLfor all parameter blocks.
-
which_column(
character())
Selects the columns in thedetailspart of the output and can be one or more of"iteration","value","parameter","block", and"seconds"
Method get_value()
Get the function value in different steps of the alternating optimization procedure.
Usage
Procedure$get_value( which_iteration = NULL, which_block = NULL, keep_iteration_column = FALSE, keep_block_columns = FALSE )
Arguments
which_iteration(
integer())
Selects the iteration(s). Can also beNULLto select all iterations.which_block(
character(1)orinteger())
Selects the parameter block in the partition and can be one of-
"first"for the first parameter block, -
"last"for the last parameter block, an
integervector of parameter indices,or
NULLfor all parameter blocks.
-
keep_iteration_column(
logical())
Whether to keep the column containing the information about the iteration in the output.keep_block_columns(
logical())
Whether to keep the column containing the information about the active parameter block in the output.
Method get_value_latest()
Get the function value in the latest step of the alternating optimization procedure.
Usage
Procedure$get_value_latest()
Method get_value_best()
Get the optimum function value in the alternating optimization procedure.
Usage
Procedure$get_value_best()
Method get_parameter()
Get the parameter values in different steps of the alternating optimization procedure.
Usage
Procedure$get_parameter( which_iteration = self$iteration, which_block = NULL, keep_iteration_column = FALSE, keep_block_columns = FALSE )
Arguments
which_iteration(
integer())
Selects the iteration(s). Can also beNULLto select all iterations.which_block(
character(1)orinteger())
Selects the parameter block in the partition and can be one of-
"first"for the first parameter block, -
"last"for the last parameter block, an
integervector of parameter indices,or
NULLfor all parameter blocks.
-
keep_iteration_column(
logical())
Whether to keep the column containing the information about the iteration in the output.keep_block_columns(
logical())
Whether to keep the column containing the information about the active parameter block in the output.
Method get_parameter_latest()
Get the parameter value in the latest step of the alternating optimization procedure.
Usage
Procedure$get_parameter_latest(parameter_type = "full")
Arguments
parameter_type(
character(1))
Can be one of-
"full"(default) to get the full parameter vector, -
"block"to get the parameter values for the current block, i.e., the parameters with the indicesself$block -
"fixed"to get the parameter values which are currently fixed, i.e., all except for those with the indicesself$block
-
Method get_parameter_best()
Get the optimum parameter value in the alternating optimization procedure.
Usage
Procedure$get_parameter_best(parameter_type = "full")
Arguments
parameter_type(
character(1))
Can be one of-
"full"(default) to get the full parameter vector, -
"block"to get the parameter values for the current block, i.e., the parameters with the indicesself$block -
"fixed"to get the parameter values which are currently fixed, i.e., all except for those with the indicesself$block
-
Method get_seconds()
Get the optimization time in seconds in different steps of the alternating optimization procedure.
Usage
Procedure$get_seconds( which_iteration = NULL, which_block = NULL, keep_iteration_column = FALSE, keep_block_columns = FALSE )
Arguments
which_iteration(
integer())
Selects the iteration(s). Can also beNULLto select all iterations.which_block(
character(1)orinteger())
Selects the parameter block in the partition and can be one of-
"first"for the first parameter block, -
"last"for the last parameter block, an
integervector of parameter indices,or
NULLfor all parameter blocks.
-
keep_iteration_column(
logical())
Whether to keep the column containing the information about the iteration in the output.keep_block_columns(
logical())
Whether to keep the column containing the information about the active parameter block in the output.
Method get_seconds_total()
Get the total optimization time in seconds of the alternating optimization procedure.
Usage
Procedure$get_seconds_total()
Method check_stopping()
Checks if the alternating optimization procedure can be terminated.
Usage
Procedure$check_stopping()