Archive for the 'Uncategorized' Category

Advertisement PshR

Wednesday, December 2nd, 2009

WebPages that display GP Tools, and would probably display PshRSymbolicRegression

1) Jaime Fernandez

2) John R. Koza
OFFICE PHONE: 650-960-8180
(This webpage already includes Lee Spector’s Push Language)

R users venues that would be interested in learning about the new package

1)                                                                                                   “This is the new blog from REvolution Computing, dedicated to news and information of interest to members of the R community.  We’ll focus mainly on news directly about R: announcements about new releases and packages…”
2)                                                                                            R-Journal articles can include an introduction to new packages
3) Send out an email to the R-mailing list: (must register to the list-serve first)
4) Post package on CRAN (

But before the package can become the new hot thing, we just need to finalize the package…


PS: I have been working on formalizing what we have so far into a package that can be submitted to CRAN. Me and Dan met up yesterday and worked out some of the bugs that were happening when I tried to build the tarball. We finally were able to build it and I have filled in many of the necessary help files, description files, NAMEFILES and other necessary package files. Dan is adding and streamlining a few important things (such as adding categorical data, and more than two variables)   and then we can finalize the package.

R User Manual (low usability)

Wednesday, November 11th, 2009

I wrote a few more pieces of code in R and worked to allow a R user to use PushGP to evolve a push formula for their data and return dependent variable results upon input of any independent variable. Once they download the package they will only have to work through the R console. So far the manual probably has too many steps (although some are necessary if they want to control the parameters), and hence the usability should be further streamlined. Ultimately there should only be 3 steps: 1) insert data, 2) call a function on your data (and change parameters if wanted) that does all the steps necessary to return a PushGP function and the correlation coefficient (or related fitness value), and 3) input any independent variables to see the resulting dependent variable.

Here is how the R manual looks (although it may be totally different as Dan is working on something that may change how the whole R PushGP information transfer works):

Instructions for Users:

1) Load your data into R under these two variables:

2) Create the file to format your data and parameters:
a) navigate to the directory which holds user files:
> setwd(“~/Desktop/AI/R/PackageFiles/UserFiles”);

b) source setParameters.R
> source(“setParameters.R”);
Configuration file will automatically be saved in the UserFiles folder as MyData.txt


here are the user options (defining them is optional):
> MyParameters <- SetParameters(Population Size, Execution Limit, Tournament Size, Mutation Rate, Crossover Percentage, Maximum Generations, Maximum Code Size, Mutation Range, Push Function Set)
here is an example of setting the parameters (the predefined parameters):
> MyParameters <- SetParameters(2000, 80, 7, 20, 70, 200, 40, .3, “FLOAT.* FLOAT.+ FLOAT.% FLOAT.DUP FLOAT.- FLOAT.SWAP FLOAT.ERC”);

Now you must export the new parameters as a configuration file:
> write(MyParameters, file = “~/Desktop/AI/R/PackageFiles/UserFiles/MyData.txt”)

Your data and parameters will be routed to PshGP (done) and your Push Function will be returned. *needs to be done* (it should be returned in the format shown in the file Function.R).

3) Now you can see the function and get Y Values for any given X Value:
> source(“RunningPushFunction.R”);
a) put in the x-value you want the y-value for, ie:
> x <- 42
b) run the function on it:
> source(“InterpretFunction.R”);
c) Display the answers (the last number in the list returned is your answer)
> Floats

Multiple inputs

Wednesday, October 28th, 2009

This week I was able to mess around in Psh enough to figure out how to return the push program with the best fitness, which was a big hump for a while. Now me and Jeremy are working on looking to how we want move forward. One large hurdle is how we can impliment categorical and ordinal variables as well as the quantitative ones we’re looking at now.

setting PshGP user definable parameters in R

Friday, October 23rd, 2009

In order to set user definable parameters in R that can be read in Java I have made the exact text that the java PshGP uses to configure the linear regression GP in R. This text is separated in a function with all the aspects of the text that are user definable (such as data input) as variables in the function. Hence users will only have to do SetParameters(…) and fill in any specifics they want to change, or let it run at default.

##Data Formatting (They would set Xdata and Ydata as their own data)
Xdata <- c(1,2,3,4);
Ydata <- c(2,4,6,8);
XYdata <- cbind(Xdata,Ydata);
DataFormatted <- cbind(Xdata,Ydata);
for (i in 1:length(Ydata))
FirstParenth <- c(“( “);
LastParenth <- c(” )”);
DataFormatted[i,1] <- paste(FirstParenth, DataFormatted[i,1]);
DataFormatted[i,2] <- paste(DataFormatted[i,2], LastParenth);
DataForm <- paste(DataFormatted[1:i,1], DataFormatted[1:i,2]);
Data <- (“(“);
for (i in 1:length(DataForm))
Data1 <- DataForm[i];
Data <- paste(Data,Data1);

## making user definable
SetParameters <- function(Pop=2000, Exec=80, Tourn=7, Mut=20, Cross=70, Gen=200, Code=40, Fair=.3,
## Random Comments, formatting and Text preservation
TextIntro <- c(“\n#\n# A sample PushGP file for a simple test symbolic regression problem.# In this demo, the system solves the equation y = 12x^2 + 5.\n#\n# Jon Klein <jk [at]>\n# 06/14/2008\n#\n\n### We can optionally read in some additional parameters\ninclude standard.pushgp\n\n### Setup some standard GP parameters\n\npopulation-size =”);
TextIntro2 <- c(“\n\n### The problem class determines how test cases are setup and\n### how fitness scores are computed.  The FloatSymbolicRegression\n### class uses a set of float inputs and a single output.\n\nproblem-class\t\t=org.spiderland.Psh.FloatSymbolicRegression\n\ntest-cases\t\t= “);
TextIntro3 <- c(“)\n\n### Other possible ways of defining test cases\n\n# test-case-class \t= Problem1Generator\t# at runtime from code\n# test-case-xml\t\t= Problem1.xml\t\t# from an XML file\n# test-case-csv\t\t= Problem1.csv\t\t# from a comma separated value file\n\ninstruction-set = ( “);
TextIntro4 <- c(“))”);
TextExecLimit <- c(“\nexecution-limit         = “);
TextTournSize <- c(“\ntournament-size         = “);
TextMutPerc <- c(“\nmutation-percent        = “);
TextCrossOver <- c(“crossover-percent       = “);
TextGenerations <- c(“\nmax-generations         = “);
TextCodeSize <- c(“\nmax-random-code-size    = “);
TextFairMut <- c(“fair-mutation-range     =”);
## Evolution Parameters user determined (or not)
Population <- Pop;
ExecLimit <- Exec;
TournSize <- Tourn;
MutPerc <- Mut;
CrossOver <- Cross;
Generations <- Gen;
CodeSize <- Code;
FairMut    <- Fair;
FunctSet <- FunctionSet;
##Setting up whole regression text file
Regression1 <- paste(TextIntro, Population, TextExecLimit, ExecLimit, TextTournSize, TournSize, TextMutPerc,
MutPerc, TextCrossOver, CrossOver, TextGenerations, Generations, TextCodeSize, CodeSize, TextFairMut, FairMut,
TextIntro2, Data[1:length(Data)], TextIntro3, FunctSet, TextIntro4);

Java troubles

Wednesday, October 14th, 2009

This week Jeremy put together a function in R that can take a push function and output its result. My original plan was to have a working version of the Psh library running in R to take advantage of this but I’ve been having some serious issues on the java side of things. Essentially i’m able to load up a class into R but then when I try to run its methods the R-java interpreter is unable to run the method. I have no idea why at this point so I’ll need to bug somebody about it.

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

Data into PushGP Regression Model

Wednesday, October 7th, 2009

//HTML code to plug an array of data into an evolved push function. Evolved function made in the PshGP example regression1.pushgp by Jon Klein modeling data from y = 12x^2 + 5. Help with HTML java script push implementation from Paul Sawaya

<script src=”push.js”></script>
function main()
var x = new Array(“1.1″,”2.1″,”3.1″,”4.1”);
for (i=0;i<=3;i++)


// push function manually pasted from regression1.pushgp
var form = new String(“5.0 7.0 FLOAT.+ FLOAT.* FLOAT.% FLOAT.% FLOAT.* FLOAT.SWAP        FLOAT.+ ” + parseFloat(x[i]) + ” FLOAT.* 6.0 FLOAT.+ 1.0 FLOAT.- FLOAT.SWAP FLOAT.-“);
var program = pushParseString(form);
var interpreter = new pushInterpreter();
var info = pushRunProgram( interpreter, program )


Jeremy & Dan

R Basics

Wednesday, October 7th, 2009

R basics
October 7, 2009
by Jeremy Koelmel (jpk07)

R Basics, Here is how to:
1) to manually set up data in R
2) Import data from outside R (as .txt)
3) export data out of R (as .txt)
4) To export and import R code to run in R

# writing simple exponential data in R
#assign arrays
X <- c(1:10);
Y <- c(X^2);
XYdata <- cbind(X,Y);
#transpose data
XYdata <- t(XYdata);
#select one
# Plot
plot(X, Y, main=”Exponential Function”);

write.table(XYdata, file=”Desktop/XYdata.txt”, sep=”,”);
#getting the working directory
#setting the working directory

RoseData <- read.table(file=”RoseData.txt”);
#see all plots
plot(RoseData, main=”Multiflora Rose Distribution in a Pine Stand”);
#comparing two variables
MFRdensity <- RoseData[,3];
DistanceFromEdge <- RoseData[,9];
#lm(DistanceFromEdge,MFRdensity); not working because more than one instance of y for single x
# Writing .R function: Write in a simple text format (.txt) and Save as “blahblah”.R

# ie. in this format
X <- c(1:10);
Y <- c(X^2);
XYdata <- cbind(X,Y);
plot(X, Y, main=”Exponential Function”);

# get to the right directory
# enact it in R

Love Jeremy

PS: Further Resources:

rJava and psh

Wednesday, October 7th, 2009

Since last class what i’ve wanted to do is just get a simple working function in r that would take some variable in R, put it through Psh and then return the output to R. The original plan was to have minimal work done on the R side of things, R would just give some values and call the function. Then the function itself would go crazy, run the tests and save the model for future tests to be run. As of last night me and Jeremy have had all the seperate components working and we just had to put them all together into a cohesive program.

While we were working on this though all sorts of little problems came up that we needed obscure workarounds to deal with. At the core of most these issues was that all the work was being done externally from R. So I think it might be actually useful for us to go back and actually implement the core classes of Psh in R using rJava rather than obscure workarounds. This will take a little longer but it will give us more control over how everything runs and in the end should be much more useful.

Hello world!

Wednesday, September 30th, 2009

Welcome to i3ci. This is your first post. Edit or delete it, then start blogging about your cool Computer Science project!