Objective functions
Methods common to pomp
stateful objective functions
Since pomp
cannot guarantee that the final call an optimizer makes to the function is a call at the optimum, it cannot guarantee that the parameters stored in the function are the optimal ones. Therefore, it is a good idea to evaluate the function on the parameters returned by the optimization routine, which will ensure that these parameters are stored.
If you use C snippets (see Csnippet
), a dynamically loadable library will be built. As a rule, pomp
functions load this library as needed and unload it when it is no longer needed. The stateful objective functions are an exception to this rule. For efficiency, calls to the objective function do not execute pompLoad
or pompUnload
: rather, it is assumed that pompLoad
has been called before any call to the objective function. When a stateful objective function using one or more C snippets is created, pompLoad
is called internally to build and load the library: therefore, within a single session, if one creates a stateful objective function, one can freely call that objective function and (more to the point) pass it to an optimizer that calls it freely, without needing to call pompLoad
. On the other hand, if one retrieves a stored objective function from a file, or passes one to another session, one must call pompLoad
before using it. Failure to do this will typically result in a segmentation fault (i.e.,it will crash the R session).