Psh is a project mainly written in Java, based on the Apache-2.0 license.
Java implementation of the Push programming language, a stack based language designed for genetic programming.
Copyright 2009-2010 Jon Klein
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Psh is a Java implementation of the Push programming language and of PushGP. Push is a stack-based language designed for evolutionary computation, specifically genetic programming. PushGP is a genetic programming system that evolves programs in Push. More information about Push and PushGP can be found here.
This is v1.0 of Psh.
$ git clone git://github.com/jonklein/Psh.git
$ cd Psh
$ cd Psh
$ git pull
After getting Psh with get, build the package:
$ make
To run PshGP on a sample problem:
$ java PshGP gpsamples/intreg1.pushgp
This problem uses integer symbolic regression to solve the equation y = 12x^2 + 5. Other sample problems are available, with descriptions, in gpsamples/
. For example, intreg2.pushgp
uses integer symbolic regression to solve the factorial function, and regression1.pushgp
uses float symbolic regression to solve y = 12x^2 + 5.
PshInspector allows you to examine every step of a Psh program as it executes. To run PshInspector on a sample psh program:
$ java PshInspector pushsamples/exampleProgram1.push
This push file runs the psh program (2994 5 integer.+)
for 100 steps after pushing the inputs 44, 22, true, 17.76
. Other sample psh programs are available in pushsamples/
.
Use Getting Started with Git above, or use Egit with help on this page. Note on installing Egit: the link provided on the download page does not download any files directly; instead, it is meant to be pasted in Eclipse under Help > Install New Software
.
Start a new Java project by clicking File > New > Java Project
. From there, select Create project from existing source
and browse for and select the Psh project folder. Click Finish
.
JUnit, while not essential to using Psh, will allow for some automatic testing and will make Eclipse not complain about errors in Psh whenever you try to run it. JUnit can be downloaded here, and should be placed wherever you want to store Java jar libraries. To add JUnit to your Psh project, click Project > Properties
. Then select Java Build Path
followed by the Libraries
tab, and then click Add External JARs...
. Select your JUnit jar file wherever you saved it, click Open
, and then Ok
. Now, JUnit should be added to your build path.
Since PshGP requires command-line arguments, you must first specify them in Eclipse by setting up a Run Configuration. To do so, click Run > Run Configurations...
. From here, click New launch configuration
in the upper left corner. Give your configuration a name, and select the project by browsing or by typing Psh in the project line. Then, select PshGP as the main class by clicking Search > PshGP > Ok
. Now, click the Arguments
tab, and type in the configuration file you wish to run, for example gpsamples/intreg1.pushgp
. From here, you can click Run
to directly run this configuration, or Apply
then Close
if you don't want to run it right away. To run a run configuration, click the arrow to the right of the Run
arrow, and select the run configuration you wish to execute.
PshGP runs are setup using configuration files which have the extension .pushgp
. These files contain a list of parameters in the form of
param-name = value
The following parameters must be defined in the configuration file, given with example values:
problem-class = org.spiderland.Psh.IntSymbolicRegression
max-generations = 200
population-size = 1000
execution-limit = 150
max-points-in-program = 100
max-random-code-size = 40
tournament-size = 7
mutation-percent = 30
crossover-percent = 55
simplification-percent = 5
reproduction-simplifications = 25
report-simplifications = 100
final-simplifications = 1000
test-cases = ((1 1) (2 2) (3 6) (4 24) (5 120) (6 720))
instruction-set = (registered.exec registered.boolean integer.% integer.* integer.+ integer.- integer./ integer.dup)
The following parameters are optional. If not specified, the default values below will be used for these parameters, except for the parameters mutation-mode
, output-file
, and push-frame-mode
, which significantly change the run when specified. Also, target-function-string
defaults to not displaying a string, but a representative example is given below.
trivial-geography-radius = 10
simplify-flatten-percent = 20
mutation-mode = fair
fair-mutation-range = .3
node-selection-mode = unbiased (others available are leaf-probability and size-tournament)
node-selection-leaf-probability = 10 (only used if node-selection-mode = leaf-probability)
node-selection-tournament-size = 2 (only used if node-selection-mode = size-tournament)
min-random-integer = -10
max-random-integer = 10
random-integer-resolution = 1
min-random-float = -10.0
max-random-float = 10.0
random-float-resolution = 0.01
target-function-string = "y = x^4 - 2x + 7"
interpreter-class = org.spiderland.Psh.Interpreter
individual-class = org.spiderland.Psh.PushGPIndividual
inputpusher-class = org.spiderland.Psh.InputPusher
output-file = out.txt
push-frame-mode = pushstacks
In order to inspect the execution of a program, PshInspector takes a push program file with the extension .push
. After every step of the program, the stacks of the interpreter are displayed. The input file contains the following, separated by new lines:
PshGP uses problem classes, implemented as Java classes, to determine certain aspects of the run, such as how to compute fitness values. The choice of problem class determines how test case data is interpreted, and which stacks are used for test case input and output. In addition, certain inherited methods in both GA.java and PushGP.java may be overwritten for further customization.
Psh comes with a few standard problem classes. The following problem classes are currently implemented, and are in the ProbClass subpackage:
In order to perform runs for other types of problems, you can implement your own custom problem classes. Please note the following:
target-function-string
, which specifies a human-readable version of the target function, which is only used in I/O.This material is based upon work supported by the National Science Foundation under Grant No. 1017817. Any opinions, findings, and conclusions or recommendations expressed in this publication are those of the authors and do not necessarily reflect the views of the National Science Foundation.