Utilities
Since version v2.1, EvoLP.jl now includes some utilities and metrics that may come in handy when working with evolutionary algorithms.
Bitstring and Binary Utilities
Although many algorithms, operators, and functions in EvoLP work well with bitstrings created from 0s and 1s using Vector{Int} representation, it is much more efficient to work on Boolean vectors (or BitVector <: BitArray).
To convert these individuals to BitVector, we provide a convenient function, force_boolean.
EvoLP.force_boolean — Function
force_boolean(x::AbstractVector{Integer})Convert an integer-based individual into a BitArray. Most binary utilities are more efficient on BitArrays.
The following utilities are efficient on individuals of type BitVector:
EvoLP.ind2dec — Function
ind2dec(x::AbstractVector{Bool})Return the decimal representation of a bitstring x.
EvoLP.ind2str — Function
ind2str(x::AbstractVector{Bool})Convert a bitstring x into its textual representation.
EvoLP.dec2ind — Function
dec2ind(n::Int; pad::Int = 1)Return the bitstring representation of an integer n, optionally padded with zeros until reaching a size pad.
EvoLP.str2ind — Function
str2ind(x::String)Convert a textual bitstring x to its boolean representation.
EvoLP.get_neighbourhood — Function
get_neighbourhood(x::AbstractVector{Bool})
get_neighbourhood(n::Integer; pad=1)Return all neighbours of an individual x. If x is a bitstring, it returns the neighbourhood as bitstrings. If x is a natural number, it returns integers (e.g., indices to extract from a sorted array)
EvoLP.get_neighbourhood_ixs — Function
get_neighbourhood_ixs(x::AbstractVector{Bool})Return a list of the decimal representations of all neighbours of an individual x, for example, to use as indices to extract from a sorted array or lookup table.
EvoLP.global_entropy — Function
global_entropy(population::AbstractVector{AbstractVector{Bool}})Returns the global Shannon entropy of the population, which is a measurement of how similar Boolean individuals are:
\[\text{H}(X) = - \sum_{x \in \{0, 1\}} p(x) \log_2 p(x).\]