tests/testthat/test-test_replacement.R

test_that("replacement replaces correct number of individuals", {
    population <- c(1, 3, 0)
    offspring <- c(2, 2)
    replaced_population <- genetic.algo.optimizeR::replacement(population, offspring, num_to_replace = 1)
    expect_equal(length(unique(replaced_population)), length(population)) # Check if all individuals are unique
})

Try the genetic.algo.optimizeR package in your browser

Any scripts or data that you put into this service are public.

genetic.algo.optimizeR documentation built on Oct. 10, 2024, 5:07 p.m.