populationDenseVec | R Documentation |
This function generates a population of dense vectors for a given size of the "world." It controls the sparsity of each vector based on the parameters defined in 'clf', either by creating random dense vectors or by building on a given 'best_ancestor' to produce similar solutions.
populationDenseVec(clf, size_world, best_ancestor = NULL)
clf |
A classifier object containing parameters for population generation, including: - 'size_pop': Size of the population to generate. - 'current_sparsity': Target sparsity level for the population (if specified). - 'sparsity': Vector of sparsity levels, from which the minimum is used if 'current_sparsity' is not provided. - 'perc_best_ancestor': Percentage of the population to generate based on the best ancestor. |
size_world |
An integer representing the size of the dense vector for each individual. |
best_ancestor |
An optional vector representing the best ancestor to use as a basis for generating a portion of the population. If provided, this ancestor must have a non-zero gene count equal to 'aimedSpar - 1'. |
The function: 1. Determines the target sparsity ('aimedSpar') based on 'current_sparsity' or the minimum value in 'sparsity'. 2. Generates a set of dense vectors based on 'aimedSpar': - **Random Vectors**: For the general population, randomly generated with a specified probability for non-zero elements. - **Ancestor-based Vectors**: If 'best_ancestor' is provided, some population members are generated by modifying the ancestor with additional random genes.
**Sparsity Control**: Each generated vector's sparsity is adjusted to exactly match 'aimedSpar' by adding or removing non-zero elements as necessary.
A list of dense vectors representing the generated population, each with controlled sparsity.
## Not run:
clf <- list(
params = list(size_pop = 10, current_sparsity = 5, sparsity = c(3, 5, 7), perc_best_ancestor = 50)
)
size_world <- 20
best_ancestor <- sample(c(-1, 0, 1), size_world, replace = TRUE)
population <- populationDenseVec(clf, size_world, best_ancestor)
print(population)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.