individual_vec_v1: Generate a Sparse Individual Vector for Evolutionary...

View source: R/terga2.lib.R

individual_vec_v1R Documentation

Generate a Sparse Individual Vector for Evolutionary Computation

Description

This function generates an individual vector representation for evolutionary algorithms. The vector is generated with specified sparsity, based on binary or ternary language, depending on the configuration in the classifier object ('clf').

Usage

individual_vec_v1(clf, signs = NULL)

Arguments

clf

A classifier object containing parameters that guide the vector generation, including 'language', 'size_world', 'sparsity.mean', 'sparsity.min', and 'sparsity.max'.

signs

An optional vector of signs used to set or adjust the values in the generated individual vector. Defaults to NULL.

Details

The function creates a vector of length 'clf$params$size_world', with elements initialized based on a specified probability distribution. For binary language, the vector elements are either 1 or 0, while for ternary language, they can be -1, 0, or 1. The function ensures that the vector respects specified minimum and maximum sparsity levels ('clf$params$sparsity.min' and 'clf$params$sparsity.max'), adjusting the number of non-zero elements as needed.

Value

A numeric vector of length 'clf$params$size_world', representing an individual with the desired sparsity and language settings.

Examples

## Not run: 
clf <- list(params = list(language = "ternary", size_world = 100, sparsity.mean = 0.1, sparsity.min = 5, sparsity.max = 20))
individual <- individual_vec_v1(clf)

## End(Not run)


predomics/predomicspkg documentation built on Dec. 11, 2024, 11:06 a.m.