A Nop object defines a Numerical Optimization Problem.
A Nop object, which is an R6 class that specifies the numerical
optimization problem, stores optimization results, and provides methods
for analyzing the results, see the details.
Nop object:
Call object <- Nop$new(f, npar, ...) where
f is the function to be optimized over its first argument,
npar is the length of the first argument of f,
and ... are additional arguments for f.
Call object$set_optimizer(<optimizer object>), where
<optimizer object> is an object of class optimizer, which can
be created with the define_optimizer function from
the {optimizeR} package.
Two optimizer objects are already available:
optimizer_nlm
optimizer_optim
Call object$test() to validate your configuration. An overview of
the configuration yields the $print() method.
Call object$evaluate() to evaluate the target function at some point.
Call object$optimize() for optimization. See also the methods
object$standardize(), object$reduce(), and
object$continue() for initialization strategies.
The following are methods for the analysis of optimization results, with different filter options for optimization runs, optimizers, and elements:
$results() returns all saved optimization results,
$summary() summarizes the results,
$optima() returns a frequency table of identified optima,
$plot() visualizes the optimization time or value,
$best_parameter() returns the parameter vector at which the optimum value is obtained,
$best_value() returns the found optimum value of f,
$closest_parameter() returns parameter closest to a specified value.
fThe function to be optimized.
f_nameThe name of the function to be optimized.
f_targetThe name of the target argument, i.e., the argument over
which f is optimized.
nparThe length of the target argument, i.e., the argument over
which f is optimized.
argumentsA list of specified additional arguments for
f.
true_valueThe true numeric optimum value of f
(if available).
true_parameterThe true optimum numeric parameter vector
of length npar (if available), i.e., the point where f
obtains its optimum.
minimizedA logical, set to TRUE (default) to
show best minimum in $best_value(), $best_parameter(), and
$optima().
optimizerA list of specified optimizers.
new_labelA character, a new optimization label that has
not been used yet.
new()Creates a new Nop object.
Nop$new(f, npar, ...)fThe function to be optimized.
It is optimized over its first argument, which should be a numeric
vector of length npar.
nparAn integer, the length of the first argument of f (the
argument over which f is optimized).
...Optionally additional and named arguments for f.
A new Nop object.
print()Prints details of the numerical optimization problem.
Nop$print(digits = getOption("ino_digits", default = 2), ...)digitsAn integer, the number of shown decimal places.
The default is 2.
...Currently not used.
Invisibly the Nop object.
set_argument()Sets additional arguments for f.
Nop$set_argument(...)...Optionally additional named arguments for f.
Invisibly the Nop object.
get_argument()Gets an argument value for f.
Nop$get_argument(argument_name)argument_nameA character, the argument to extract.
The argument.
remove_argument()Removes an additional argument for f.
Nop$remove_argument(argument_name)argument_nameA character, the argument to remove.
Invisibly the Nop object.
set_optimizer()Sets a numerical optimizer.
Nop$set_optimizer(optimizer, label = NULL)optimizerAn object of class optimizer, which can be created with the
define_optimizer function from the {optimizeR}
package.
labelA character, a unique label for the optimizer.
By default label = NULL, in which case the default label saved
inside optimizer is used.
Invisibly the Nop object.
remove_optimizer()Removes numerical optimizer.
Nop$remove_optimizer(
which_optimizer,
verbose = getOption("ino_verbose", default = TRUE)
)which_optimizerSelect specified numerical optimizers. Either:
"all", all specified optimizers,
"removed", all removed optimizers,
"active", all active optimizers (i.e., not removed),
a character (vector) of specified optimizer labels,
a numeric (vector) of optimizer ids (see $print() output).
verboseA logical, which indicates whether progress/details should be printed.
Set to TRUE (FALSE) to print (hide) such messages.
The default is TRUE.
Invisibly the Nop object.
evaluate()Evaluates the function.
Nop$evaluate(at = rnorm(self$npar), time_limit = NULL, hide_warnings = FALSE)atA numeric vector of length npar, the point where the
function is evaluated.
Per default, at = rnorm(self$npar), i.e., random values drawn from a standard normal distribution.
time_limitAn integer, the time limit in seconds for computations.
No time limit if time_limit = NULL (the default).
This currently only works reliably under Windows.
hide_warningsA logical.
Set to TRUE (FALSE) to hide (show) warning messages.
Either:
a numeric value, the function value at at,
"time limit reached" if the time limit was reached,
the error message if the evaluation failed.
optimize()Optimizes the function.
Nop$optimize(
initial = "random",
runs = 1,
which_optimizer = "all",
seed = NULL,
return_results = FALSE,
save_results = TRUE,
label = self$new_label,
ncores = getOption("ino_ncores", default = 1),
verbose = getOption("ino_verbose", default = TRUE),
simplify = TRUE,
time_limit = NULL,
hide_warnings = TRUE,
fail_bad_initial = TRUE
)initialSpecify the initial point where the optimizer should start. Either:
the character "random" (the default) for random initial
values drawn from a standard normal distribution,
a numeric vector of length npar, the starting point for
optimization,
a list of such vectors (in this case, runs is set to the
length of the list),
or a function without any arguments that returns a
numeric vector of length npar.
In all these cases, the same initial values are used for each optimizer.
For more flexibility, a funtion for initial can have two
arguments, where the first argument specifies the optimization run,
and the second argument specifies the optimizer.
runsAn integer, the number of optimization runs.
By default, runs = 1.
which_optimizerSelect specified numerical optimizers. Either:
"all", all specified optimizers,
"removed", all removed optimizers,
"active", all active optimizers (i.e., not removed),
a character (vector) of specified optimizer labels,
a numeric (vector) of optimizer ids (see $print() output).
seedAn integer, passed to set.seed for reproducibility.
Can be NULL for no seed, which is the default.
return_resultsA logical, which indicates whether the optimization results should be
returned as a list.
By default, return_results = FALSE.
save_resultsA logical, which indicates whether the optimization results should be
saved inside the Nop object.
By default, save_results = TRUE.
labelOnly relevant if save_results = TRUE.
In this case, an optional character to specify a custom label of
the optimization.
By default, label = self$new_label creates a new label.
Labels can be useful to distinguish optimization runs later.
ncoresAn integer, the number of CPU cores for parallel computation.
The default is 1.
You can use parallel::detectCores() to detect the number of available
CPU cores.
verboseA logical, which indicates whether progress/details should be printed.
Set to TRUE (FALSE) to print (hide) such messages.
The default is TRUE.
simplifyOnly relevant if return_results = TRUE and runs = 1 and/or
only one optimizer is specified.
In this case, if simplify = TRUE, the nested list output
of optimization results is flattened if possible.
time_limitAn integer, the time limit in seconds for computations.
No time limit if time_limit = NULL (the default).
This currently only works reliably under Windows.
hide_warningsA logical.
Set to TRUE (FALSE) to hide (show) warning messages.
fail_bad_initialEither TRUE to immediately fail if initial contains any
misspecifications (default), or FALSE to include the failed runs
in the results.
The return value depends on the value of return_results:
if return_results = FALSE, invisibly the Nop object,
if return_results = TRUE, a nested list of
optimization results.
Each element corresponds to one optimization run
and is a list of results for each optimizer.
The results for each optimizer is a list, the output of
apply_optimizer.
If simplify = TRUE, the output is flattened if possible.
test()Validates the configuration of a Nop object.
Nop$test(
at = rnorm(self$npar),
which_optimizer = "active",
time_limit = 10,
verbose = getOption("ino_verbose", default = TRUE),
digits = getOption("ino_digits", default = 2)
)atA numeric of length npar, the point at which the
function f and the specified optimizer are tested.
Per default, at = rnorm(self$npar), i.e., random values drawn
from a standard normal distribution.
which_optimizerSelect specified numerical optimizers. Either:
"all", all specified optimizers,
"removed", all removed optimizers,
"active", all active optimizers (i.e., not removed),
a character (vector) of specified optimizer labels,
a numeric (vector) of optimizer ids (see $print() output).
time_limitAn integer, the time limit in seconds for computations.
No time limit if time_limit = NULL (the default).
This currently only works reliably under Windows.
verboseA logical, which indicates whether progress/details should be printed.
Set to TRUE (FALSE) to print (hide) such messages.
The default is TRUE.
digitsAn integer, the number of shown decimal places.
The default is 2.
Invisibly TRUE if the tests are successful.
standardize()Standardizes the optimization problem.
Nop$standardize(
argument_name,
by_column = TRUE,
center = TRUE,
scale = TRUE,
ignore = integer(),
verbose = getOption("ino_verbose", default = TRUE)
)argument_nameA character, the name of the argument of f to be
standardized. The argument must a numeric vector,
matrix, or data.frame.
by_columnOnly relevant if the argument argument_name is a matrix or
a data.frame.
In that case, either TRUE to standardize column-wise (default) or
FALSE to standardize row-wise.
Currently, only by_column = TRUE is implemented.
centerPassed to scale.
Default is TRUE.
scalePassed to scale.
Default is TRUE.
ignoreA integer (vector) of column indices (or row indices if
by_column = FALSE) to not standardize.
verboseA logical, which indicates whether progress/details should be printed.
Set to TRUE (FALSE) to print (hide) such messages.
The default is TRUE.
Invisibly the Nop object.
reduce()Reduces the optimization problem.
Nop$reduce(
argument_name,
by_row = TRUE,
how = "random",
proportion = 0.5,
centers = 2,
ignore = integer(),
seed = NULL,
verbose = getOption("ino_verbose", default = TRUE)
)argument_nameA character, the name of the argument of f to be reduced.
by_rowOnly relevant if the argument argument_name is a matrix or
a data.frame.
In that case, either TRUE to reduce row-wise (default) or
FALSE to reduce column-wise.
Currently, only by_row = TRUE is implemented.
howA character, specifying how to reduce. Can be one of:
"random" (default), reduce at random
"first", reduce to the first elements
"last", reduce to the last elements
"similar", reduce to similar elements
"dissimilar", reduce to dissimilar elements
Note that "similar" and "dissimilar" are based on k-means
clustering via kmeans. To apply these options,
the argument argument_name must be numeric.
proportionA numeric between 0 and 1, specifying the
reduction proportion.
By default, proportion = 0.5.
centersOnly relevant, if how = "(dis)similar".
In that case, passed to kmeans.
By default, centers = 2.
ignoreOnly relevant, if how = "(dis)similar".
In that case a integer (vector) of row indices (or column indices
if by_row = FALSE) to ignore for clustering.
seedAn integer, passed to set.seed for reproducibility.
Can be NULL for no seed, which is the default.
verboseA logical, which indicates whether progress/details should be printed.
Set to TRUE (FALSE) to print (hide) such messages.
The default is TRUE.
Invisibly the Nop object.
reset_argument()Resets an additional argument for f after transformation with
$standardize() or $reduce().
Nop$reset_argument(
argument_name,
verbose = getOption("ino_verbose", default = TRUE)
)argument_nameA character, the name of the argument to reset.
verboseA logical, which indicates whether progress/details should be printed.
Set to TRUE (FALSE) to print (hide) such messages.
The default is TRUE.
Invisibly the Nop object.
continue()Continues optimization runs, e.g., with a transformed parameter.
Nop$continue(
which_run = "last",
which_optimizer = "active",
seed = NULL,
return_results = FALSE,
save_results = TRUE,
ncores = getOption("ino_ncores", default = 1),
verbose = getOption("ino_verbose", default = TRUE),
simplify = TRUE,
time_limit = NULL,
hide_warnings = TRUE
)which_runSelect saved results of optimization runs. Either:
"all", all results,
"last", the results from the last optimization,
"failed", the results from failed optimization runs,
a character (vector) of labels specified in $optimize(),
a numeric (vector) of run ids.
which_optimizerSelect specified numerical optimizers. Either:
"all", all specified optimizers,
"removed", all removed optimizers,
"active", all active optimizers (i.e., not removed),
a character (vector) of specified optimizer labels,
a numeric (vector) of optimizer ids (see $print() output).
seedAn integer, passed to set.seed for reproducibility.
Can be NULL for no seed, which is the default.
return_resultsA logical, which indicates whether the optimization results should be
returned as a list.
By default, return_results = FALSE.
save_resultsA logical, which indicates whether the optimization results should be
saved inside the Nop object.
By default, save_results = TRUE.
ncoresAn integer, the number of CPU cores for parallel computation.
The default is 1.
You can use parallel::detectCores() to detect the number of available
CPU cores.
verboseA logical, which indicates whether progress/details should be printed.
Set to TRUE (FALSE) to print (hide) such messages.
The default is TRUE.
simplifyOnly relevant if return_results = TRUE and runs = 1 and/or
only one optimizer is specified.
In this case, if simplify = TRUE, the nested list output
of optimization results is flattened if possible.
time_limitAn integer, the time limit in seconds for computations.
No time limit if time_limit = NULL (the default).
This currently only works reliably under Windows.
hide_warningsA logical.
Set to TRUE (FALSE) to hide (show) warning messages.
The same as the return value of $optimize().
results()Returns saved optimization results.
Nop$results(
which_run = "all",
which_optimizer = "all",
which_element = "all",
only_comparable = FALSE,
simplify = TRUE
)which_runSelect saved results of optimization runs. Either:
"all", all results,
"last", the results from the last optimization,
"failed", the results from failed optimization runs,
a character (vector) of labels specified in $optimize(),
a numeric (vector) of run ids.
which_optimizerSelect specified numerical optimizers. Either:
"all", all specified optimizers,
"removed", all removed optimizers,
"active", all active optimizers (i.e., not removed),
a character (vector) of specified optimizer labels,
a numeric (vector) of optimizer ids (see $print() output).
which_elementSelect elements of saved optimization results.
See $elements_available() for the names of all available elements.
Either:
"all", all elements,
"basic", the elements
"value", the numeric value of the found optimum,
"parameter", the parameter vector at which the optimum value
is obtained,
"default", the elements that are saved for all optimization runs by
default, i.e.
"run", the run id,
"optimizer", the label for the optimizer,
"value" and "parameter" (see above),
"seconds", the optimization time in seconds,
"label", the label for the optimization run,
a character (vector), names of specific elements in the optimization
output.
only_comparableEither TRUE to show only comparable results (i.e., results obtained
for the original optimization problem), or FALSE to
include all optimization results.
simplifyOnly relevant if return_results = TRUE and runs = 1 and/or
only one optimizer is specified.
In this case, if simplify = TRUE, the nested list output
of optimization results is flattened if possible.
A nested list of optimization results.
Each element corresponds to one optimization run and is a list
of results for each optimizer.
If simplify = TRUE, the output is flattened if possible.
number_runs()Returns the number of saved optimization runs.
Nop$number_runs(
which_run = "all",
which_optimizer = "all",
only_comparable = FALSE
)which_runSelect saved results of optimization runs. Either:
"all", all results,
"last", the results from the last optimization,
"failed", the results from failed optimization runs,
a character (vector) of labels specified in $optimize(),
a numeric (vector) of run ids.
which_optimizerSelect specified numerical optimizers. Either:
"all", all specified optimizers,
"removed", all removed optimizers,
"active", all active optimizers (i.e., not removed),
a character (vector) of specified optimizer labels,
a numeric (vector) of optimizer ids (see $print() output).
only_comparableEither TRUE to show only comparable results (i.e., results obtained
for the original optimization problem), or FALSE to
include all optimization results.
An integer.
elements_available()Returns names of available elements per optimizer.
Nop$elements_available(which_optimizer = "all")which_optimizerSelect specified numerical optimizers. Either:
"all", all specified optimizers,
"removed", all removed optimizers,
"active", all active optimizers (i.e., not removed),
a character (vector) of specified optimizer labels,
a numeric (vector) of optimizer ids (see $print() output).
A list.
clear()Deletes optimization results.
Nop$clear(which_run, which_optimizer = "all", which_element = "all")which_runSelect saved results of optimization runs. Either:
"all", all results,
"last", the results from the last optimization,
"failed", the results from failed optimization runs,
a character (vector) of labels specified in $optimize(),
a numeric (vector) of run ids.
which_optimizerSelect specified numerical optimizers. Either:
"all", all specified optimizers,
"removed", all removed optimizers,
"active", all active optimizers (i.e., not removed),
a character (vector) of specified optimizer labels,
a numeric (vector) of optimizer ids (see $print() output).
which_elementSelect elements of saved optimization results.
See $elements_available() for the names of all available elements.
Either:
"all", all elements,
"basic", the elements
"value", the numeric value of the found optimum,
"parameter", the parameter vector at which the optimum value
is obtained,
"default", the elements that are saved for all optimization runs by
default, i.e.
"run", the run id,
"optimizer", the label for the optimizer,
"value" and "parameter" (see above),
"seconds", the optimization time in seconds,
"label", the label for the optimization run,
a character (vector), names of specific elements in the optimization
output.
Invisibly the Nop object.
summary()Provides an overview of the optimization runs.
Nop$summary(
which_element = "basic",
which_run = "all",
which_optimizer = "all",
digits = getOption("ino_digits", default = 2),
only_comparable = FALSE,
...
)which_elementSelect elements of saved optimization results.
See $elements_available() for the names of all available elements.
Either:
"all", all elements,
"basic", the elements
"value", the numeric value of the found optimum,
"parameter", the parameter vector at which the optimum value
is obtained,
"default", the elements that are saved for all optimization runs by
default, i.e.
"run", the run id,
"optimizer", the label for the optimizer,
"value" and "parameter" (see above),
"seconds", the optimization time in seconds,
"label", the label for the optimization run,
a character (vector), names of specific elements in the optimization
output.
which_runSelect saved results of optimization runs. Either:
"all", all results,
"last", the results from the last optimization,
"failed", the results from failed optimization runs,
a character (vector) of labels specified in $optimize(),
a numeric (vector) of run ids.
which_optimizerSelect specified numerical optimizers. Either:
"all", all specified optimizers,
"removed", all removed optimizers,
"active", all active optimizers (i.e., not removed),
a character (vector) of specified optimizer labels,
a numeric (vector) of optimizer ids (see $print() output).
digitsAn integer, the number of shown decimal places.
The default is 2.
only_comparableEither TRUE to show only comparable results (i.e., results obtained
for the original optimization problem), or FALSE to
include all optimization results.
...Optionally named expressions of elements.
See $elements_available() for the names of all available elements.
In addition, "true_value", "true_parameter",
"best_value", and "best_parameter" can be accessed
As an example, you could add
distance = "sqrt(sum((parameter - true_parameter) ^ 2))" for the
euclidean distance between the estimated and true parameter vector.
A data.frame with optimization results.
optima()Provides an overview of the identified optimum values.
Nop$optima(
digits = getOption("ino_digits", default = 2),
sort_by = "frequency",
which_run = "all",
which_optimizer = "all",
only_comparable = TRUE
)digitsAn integer, the number of shown decimal places.
The default is 2.
sort_byEither:
"frequency" (default) to sort rows by frequency,
"value" to sort by value.
which_runSelect saved results of optimization runs. Either:
"all", all results,
"last", the results from the last optimization,
"failed", the results from failed optimization runs,
a character (vector) of labels specified in $optimize(),
a numeric (vector) of run ids.
which_optimizerSelect specified numerical optimizers. Either:
"all", all specified optimizers,
"removed", all removed optimizers,
"active", all active optimizers (i.e., not removed),
a character (vector) of specified optimizer labels,
a numeric (vector) of optimizer ids (see $print() output).
only_comparableEither TRUE to show only comparable results (i.e., results obtained
for the original optimization problem), or FALSE to
include all optimization results.
A data.frame.
plot()Visualizes the optimization time or value.
Nop$plot(
which_element = "seconds",
by = NULL,
relative = FALSE,
which_run = "all",
which_optimizer = "all",
only_comparable = FALSE,
title = paste("Optimization of", x$f_name),
xlim = c(NA, NA)
)which_elementEither:
"seconds" to plot the optimization times (default)
"value" to plot the optimization values
byEither:
"label" to group by optimization label
"optimizer" to group by optimizer
NULL to not group (default)
relativeOnly if which_element = "seconds".
In this case, set to TRUE to plot relative time differences with
respect to the overall median.
which_runSelect saved results of optimization runs. Either:
"all", all results,
"last", the results from the last optimization,
"failed", the results from failed optimization runs,
a character (vector) of labels specified in $optimize(),
a numeric (vector) of run ids.
which_optimizerSelect specified numerical optimizers. Either:
"all", all specified optimizers,
"removed", all removed optimizers,
"active", all active optimizers (i.e., not removed),
a character (vector) of specified optimizer labels,
a numeric (vector) of optimizer ids (see $print() output).
only_comparableEither TRUE to show only comparable results (i.e., results obtained
for the original optimization problem), or FALSE to
include all optimization results.
titleA character, the plot title.
xlimPassed on to coord_cartesian.
A ggplot object.
deviation()Visualizes deviation of parameters.
Nop$deviation(
reference = self$true_parameter,
which_element = "initial",
which_run = "all",
which_optimizer = "all",
only_comparable = FALSE,
title = "Parameter deviation",
ylim = c(NA, NA),
parameter_labels = paste0("theta", 1:self$npar)
)referenceA numeric of length self$npar, the reference parameters.
which_elementEither:
"initial" to compute deviations to the initial values (default)
"parameter" to compute deviations to the estimated parameters
which_runSelect saved results of optimization runs. Either:
"all", all results,
"last", the results from the last optimization,
"failed", the results from failed optimization runs,
a character (vector) of labels specified in $optimize(),
a numeric (vector) of run ids.
which_optimizerSelect specified numerical optimizers. Either:
"all", all specified optimizers,
"removed", all removed optimizers,
"active", all active optimizers (i.e., not removed),
a character (vector) of specified optimizer labels,
a numeric (vector) of optimizer ids (see $print() output).
only_comparableEither TRUE to show only comparable results (i.e., results obtained
for the original optimization problem), or FALSE to
include all optimization results.
titleA character, the plot title.
ylimPassed on to coord_cartesian.
parameter_labelsA character of length length(reference) with labels for the
parameters.
A ggplot object.
trace()Capture trace of optimization with stats::nlm().
Nop$trace(
initial = stats::rnorm(self$npar),
iterations = 100,
tolerance = 1e-06,
which_element = c("value", "parameter", "gradient", "hessian", "seconds"),
...
)initialA numeric vector of length npar, the starting point for
the optimization.
By default, initial = stats::rnorm(self$npar), i.e., random
initial values drawn from a standard normal distribution.
iterationsA positive integer, the maximum number of iterations before
termination.
By default, interations = 100.
toleranceA numeric, the minimum allowable absolute change in the
function value before termination.
By default, tolerance = 1e-6.
which_elementA character (vector) of elements to provide in the output, can be
one or more of:
value (the current function value)
parameter (the current value of each parameter)
gradient (the current gradient value)
hessian (the current Hessian value)
seconds (the number of seconds for the current iteration)
...Additional arguments passed on to nlm.
The arguments iterlim and hessian cannot be specified.
A data.frame with iterations in rows, the columns depend on the
specification of which_element.
best_value()Returns the best found numeric value of f.
Nop$best_value(
which_run = "all",
which_optimizer = "all",
only_comparable = TRUE,
digits = getOption("ino_digits", default = 2)
)which_runSelect saved results of optimization runs. Either:
"all", all results,
"last", the results from the last optimization,
"failed", the results from failed optimization runs,
a character (vector) of labels specified in $optimize(),
a numeric (vector) of run ids.
which_optimizerSelect specified numerical optimizers. Either:
"all", all specified optimizers,
"removed", all removed optimizers,
"active", all active optimizers (i.e., not removed),
a character (vector) of specified optimizer labels,
a numeric (vector) of optimizer ids (see $print() output).
only_comparableEither TRUE to show only comparable results (i.e., results obtained
for the original optimization problem), or FALSE to
include all optimization results.
digitsAn integer, the number of shown decimal places.
The default is 2.
A numeric, the best found numeric value of f.
The output has two attributes:
run, the run id that led to the best value,
optimizer, the optimizer that led to the best value.
In the case that multiple optimization runs led to the best value, the
first one of them is returned.
best_parameter()Returns the best found numeric parameter vector.
Nop$best_parameter(
which_run = "all",
which_optimizer = "all",
only_comparable = TRUE,
digits = getOption("ino_digits", default = 2)
)which_runSelect saved results of optimization runs. Either:
"all", all results,
"last", the results from the last optimization,
"failed", the results from failed optimization runs,
a character (vector) of labels specified in $optimize(),
a numeric (vector) of run ids.
which_optimizerSelect specified numerical optimizers. Either:
"all", all specified optimizers,
"removed", all removed optimizers,
"active", all active optimizers (i.e., not removed),
a character (vector) of specified optimizer labels,
a numeric (vector) of optimizer ids (see $print() output).
only_comparableEither TRUE to show only comparable results (i.e., results obtained
for the original optimization problem), or FALSE to
include all optimization results.
digitsAn integer, the number of shown decimal places.
The default is 2.
A numeric of length self$npar.
The output has two attributes:
run, the run id that led to the best parameter vector,
optimizer, the optimizer that led to the best parameter vector.
Note that this parameter vector is not necessarily unique.
closest_parameter()Extracts the parameter vector that led to a function value closest
(in absolute value) to value.
Note that this parameter vector is not necessarily unique.
Nop$closest_parameter(
value,
which_run = "all",
which_optimizer = "all",
only_comparable = TRUE,
digits = getOption("ino_digits", default = 2)
)valueA single numeric.
which_runSelect saved results of optimization runs. Either:
"all", all results,
"last", the results from the last optimization,
"failed", the results from failed optimization runs,
a character (vector) of labels specified in $optimize(),
a numeric (vector) of run ids.
which_optimizerSelect specified numerical optimizers. Either:
"all", all specified optimizers,
"removed", all removed optimizers,
"active", all active optimizers (i.e., not removed),
a character (vector) of specified optimizer labels,
a numeric (vector) of optimizer ids (see $print() output).
only_comparableEither TRUE to show only comparable results (i.e., results obtained
for the original optimization problem), or FALSE to
include all optimization results.
digitsAn integer, the number of shown decimal places.
The default is 2.
A numeric vector of length self$npar.
The output has two attributes:
run, the run id that led to this parameter vector,
optimizer, the optimizer that led to this parameter vector.
clone()The objects of this class are cloneable with this method.
Nop$clone(deep = FALSE)deepWhether to make a deep clone.
Nop$new(f = f_ackley, npar = 2)$
set_optimizer(optimizer_nlm())$
optimize(runs = 100, verbose = FALSE)$
optima()
Run the code above in your browser using DataLab