Learn R Programming

xegaDerivationTrees (version 1.0.0.6)

Generating and Manipulating Derivation Trees

Description

Derivation tree operations are needed for implementing grammar-based genetic programming and grammatical evolution: Generating a random derivation trees of a context-free grammar of bounded depth, decoding a derivation tree, choosing a random node in a derivation tree, extracting a tree whose root is a specified node, and inserting a subtree into a derivation tree at a specified node. These operations are necessary for the initialization and for decoders of a random population of programs, as well as for implementing crossover and mutation operators. Depth-bounds are guaranteed by switching to a grammar without recursive production rules. For executing the examples, the package 'BNF' is needed. The basic tree operations for generating, extracting, and inserting derivation trees as well as the conditions for guaranteeing complete derivation trees have been presented in Geyer-Schulz (1997, ISBN:978-3-7908-0830-X). The use of random integer vectors for the generation of derivation trees has been introduced in Ryan, C., Collins, J. J., and O'Neill, M. (1998) for grammatical evolution.

Copy Link

Version

Install

install.packages('xegaDerivationTrees')

Monthly Downloads

199

Version

1.0.0.6

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Andreas Geyer-Schulz

Last Published

April 16th, 2025

Functions in xegaDerivationTrees (1.0.0.6)

newE

Returns empty data frame for edges.
decodeSymVec

Decodes a vector of symbols.
generateDerivationTree

Generates a derivation tree from an integer vector.
leavesIncompleteDT

Returns the list of symbol identifiers of the leaves of a derivation tree.
generateCDT

Generates a complete derivation tree from an integer vector.
decodeDTsym

Decodes a derivation tree into a list of the leaf symbols of the derivation tree.
newV

Returns empty data frame for vertices.
substituteSymbol

Codes the substitution of a non-terminal symbol by the symbols derived by a production rule as a nested list.
testGenerateDerivationTree

Generate, decode, and show times derivation trees from random integer vectors for grammar BNF on the console.
rndsubk

Transforms a non-terminal symbol into a 1-level derivation tree for a given k.
rndsub

Transforms a non-terminal symbol into a random 1-level derivation tree.
filterANLid

Filter an Attributed Node List (ANL) of a derivation tree by a symbol identifier.
printDerivations

Print derivations.
treeChildren

Returns the children of a derivation tree.
treeANL

Builds an Attributed Node List (ANL) of a derivation tree.
treeListDepth

Measures the depth of a (nested) list.
treeLeaves

Measures the number of leaves of a complete derivation tree.
treeToDataFrames

Convert a tree to two dataframes.
xegaDerivationTrees

Package xegaDerivationTrees
randomDerivationTree

Generates a random derivation tree.
rndPartition

Randomly partitions n in k parts.
treeNodes

Measures the number of inner nodes in a derivation tree.
treeRoot

Returns the root of a derivation tree.
treeProbability

The (path) probability of generating tree by grammar G.
treeSize

Measures the number of symbols in a derivation tree.
treeExtract

Extracts the subtree at position pos in a derivation tree.
treeInsert

Inserts a subtree into a derivation tree at a node.
chooseRule

Selects a production rule index at random from a vector of production rules.
compatibleSubtrees

Test the compatibility of subtrees.
addV

Add a vertex to the data frame for vertices.
chooseNode

Randomly selects an attributed node in an attributed node list.
compileBNF

Compile a BNF (Backus-Naur Form) of a context-free grammar.
booleanGrammar

A constant function which returns the BNF (Backus-Naur Form) of a context-free grammar for the XOR problem.
decodeCDT

Converts a complete derivation tree into a program.
decodeAndFixDT

Decodes (and completes) a derivation tree into a working program.
chooseRulek

Selects k-th production rule index from a vector of production rules.
addE

Add an edge or a list of edges to the data frame for edges.
decodeDT

Decodes a derivation tree into a program.
decodeTree

Returns a list of all symbols of a derivation tree in depth-first left-to-right order.
filterANL

Filter an Attributed Node List (ANL) of a derivation tree by depth.