par: Vector of initial values for the function to be optimized over.
fg: Function and gradient list. See the documentation of mize.
max_iter: (Optional). Maximum number of iterations. See the 'Convergence' section of mize for details.
max_fn: (Optional). Maximum number of function evaluations. See the 'Convergence' section of mize for details.
max_gr: (Optional). Maximum number of gradient evaluations. See the 'Convergence' section of mize for details.
max_fg: (Optional). Maximum number of function or gradient evaluations. See the 'Convergence' section of mize for details.
abs_tol: (Optional). Absolute tolerance for comparing two function evaluations. See the 'Convergence' section of mize for details.
rel_tol: (Optional). Relative tolerance for comparing two function evaluations. See the 'Convergence' section of mize for details.
grad_tol: (Optional). Absolute tolerance for the length (l2-norm) of the gradient vector. See the 'Convergence' section of mize
for details.
ginf_tol: (Optional). Absolute tolerance for the infinity norm (maximum absolute component) of the gradient vector. See the 'Convergence' section of mize for details.
step_tol: (Optional). Absolute tolerance for the size of the parameter update. See the 'Convergence' section of mize for details.
Returns
Initialized optimizer.
Details
Should be called after creating an optimizer with make_mize and before beginning any optimization with mize_step. Note that if fg and par are available at the time mize_step is called, they can be passed to that function and initialization will be carried out automatically, avoiding the need to call mize_init.
Optional convergence parameters may also be passed here, for use with check_mize_convergence. They are optional if you do your own convergence checking.
Details of the fg list can be found in the 'Details' section of mize.
Examples
# Create an optimizeropt <- make_mize(method ="L-BFGS")# Function to optimize and starting point defined after creating optimizerrosenbrock_fg <- list( fn =function(x){100*(x[2]- x[1]* x[1])^2+(1- x[1])^2}, gr =function(x){ c(-400* x[1]*(x[2]- x[1]* x[1])-2*(1- x[1]),200*(x[2]- x[1]* x[1]))})rb0 <- c(-1.2,1)# Initialize with function and starting point before commencing optimizationopt <- mize_init(opt, rb0, rosebrock_fg)# Finally, can commence the optimization looppar <- rb0
for(iter in1:3){ res <- mize_step(opt, par, rosenbrock_fg) par <- res$par
opt <- res$opt
}