test_user_function: Tests User_Provided Custom Function

View source: R/test_custom_function.R

test_user_functionR Documentation

Tests User_Provided Custom Function

Description

This function confirms that a user-provided function takes genes from a generation_matrix and a data matrix and returns a score for each gene It also confirms there are not NAs or infinity values. This function does not confirm that the scores are in descending order aka higher fitness creatures receive a higher fitness scores. It also does not confirm that all possible scores are defined.

Usage

test_user_function(func, generation_matrix, data)

Arguments

func

user provided function (needs generation_matrix followed by data)

generation_matrix

generation matrix with all 0s and 1s with ncol = gene_length and nrow = pop

data

a matrix or dataframe with ncol = gene_length plus 1

Details

User-provided function must have its first two arguments be (1) generation_matrix and (2) data. Function needs to take a single row of a generation_matrix and return a single numeric without NAs or infinities.

Value

TRUE if it passes and an error message otherwise

Examples

generation_matrix <- matrix(rbinom(2*10,1,.5),ncol=10)
data <- matrix(rnorm(11*3),nc=11)
func <- function(generation_matrix,data) {sum(generation_matrix)}

test <- test_user_function(func,generation_matrix,data)


AndrewM1130/GA documentation built on July 9, 2022, 11:43 a.m.