individual_vec_v3: Generate Sparse Individual Vector with Indices and...

View source: R/terga2.lib.R

individual_vec_v3R Documentation

Generate Sparse Individual Vector with Indices and Coefficients

Description

This function generates a sparse individual vector representation for evolutionary algorithms, returning a list with the indices and coefficients of non-zero elements. The values and sparsity level are based on the parameters defined in a classifier object ('clf').

Usage

individual_vec_v3(clf, signs = NULL)

Arguments

clf

A classifier object containing parameters for generating the vector, including 'size_world', 'sparsity.min', 'sparsity.max', and 'language'.

signs

An optional vector of signs (not used in this function but included for consistency with other versions).

Details

The function randomly selects a number of non-zero elements within the range specified by 'sparsity.min' and 'sparsity.max'. It then assigns values to these elements based on 'clf$params$language': for binary language, only 1s are used; for ternary language, values are -1 or 1.

Value

A list with two elements:

indices

A vector of indices corresponding to non-zero elements in the generated vector.

coeffs

A vector of coefficients (1 or -1) at the specified indices.

Examples

## Not run: 
clf <- list(params = list(language = "ternary", size_world = 50, sparsity.min = 5, sparsity.max = 15))
individual <- individual_vec_v3(clf)
print(individual)

## End(Not run)


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