If the potential solution is indeed a local optimum of the objective function, and if it is used to initialize a second optimization, then original and "refined" solutions ought to be close.

optim_refit(xsol, fun, maximize = TRUE, maxit = 5000, reltol = 1e-08, xopt)

Arguments

xsol

Potential solution vector of length nx.

fun

Objective function to be maximized (or minimized), with first argument the length-nx parameter vector over which optimization is to take place. Should return a scalar result.

maximize

Logical, whether a maximum or a minimum of the objective function is sought.

maxit

Maximum number of iterations for stats::optim() refit (see Details).

reltol

Relative tolerance for convergence of stats::optim() refit (see Details).

xopt

Optional refit solution calculated externally from an optimization algorithm of choice (see Details).

Value

An object of class optrefit inheriting from optcheck, with elements:

xsol

The potential solution.

ysol

The value of fun(xsol).

maximize

Logical indicating whether the potential solution should maximize or minimize the objective function.

xopt

The solution found by the general-purpose optimizer.

yopt

The function value at the optimal solution, i.e., fun(xopt).

Details

By default, a so-called refined op(t)imization (or refit) test is performed by running the default Nelder-Mead simplex method provided by stats::optim(), initialized by the potential solution xsol. Only a simplified interface to stats::optim()'s control parameters are provided here.

Alternatively, the refit test can be performed with any optimization algorithm of choice. This is done externally, with the refined solution passed to optim_refit() via the argument xopt.

See also

summary, print, and diff for optrefit objects are available; see summary.optrefit(), print.optrefit(), and diff.optrefit().