seq_opt: Find optimal sequence

Description Usage Arguments Value

View source: R/seq-opt.R

Description

Given a list of timepoints and corresponding lists of possible states, efficiently finds an optimal state sequence that minimises (or maximises) an arbitrary transition cost function. The implementation uses dynamic programming to achieve complexity linear in the sequence length and quadratic in the number of possible states.

Usage

1
2
seq_opt(x, cost_funs, weights = 1, verbose = FALSE, exp_cost = FALSE,
  norm_cost = FALSE, log_cost = FALSE, minimise = TRUE)

Arguments

x

A nested list describing the possible states at the possible time points. Element x[[i]] should be a list describing the states available at timepoint i. Element x[[i]][[j]] should be the jth possible state at timepoint i.

cost_funs

A list of cost functions, with each cost function created by cost_fun(). When applied to a state transition, each cost function is computed, weighted by its weight parameter, and summed to provide the total cost. Decomposition of cost functions in this way has efficiency benefits when some of the cost functions are context-independent (i.e. the cost associated with moving to a state is independent of the previous state).

weights

Numeric vector of either length 1 or the same length as cost_funs, giving the weight for each cost function.

verbose

(Logical scalar) Whether to display progress messages.

exp_cost

(Logical scalar) Whether the combined cost function should be exponentiated.

norm_cost

(Logical scalar) Whether or not the cost at each transition (conditioned on the previous state) should be normalised to sum to 1 for the set of possible continuations. This yields a probabilistic interpretation of the cost function. This takes place after the exponentiation controlled by the exp_cost argument.

log_cost

(Logical scalar) Whether or not the final costs should have their logarithm taken. This takes place after the normalisation controlled by the norm_cost argument.

minimise

(Logical scalar) Whether the cost function should be minimised or maximised.

Value

A list where element i corresponds to the optimal state at timepoint i.


pmcharrison/seqopt documentation built on May 22, 2019, 6:35 p.m.