xega: Package xega

xegaR Documentation

Package xega

Description

The main program of the e(x)tended (e)volutionary and (g)enetic (a)lgorithm (xega) package.

Layers (in top-down direction)

  1. Top-level main programs (Package xega <https://CRAN.R-project.org/package=xega>): xegaRun(), xegaReRun()

  2. Population-level operations - independent of representation (Package xegaPopulation <https://CRAN.R-project.org/package=xegaPopulation>): The population layer consists of functions for initializing, logging, observing, evaluating a population of genes, as well as computing the next population.

  3. Gene-level operations - representation-dependent.

    1. Binary representation (Package xegaGaGene <https://CRAN.R-project.org/package=xegaGaGene>): Initialization of random binary genes, several gene maps for binary genes, several mutation operators, several crossover operators with 1 and 2 kids, replication pipelines for 1 and 2 kids, and, last but not least, function factories for configuration.

    2. Real-coded genes (Package xegaDfGene <https://CRAN.R-project.org/package=xegaDfGene>).

    3. Permutation genes (Package xegaPermGene <https://CRAN.R-project.org/package=xegaPermGene>).

    4. Derivation-tree genes (Package xegaGpGene <https://CRAN.project.org/package=xegaGpGene>).

    5. Binary genes with a grammar-driven decoder (Package xegaGeGene <https://CRAN.project.org/package=xegaGeGene>).

  4. Gene-level operations - independent of representation (Package xegaSelectGene <https://CRAN.project.org/package=xegaSelectGene>). Functions for static and adaptive fitness scaling, gene selection, gene evaluation, as well as measuring performance and configuration.

Early Termination

A problem environment may implement a function terminate(solution) which returns TRUE if the solution meets a condition for early termination.

Genetic Operator Pipelines

In xega the extended gene life-cycle is:

  • (sequential) ... -> gene (data structure) -> select -> replicate(crossover -> mutate -> accept)

  • (parallelizable) -> decode -> evaluate -> gene (data structure) -> ...

Only the decode -> evaluate phase can be parallelized. The select -> crossover -> mutate -> accept phases are executed sequentially. For algorithms which require e.g. evaluation during the accept phase (simulated annealing variants), this organization implies that the improvement by parallel or distributed execution models is negligible.

A genetic operator pipeline embeds the crossover -> mutate -> accept -> decode -> evaluate phases into a function closure per gene. The evaluation of a population of genes can be evaluated in parallel with potentially high reductions in total run-time.

The gene life-cycle with genetic operator pipelines in xega is:

  • (sequential) ... -> gene (data structure) -> select -> replicate pipeline -> gene (function closure)

  • (parallelizable) -> evaluate -> gene (data structure) ...

This shifts the execution of the crossover -> mutate -> accept -> decode -> evaluate phases to the parallizable evaluation of a function closure.

Parallel and Distributed Execution

Several implementations of a parallel lapply() function are provided. They support the parallel and distributed execution of fitness functions on several combinations of hard- and software architectures. A parallel lapply()-function must have the following abstract interface:

parallelApply(pop, EvalGene, lF)

where pop is a list of genes, EvalGene the evaluation function for the fitness of a gene, and lF the local function configuration of the algorithm.

The several implementations of a parallelApply() function are provided. The implementations use

  • the function parallel::mclapply() for multi-core parallelization by the fork mechanism of Unix-based operating systems on a single machine.

  • the function parallel::parLapply() for socket connections on a single or multiple machines on the Internet.

  • the function future.apply::future_lapply() for asynchronous parallelization based on future packages.

In addition, user-defined parallel apply functions can be provided. Example scripts for using the Rmpi::mpi.parLapply() function of the Rmpi package are provided for an HPC environment with Slurm as well as on a notebook.

The Architecture of the xegaX-Packages

The xegaX-packages are a family of R-packages which implement e(x)tended (e)volutionary and (g)enetic (a)lgorithms (xega). The architecture has 3 layers, namely the user interface layer, the population layer, and the gene layer:

  • The user interface layer (package xega <https://CRAN.R-project.org/package=xega> ) provides a function call interface and configuration support for several algorithms: genetic algorithms (sga), permutation-based genetic algorithms (sgPerm), derivation-free algorithms as e.g. differential evolution (sgde), grammar-based genetic programming (sgp), and grammatical evolution (sge).

  • The population layer (package xegaPopulation <https://CRAN.R-project.org/package=xegaPopulation> ) contains population-related functionality as well as support for population statistics dependent adaptive mechanisms and for parallelization.

  • The gene layer is split into a representation-independent and a representation-dependent part:

    1. The representation-independent part (package xegaSelectGene <https://CRAN.R-project.org/package=xegaSelectGene> ) is responsible for variants of selection operators, evaluation strategies for genes, as well as profiling and timing capabilities.

    2. The representation-dependent part consists of the following packages:

      • xegaGaGene <https://CRAN.R-project.org/package=xegaGaGene> for binary-coded genetic algorithms.

      • xegaPermGene <https://CRAN.R-project.org/package=xegaPermGene> for permutation-based genetic algorithms.

      • xegaDfGene <https://CRAN.R-project.org/package=xegaDfGene> for derivation-free algorithms e.g. differential evolution.

      • xegaGpGene <https://CRAN.R-project.org/package=xegaGpGene> for grammar-based genetic algorithms.

      • xegaGeGene <https://CRAN.R-project.org/package=xegaGaGene> for grammatical evolution algorithms.

      The packages xegaDerivationTrees and xegaBNF support the packages xegaGpGene and xegaGeGene:

      • xegaBNF <https://CRAN.R-project.org/package=xegaBNF> essentially provides a grammar compiler and

      • xegaDerivationTrees <https://CRAN.R-project.org/package=xegaDerivationTrees> an abstract data type for derivation trees.

Copyright

(c) 2023 Andreas Geyer-Schulz

License

MIT

URL

https://github.com/ageyerschulz/xega

Installation

From CRAN by install.packages('xega')

Author(s)

Andreas Geyer-Schulz

See Also

Useful links:


xega documentation built on Feb. 17, 2026, 5:07 p.m.

Related to xega in xega...