Push Library in R (Simple Float Functions)

Wednesday, October 14th, 2009

Instruction set:

PushLibrary.R contains all the Push Functions made in R so far. It also sets up Floats with NaN as the original value which will be deleted as soon as the interpreter is run on the first float in the function (see NewFloat.R).

In the future this function will be automatically constructed from a text file or other output from the java pushGP regression implementation, which was constructed prior by a data set inserted into R.

Run InterpretFunction.R to run the PushGP function on a chosen x value and return a vector of numbers (object(Floats)) with the y value as the final output.

RefreshStack.R: Very important! Every time any of the functions/operators/floats are called and affect the Floats vector all the positions of the stack may change as well as the values. This simply makes sure that the objects serving as place trackers in the vector are constantly updated when a function is called.

When function interpreter sees a float put it into the Floats vector.

Example of how to run this package in the R terminal:

> setwd(”~/Desktop/AI/R/PackageFiles”);
Error: syntax error
> setwd(“~/Desktop/AI/R/PackageFiles”);
> source(“PushLibrary.R”)
> objects()
[1] “a”             “A”             “b”             “B”
[5] “C”             “FLOATadd”      “FLOATdivide”   “FLOATdup”
[9] “FLOATmultiply” “Floats”        “FLOATsubtract” “FLOATswap”
> source(“Function.R”)
> GPfunction
function(x) c(5.0, 7.0, “FLOAT.+”, “FLOAT.*”, “FLOAT.%”, “FLOAT.SWAP”, x, 6.0, “FLOAT.+”, 1.0, “FLOAT.SWAP”)
> x <- 42
> Floats
[1] NaN
> source(“InterpretFunction.R”)
Warning messages:
1: NAs introduced by coercion
2: NAs introduced by coercion
3: NAs introduced by coercion
4: NAs introduced by coercion
5: NAs introduced by coercion
6: NAs introduced by coercion
> Floats
[1] 12  1 48