convergence.test: Test for Convergence in Evolutionary Algorithm Scores

View source: R/terga1.lib.R

convergence.testR Documentation

Test for Convergence in Evolutionary Algorithm Scores

Description

This function checks for convergence in a vector of scores, identifying if there has been a stable sequence of scores over a specified number of steps. Convergence is defined as no change in score for 'steps' consecutive generations.

Usage

convergence.test(x, steps = 10)

Arguments

x

A numeric vector representing scores from successive generations in an evolutionary algorithm.

steps

An integer specifying the number of consecutive steps required with no change in score to consider the sequence as converged.

Details

The function iterates through the scores in 'x' and counts consecutive instances where there is no change in score. If the count reaches 'steps', the function returns 'TRUE', indicating convergence. If there are fewer scores in 'x' than 'steps', the function stops with an error.

**Usage in Evolutionary Algorithms**: This convergence test is useful in evolutionary algorithms to detect when further evolution is unlikely to yield improved scores, allowing the algorithm to terminate early.

Value

A logical value: 'TRUE' if convergence is detected, 'FALSE' otherwise.

Examples

## Not run: 
scores <- c(0.8, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85)
has_converged <- convergence.test(scores, steps = 5)
print(has_converged)  # Returns TRUE, as the score did not change for 5 steps

## End(Not run)


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