random_population: Random population initialization

View source: R/RcppExports.R

random_populationR Documentation

Random population initialization

Description

Randomly generate the individuals' chromosomes (changepoint confirgurations) to construct the first generation population.

Usage

random_population(popSize, prange, N, minDist, pchangepoint, mmax, lmax)

Arguments

popSize

An integer represents the number of individual in each population for GA (or subpopulation for IslandGA).

prange

Default is NULL for only changepoint detection. If prange is specified as a list object, which contains the range of each model order parameters for order selection (integers). The number of order parameters must be equal to the length of prange.

N

The length of time series.

minDist

The minimum length between two adjacent changepoints.

pchangepoint

Same as pchangepoint from cptga or cptgaisl, the probability that a changepoint has occurred.

mmax

The maximum possible number of changepoints in the data set.

lmax

The maximum possible length of the chromosome representation.

Details

Each population can be stored in a matrix with lmax rows and popSize columns, where each column represents an individual chromosome in the format of

C = (m, \boldsymbol{s}, \boldsymbol{\tau}, N+1)',

in cptga or cptgaisl. This function can randomly initialize the population matrix with some imposed constraints, such as ensuring the number of time points between two adjacent changepoints is greater than or equal to minDist. This prevents unrealistic scenario of two changepoints being too close to each other and helps reduce the total number of admissible solutions in the search space. Users can adjust the level of searching space reduction by setting an appropriate value for minDist. During population initialization, each changepoint location in \boldsymbol{\tau} can be selected sequentially. With a specified probability pchangepoint denoting the probability of a time point being selected as a changepoint, the first changepoint \tau_{1} is randomly picked between t=1+minDist and t=N. Then \tau_{2} is randomly selected from a smaller range between t=\tau_{1}+minDist and t=N. The process is continued until the last admissible changepoint t=N-minDist is exceeded, and the number of changepoints m is obtained automatically. For added flexibility, users can specify their own population initialization function. The default population initialization uses selectTau to select the chromosome for the first generation population.

Value

A matrix that contains each individual's chromosome.


changepointGA documentation built on Nov. 5, 2025, 6:54 p.m.