Skip to contents

This class defines the optimization technique.

Public fields

id

(`character(1)` The id of the objective.

print_trace

(`logical(1)` Indicator whether to print the status of `$optimize()`.

Active bindings

lr

(`numeric(1`) Step size of the algorithm.

archive

(`data.table()`) Archive of all calls to `$evalStore`.

objective

(`Objective`) The objective function.

x

(`numeric()`) The numerical input vector used as starting point by `$optimize()`.

Methods


Method new()

Creates a new instance of this [R6][R6::R6Class] class.

Usage

Optimizer$new(objective, x_start, id = NULL, print_trace = TRUE)

Arguments

objective

(`Objective`) The objective to optimize.

x_start

(`numeric()`) Start value of the optimization. Note, after the first call of `$optimize()` the last value is used to continue optimization. Get this value with `$x`.

id

(`character(1)`) Id of the object.

print_trace

(`logical(1)`) Indicator whether to print the status of `$optimize()`.


Method prepareUpdateForArchive()

Prepare updates for adding them to the archive.

Usage

Optimizer$prepareUpdateForArchive(
  x_out,
  x_in,
  update,
  fval_out,
  fval_in,
  lr,
  step_size,
  objective,
  step,
  ...
)

Arguments

x_out

(`numeric()`) The new proposed point by the optimizer.

x_in

(`numeric()`) The old input value which is updated to `x_out`.

update

(`numeric()`) The update from `x_in` to `x_out`.

fval_out

(`numeric(1)`) The objective value `objetive$eval(x_out)`.

fval_in

(`numeric(1)`) The objective value `objetive$eval(x_in)`.

lr

(`numeric(1)`) The learning rate used to multiply `update` with.

step_size

(`numeric(1)`) The step_size used to multiply `lr * update` with.

objective

(`Objective`) The objective used by `$optimize()`.

step

(`integer(1)`) The step or iteration.

...

Additional objects added to the archive (e.g. `momentum`).

Returns

`data.table()` of the input arguments.


Method updateArchive()

Add points to the archive.

Usage

Optimizer$updateArchive(ain)

Arguments

ain

`data.table()` with names "x_out", "x_in", "update", "fval_out", "fval_in", "lr", "objective", and "step".


Method setX()

Set the current input vector used as start point of `$optimize()`.

Usage

Optimizer$setX(x)

Arguments

x

(`numeric()`) Input vector.


Method clone()

The objects of this class are cloneable with this method.

Usage

Optimizer$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.