cost_fun: Cost function

Description Usage Arguments Value

View source: R/cost-fun.R

Description

Defines a cost function to be used in seq_opt(). A cost function defines the penalty for a given state transitions. If multiple cost functions are provided to seq_opt() then costs are computed for each cost function and summed to produce the final cost.

Usage

1
2
cost_fun(context_sensitive, f, memoise = FALSE, vectorised = FALSE,
  weight = 1)

Arguments

context_sensitive

Scalar Boolean; whether the function is affected by the identity of the previous state. If FALSE, this means the cost function only depends on the identity of the new state.

f

Function defining the cost function. If context_sensitive = TRUE, this function should take two arguments, the first corresponding to the previous state, and the second corresponding to the new state. If context_sensitive = FALSE, this function should take one argument corresponding to the new state.

memoise

Scalar Boolean; whether or not the cost function should be memoised. Defaults to FALSE, but enable this when the cost function is time-consuming to compute and repeated transitions are anticipated.

vectorised

Scalar Boolean; whether or not f is vectorised. If f is vectorised, it should take as its first input a list of potential previous states, with its second input being the new state, as before. It should then return a numeric vector corresponding to the transition cost associated with each potential previous state.

weight

Scalar numeric; defines the multiplicative weight parameter for the cost function when seq_opt() combines cost functions.

Value

An object of class cost_fun, to be combined into a list and passed to seq_opt().


pmcharrison/seqopt documentation built on Oct. 9, 2018, 7:38 p.m.