mutate_binary_sequence {gor}R Documentation

Binary sequence mutation

Description

Mutation of binary sequences for use in the genetic algorithm

Usage

mutate_binary_sequence(s, p = 0.1)

Arguments

s

Sequence consisting of 0 and 1

p

Mutation probability. Defaults to 0.1

Details

This routine takes a binary sequence and it flips ("mutates") each bit with a fixed probability. In the genetic algorithm context, this operation randomly explores regions of configuration space which are far away from the starting point, thus trying to avoid local optima. The fitting function values of mutated individuals are generically very poor, and this behavior is to be expected. Thus, mutation is not an optimization procedure per se.

Value

A mutated binary sequence

Author(s)

Cesar Asensio

See Also

search_cut_genetic genetic cut-searching algorithm, crossover_sequences crossover operation

Examples

set.seed(1)
s <- sample(0:1, 10, replace = TRUE)  # 0 0 1 1 0 1 1 1 1 0
mutate_binary_sequence(s, p = 0.5)    # 1 1 1 0 0 0 1 1 0 0
mutate_binary_sequence(s, p = 1)      # 1 1 0 0 1 0 0 0 0 1


[Package gor version 1.0 Index]