For many applications, one needs to pass a function that evaluates the cost (or the log-posterior) from the control vector. For instance:
- MCMC sampling: samples=MCMC(logpost_function, starting_point, MCMC_args, **logpost_function_args)
- Hessian computation: hess=Hessian(cost_function, evaluation_point, Hessian_args, **cost_function_args)
- Using a Python optimizer: optim(cost_function, starting_point, optim_args, **cost_function_args)
- etc.
To facilitate this, the following functions would be useful (interfaces are approximate, just to convey the idea):
- retrieve the control vector from model and optim/cost options: control=smash.get_control(model,mapping,optimize_options,cost_options)
- "unfold" a control vector into model parameters: model.set_control(control,mapping,optimize_options,cost_options)
- compute the cost using parameters currently in model: cost=smash.get_cost(model,mapping,optimize_options,cost_options)
- compute the jacobian vector dcost/dcontrol using parameters currently in model: jac=smash.get_jacobian(model,mapping,optimize_options,cost_options)
- make a forward run from the control vector, and (optionally) retrieve cost and jacobian: model,cost,jacobian=smash.forward_run_from_control(control,model,mapping,optimize_options,cost_options)
For many applications, one needs to pass a function that evaluates the cost (or the log-posterior) from the control vector. For instance:
To facilitate this, the following functions would be useful (interfaces are approximate, just to convey the idea):