Running 'bnf.R' [171s]
  Running 'es.R' [1s]
  Running 'exhaustive.R' [0s]
  Running 'ga.R' [169s]
  Running 'ge.R' [3s]
  Running 'grammar_newstyle.R' [158s]
  Running 'grammar_oldstyle.R' [160s]
  Running 'grammar_sequence.R' [151s]
  Running 'randomsearch.R' [0s]
  Running 'replace_exp.R' [152s]
Running the tests in 'tests/bnf.R' failed.
Complete output:
  > # This program performs regression testing for package "gramEvol"
  > 
  > # Author: Farzad Noorian <farzad.noorian@sydney.edu.au>
  > 
  > # This program is free software, distributed under the terms of
  > # the GNU General Public License version 2.
  > # Refer to <http://www.gnu.org/licenses/> for full terms.
  > ################################################################################
  > library("gramEvol")
  > 
  > bnfGrammarDef <- CreateGrammar("test.bnf", startSymb = '<expr>')
  > stopifnot(GetGrammarNumOfExpressions(bnfGrammarDef) == 18500)
  > 
  > genome = c(2, 1, 0, 0, 3, 3, 3, 1)
  > expr = GrammarMap(genome, bnfGrammarDef)
  > stopifnot(as.character(expr) == "c1 * v1/c2 * v2")
  > stopifnot(expr$type == "T")
  > 
  > 
  > proc.time()
     user  system elapsed 
     0.21    0.10    0.26 
Running the tests in 'tests/ga.R' failed.
Complete output:
  > # This program performs regression testing for package "gramEvol"
  > 
  > # Author: Farzad Noorian <farzad.noorian@sydney.edu.au>
  > 
  > # This program is free software, distributed under the terms of
  > # the GNU General Public License version 2.
  > # Refer to <http://www.gnu.org/licenses/> for full terms.
  > ################################################################################
  > library("gramEvol")
  > 
  > set.seed(0)
  > 
  > odd <- seq(1, 20, 2)
  > even <- seq(2, 20, 2)
  > evalfunc <- function(l) {
  +     err <- sum(l[even]) - sum(l[odd]);
  + 
  +     stopifnot(!any(duplicated(l)))
  + 
  +     return (err)
  + }
  > 
  > x <- GeneticAlg.int(genomeLen = 20, codonMin = 0, codonMax = 20,
  +                 allowrepeat = FALSE, terminationCost = -110,
  +                 monitorFunc = NULL, evalFunc = evalfunc)
  > 
  > best.result <- x$best$genome
  > 
  > stopifnot(sort(best.result[odd]) == 11:20)
  > stopifnot(sort(best.result[even]) == 0:9)
  > 
  > 
  > proc.time()
     user  system elapsed 
     0.42    0.09    0.50 
Running the tests in 'tests/grammar_newstyle.R' failed.
Complete output:
  > # This program performs regression testing for package "gramEvol"
  > 
  > # Author: Farzad Noorian <farzad.noorian@sydney.edu.au>
  > 
  > # This program is free software, distributed under the terms of
  > # the GNU General Public License version 2.
  > # Refer to <http://www.gnu.org/licenses/> for full terms.
  > ################################################################################
  > 
  > library("gramEvol")
  > 
  > ruleDef <- list(
  +   expr = gsrule("<expr><op><expr>", "<coef> * <var>"),
  +   op   = gsrule("+", "-", "*", "/"),
  +   coef = grule(c1, c2),
  +   var  = grule(v1, v2)
  + )
  > 
  > grammarDef <- CreateGrammar(ruleDef)
  > 
  > stopifnot(grammarDef$def[[1]][[2]][[1]] == "<expr><op><expr>")
  > stopifnot(grammarDef$def[[2]][[2]][[1]] == "+")
  > 
  > grammarDef
  <expr> ::= <expr><op><expr> | <coef> * <var>
  <op>   ::= + | - | * | /
  <coef> ::= c1 | c2
  <var>  ::= v1 | v2
  > ################
  > rule.cat = c(ruleDef$expr, ruleDef$op, ruleDef$coef)
  > stopifnot("GERule" %in% class(rule.cat) )
  > stopifnot(length(rule.cat) == 8)
  > ################
  > stopifnot(GrammarGetDepth(grammarDef) == 4)
  > stopifnot(GrammarGetDepth(grammarDef, max.depth=10) == 10)
  > ################
  > ruleDef2 <- list(
  +   expr =    grule(op(subexpr, subexpr)),
  +   subexpr = grule(coef * var, sqrt(var)),
  +   op   =    grule(`+`, `-`, `*`, `/`),
  +   coef =    grule(c1, c2),
  +   var  =    grule(v1, v2)
  + )
  > 
  > grammarDef2 <- CreateGrammar(ruleDef2, startSymb = '<expr>')  		   
  > 
  > stopifnot(GrammarGetDepth(grammarDef2) == 3)
  > ################
  > ruleDef3 <- list(
  +   start = grule(rbind(cbind(var, var), cbind(var, var)), cbind(var, var)),
  +   op =    grule(`+`, 'a', `>`),
  +   var =   grule(x, y, z)
  + )  
  > 
  > grammarDef3 = CreateGrammar(ruleDef3)
  > stopifnot(grammarDef3$def[[1]][[2]][[1]] == "rbind(cbind(<var>, <var>), cbind(<var>, <var>))")
  > stopifnot(grammarDef3$def[[2]][[2]][[1]] == "`+`")
  > stopifnot(grammarDef3$def[[2]][[2]][[2]] == "\"a\"")
  > stopifnot(grammarDef3$startSymb == "<start>")
  > ################
  > stopifnot(GrammarGetDepth(grammarDef2, startSymb = "<subexpr>") == 2)
  > stopifnot(GrammarGetDepth(grammarDef2, startSymb = "<coef>") == 1)
  > ################
  > stopifnot(GrammarMaxRuleSize(grammarDef) == 4)
  > ################
  > stopifnot(GrammarNumOfExpressions(grammarDef) == 18500)
  > stopifnot(GrammarNumOfExpressions(grammarDef, max.depth = 2) == 4)
  > stopifnot(GrammarNumOfExpressions(grammarDef, max.depth = 3) == 68)
  > stopifnot(GrammarNumOfExpressions(grammarDef, startSymb = "<coef>") == 2)
  > ################
  > stopifnot(GrammarMaxSequenceLen(grammarDef) == 18)
  > stopifnot(GrammarMaxSequenceLen(grammarDef2, startSymb = "<subexpr>") == 3)
  > ################
  > stopifnot(GrammarMaxSequenceLen(grammarDef, max.depth = 3) == 8)
  > ################
  > genome = c(2, 1, 0, 0, 3, 3, 3, 1)
  > expr = GrammarMap(genome, grammarDef)
  > stopifnot(expr$type == "T")
  > stopifnot(GrammarIsTerminal(expr))
  > stopifnot(as.character(expr) == "c1 * v1/c2 * v2")
  > ################
  > inputString = c(0) # a recursive example
  > expr2 = GrammarMap(inputString, grammarDef, wrapping=2)
  > stopifnot(expr2$expr == "<expr><op><expr><op><expr>")
  > stopifnot(expr2$type == "NT")
  > stopifnot(GrammarIsTerminal(expr2) == FALSE)
  > ################
  > stopifnot(GrammarIsRecursive(grammarDef, "<expr>"))
  > stopifnot(!GrammarIsRecursive(grammarDef, "<op>"))
  > stopifnot(!GrammarIsRecursive(grammarDef2))
  > ################
  > string = as.expression(expr)
  > 
  > c1 = 1
  > c2 = 2
  > v1 = 3
  > v2 = 4
  > r1 = eval(string)
  > stopifnot(r1 == 6)
  > ################
  > df = data.frame(c1 = c(1,2),
  +                 c2 = c(2,3),
  +                 v1 = c(3,4),
  +                 v2 = c(4,5))
  > 
  > expressions = list(as.expression(expr), quote(c1 * v2))
  > r2 = lapply(expressions, eval, envir = df)
  > stopifnot(dim(r2) == c(2,2))
  > stopifnot(colnames(r2) == c("expr1","expr2"))
  > stopifnot(r2$expr1[1] == 6)
  > stopifnot(r2$expr1[2] * 3 == 40)
  > stopifnot(r2$expr2 == c(4,10))
  > ################
  > vrule = gvrule(1:10)
  > stopifnot(length(vrule) == 10)
  > stopifnot(all(as.vector(vrule) == 1:10))
  > 
  > 
  > 
  > proc.time()
     user  system elapsed 
     0.78    0.09    0.84 
Running the tests in 'tests/grammar_oldstyle.R' failed.
Complete output:
  > # This program performs regression testing for package "gramEvol"
  > 
  > # Author: Farzad Noorian <farzad.noorian@sydney.edu.au>
  > 
  > # This program is free software, distributed under the terms of
  > # the GNU General Public License version 2.
  > # Refer to <http://www.gnu.org/licenses/> for full terms.
  > ################################################################################
  > 
  > library("gramEvol")
  > 
  > ruleDef <- list(list('<expr>',     list('<expr><op><expr>', '<coef>*<var>')),
  +                 list('<op>',       list('+', '-', '*', '/')),
  +                 list('<coef>',     list('c1', 'c2')),
  +                 list('<var>',      list('v1', 'v2')))
  > 
  > grammarDef <- CreateGrammar(ruleDef, startSymb = '<expr>')			   
  > 
  > grammarDef
  <expr> ::= <expr><op><expr> | <coef>*<var>
  <op>   ::= + | - | * | /
  <coef> ::= c1 | c2
  <var>  ::= v1 | v2
  > ################
  > stopifnot(GetGrammarDepth(grammarDef) == 4)
  > stopifnot(GetGrammarDepth(grammarDef, max.depth=10) == 10)
  > ################
  > 
  > ruleDef2 <- list(list('<expr>',    list('<subexpr><op><subexpr>')),
  +                  list('<subexpr>', list('<coef>*<var>', 'sqrt(<var>)')),
  +                  list('<op>',      list('+', '-', '*', '/')),
  +                  list('<coef>',    list('c1', 'c2')),
  +                  list('<var>',     list('v1', 'v2')))
  > 
  > grammarDef2 <- CreateGrammar(ruleDef2, startSymb = '<expr>')			   
  > 
  > stopifnot(GetGrammarDepth(grammarDef2) == 3)
  > ################
  > stopifnot(GetGrammarDepth(grammarDef2, startSymb = "<subexpr>") == 2)
  > stopifnot(GetGrammarDepth(grammarDef2, startSymb = "<coef>") == 1)
  > ################
  > stopifnot(GetGrammarMaxRuleSize(grammarDef) == 4)
  > ################
  > stopifnot(GetGrammarNumOfExpressions(grammarDef) == 18500)
  > stopifnot(GetGrammarNumOfExpressions(grammarDef, max.depth = 2) == 4)
  > stopifnot(GetGrammarNumOfExpressions(grammarDef, max.depth = 3) == 68)
  > stopifnot(GetGrammarNumOfExpressions(grammarDef, startSymb = "<coef>") == 2)
  > ################
  > stopifnot(GetGrammarMaxSequenceLen(grammarDef) == 18)
  > stopifnot(GetGrammarMaxSequenceLen(grammarDef2, startSymb = "<subexpr>") == 3)
  > ################
  > stopifnot(GetGrammarMaxSequenceLen(grammarDef, max.depth = 3) == 8)
  > ################
  > genome = c(2, 1, 0, 0, 3, 3, 3, 1)
  > expr = GrammarGenotypeToPhenotype(genome, grammarDef)
  > stopifnot(expr$expr == "c1*v1/c2*v2")
  > stopifnot(expr$type == "T")
  > ################
  > inputString = c(0) # a recursive example
  > expr2 = GrammarGenotypeToPhenotype(inputString, grammarDef, wrapping=2)
  > stopifnot(expr2$expr == "<expr><op><expr><op><expr>")
  > stopifnot(expr2$type == "NT")
  > ################
  > string = expr$expr
  > 
  > c1 = 1
  > c2 = 2
  > v1 = 3
  > v2 = 4
  > r1 = eval(parse(text = string))
  > stopifnot(r1 == 6)
  > ################
  > df = data.frame(c1 = c(1,2),
  +                 c2 = c(2,3),
  +                 v1 = c(3,4),
  +                 v2 = c(4,5))
  > 
  > expressions = list(expr, "c1 * v2")
  > r2 = EvalExpressions(expressions, envir = df)
  > stopifnot(dim(r2) == c(2,2))
  > stopifnot(colnames(r2) == c("expr1","expr2"))
  > stopifnot(r2$expr1[1] == 6)
  > stopifnot(r2$expr1[2] * 3 == 40)
  > stopifnot(r2$expr2 == c(4,10))
  > 
  > 
  > proc.time()
     user  system elapsed 
     0.68    0.07    0.73 
Running the tests in 'tests/grammar_sequence.R' failed.
Complete output:
  > library("gramEvol")
  > 
  > ruleDef <- list(
  +   expr     = grule(coeff * expr, coeff * var, var, var + var),
  +   var      = grule(A, B),
  +   coeff    = grule(c1, c2, c3))
  > 
  > # Creating the grammar object
  > grammar <- CreateGrammar(ruleDef) 
  > 
  > max.range <- GrammarMaxSequenceRange(grammar)
  > stopifnot(all(max.range == c(4,3,4,3,4,3,2)))
  > 
  > num.expr <- GrammarNumOfExpressions(grammar)
  > stopifnot(num.expr == 156)
  > 
  > # first sequence
  > genome <- GrammarGetNextSequence(grammar)
  > stopifnot(all(genome == c(0,0,0,0,1,0,0)))
  > 
  > genome <- GrammarGetNextSequence(grammar, genome)
  > stopifnot(all(genome == c(0,0,0,0,1,0,1)))
  > 
  > # start in a loop
  > genome <- NULL
  > cnt <- 0
  > for (i in 1:num.expr) {
  +   genome <- GrammarGetNextSequence(grammar, genome)
  +   stopifnot(!is.GrammarOverflow(genome))
  +   stopifnot(genome < max.range[1:length(genome)])
  +   cnt <- cnt + 1
  + }
  > stopifnot(all(genome == c(3,1,1)))
  > stopifnot(cnt == num.expr)
  > 
  > # next one should be overflow
  > genome <- GrammarGetNextSequence(grammar, genome)
  > stopifnot(is.GrammarOverflow(genome))
  > 
  > proc.time()
     user  system elapsed 
     3.32    1.04    4.34 
Running the tests in 'tests/replace_exp.R' failed.
Complete output:
  > library("gramEvol")
  > 
  > is.expr.eq <- function(x, y) {
  +   identical(as.character(x), as.character(y))
  + }
  > 
  > 
  > expr = expression(function(x) {
  +   cbind(f1(x),
  +         f2(x),
  +         g3(y))
  + })
  > 
  > 
  > r0 = ReplaceInExpression(expr, bquote(y), function(x) { bquote(x) })
  > stopifnot(is.expr.eq(r0, expression(function(x) { cbind(f1(x), f2(x), g3(x)) })))
  > 
  > r1 = ReplaceInExpression(expr, bquote(f2), function(x) {NULL})
  > stopifnot(is.expr.eq(r1, expression(function(x) { cbind(f1(x), NULL, g3(y)) })))
  > 
  > r2 = ReplaceInExpression(expr, bquote(f2), function(x) {bquote(f2(y))})
  > stopifnot(is.expr.eq(r2, expression(function(x) { cbind(f1(x), f2(y), g3(y)) })))
  > 
  > r3 = ReplaceInExpression(expr, bquote(g3), function(x) {bquote(f3(x))})
  > stopifnot(is.expr.eq(r3, expression(function(x) { cbind(f1(x), f2(x), f3(x)) })))
  > 
  > 
  > r4 = ReplaceInExpression(expr, bquote(g3), function(x, b) {if (b > 1) x else NULL}, b = 0)
  > stopifnot(is.expr.eq(r4, expression(function(x) { cbind(f1(x), f2(x), NULL) })))
  > 
  > r5 = ReplaceInExpression(expr, bquote(g3), function(x, b) {if (b > 1) x else NULL}, b = 3)
  > stopifnot(is.expr.eq(r5, expression(function(x) { cbind(f1(x), f2(x), g3(y)) })))
  > 
  > proc.time()
     user  system elapsed 
     0.20    0.07    0.26