check_mize_convergence: Check Optimization Convergence

Description Usage Arguments Details Value Examples

View source: R/mize.R

Description

Updates the optimizer with information about convergence or termination, signaling if the optimization process should stop.

Usage

1
check_mize_convergence(mize_step_info)

Arguments

mize_step_info

Step info for this iteration, created by mize_step_summary

Details

On returning from this function, the updated value of opt will contain:

Convergence criteria are only checked here. To set these criteria, use make_mize or mize_init.

Value

opt updated with convergence and termination data. See 'Details'.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
rb_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)

opt <- make_mize(method = "BFGS", par = rb0, fg = rb_fg, max_iter = 30)
mize_res <- mize_step(opt = opt, par = rb0, fg = rb_fg)
step_info <- mize_step_summary(mize_res$opt, mize_res$par, rb_fg, rb0)
# check convergence by looking at opt$is_terminated
opt <- check_mize_convergence(step_info)

jlmelville/mizer documentation built on Jan. 17, 2022, 8:47 a.m.