Creates a solver that evaluates the log-likelihood on a grid of points
and returns the best. Useful for finding good starting points or for
low-dimensional problems.
Usage
grid_search(lower, upper, n = 10L)
Arguments
- lower
Lower bounds for the grid
- upper
Upper bounds for the grid
- n
Number of points per dimension (scalar or vector)
Value
A solver function with signature (problem, theta0, trace) -> mle_result
Details
Grid search is deterministic and exhaustive within its bounds. It's most
useful for 1-3 dimensional problems or as the first stage of a multi-stage
strategy (e.g., grid_search
The theta0 argument is ignored; the grid is determined by lower/upper/n.
Points outside the problem's constraint support are skipped.
Examples
if (FALSE) { # \dontrun{
# Simple grid search
solver <- grid_search(lower = c(-10, 0.1), upper = c(10, 5), n = 20)
result <- solver(problem, c(0, 1))
# Coarse-to-fine: grid then gradient
strategy <- grid_search(c(-10, 0.1), c(10, 5), n = 5) %>>% gradient_ascent()
} # }