NewEnvXOR: Generate the problem environment EnvXOR

View source: R/sgpProblems.R

NewEnvXORR Documentation

Generate the problem environment EnvXOR

Description

NewEnvXOR() generates the problem environment for the XOR-Problem.

The problem environment provides an abstract interface to the simple genetic programming algorithm. ProblemEnv$f(parm) defines the function we want to optimize.

A problem environment is a function factory with the following elements:

  1. name(): A string with the name of the environment.

  2. ProblemEnv$f(word): Function with the word a word of the language (as a text string).

Should be provided by the user as a standard R-file.

Usage

NewEnvXOR()

Value

The problem environment:

  • $name: The name of the problem environment.

  • $f: The fitness function. For this environment, fitness is defined as the number of correct test cases (correct function) and the inverse of the number of terminal symbols. The second part means that a boolean function with a fewer number of variables and logical functions is fitter than one with more variables and logical functions if both solve the same number of test cases.

See Also

Other Problem Environment: Parabola2D, Parabola2DEarly, lau15

Examples

EnvXOR<-NewEnvXOR()
EnvXOR$name()
a2<-"OR(OR(D1, D2), (AND(NOT(D1), NOT(D2))))"
a3<-"OR(OR(D1, D2), AND(D1, D2))"
a4<-"AND(OR(D1,D2),NOT(AND(D1,D2)))"
gp4<-"(AND(AND(OR(D2,D1),NOT(AND(D1,D2))),(OR(D2,D1))))"
EnvXOR$f(a2)
EnvXOR$f(a3)
EnvXOR$f(a4)
EnvXOR$f(gp4)


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

Related to NewEnvXOR in xega...