A generated action vector and state matrix are input and this function returns a numeric vector of the same length as the outcome. evolve_model then computes a fitness score for that potential solution FSM by comparing it to the provided outcome. This is repeated for every FSM in the population and then the probability of selection for the next generation is set to be proportional to the fitness scores. This function is also used in the predict method for the resulting final model that is returned. The function aborts if the user aborts in R, checking every 1000 iterations.

fitnessCPP(action_vec, state_mat, covariates, period)

Arguments

action_vec

Integer Vector.

state_mat

Integer Matrix.

covariates

Integer Matrix.

period

Integer Vector.