Function factory producing solver objective function returning value and (possibly) gradient at the same time.
objective(solver, data, misfit_fn = squared_error, param_transform = NULL, ...)
solver | object of class |
---|---|
data | observed ('exact') data. |
misfit_fn | function to compute misfit between |
param_transform | function performing parameter transformation, must
accept 1 parameter |
... | additional args passed to |
Function with numeric parameter x
returning list with one or two
components:
value
numeric, objective value,
gradient
numeric, objective gradient, missing if solver does not compute Jacobian matrix.
s <- fake_adaptive_solver(4, 5) result <- run(s, c(10, 10, 10, 10), precision = 5.0, silent = TRUE) observed_data <- result$qoi x <- c(10.5, 9.44, 10.21, 8.14) solver_obj <- objective(s, observed_data, precision = 30.0, silent = TRUE) solver_obj(x)#> $value #> [1] 2594156034 #> #> $gradient #> [1] -6208209534 -4059190749 -5551351184 -2246937119 #>