Complex Systems, Spring 1998
Bio 367: Computational Models of Biological Organization
CS 246: Programming Paradigms


Paul Grobstein, Bryn Mawr College Department of Biology
Clare Congdon, Bryn Mawr College Computer Science Program
______________________________________________________________________

Using our Genetic Programming code

To do our Genetic Programming lab, you'll first need to make your own copies of the programs, just like last week. Here's one way to do this:
  mkdir GPP
  cp ~ccongdon/Public/GPP/* GPP  

Then, cd to your new GPP directory, and start up Lisp:

  cd GPP
  clisp  
First, load the basic GPP program:
  (load "loadfile")  
This includes the exclusive-or task, which you can run immediately:
  (run-ga)  
When this is done (it should take just a few minutes), two new files will be created, GA-individuals, and GA-output. Look at the first one to see what the best solution to the problem was at the end of each generation. If you want some help from Lisp in figuring out what each of these expressions does, try something like the following:

After 12 generations, my GP found the solution (AND (NOT (AND Y X)) (OR X Y))
to the XOR problem. I can set the values for X and Y and see what this
expression evaluates to, or what parts of this evaluates to:

(setf x T)
(setf y T)
(and (not (and y x)) (or x y))          --> NIL   (x and y are both T)

(setf x NIL)
(and (not (and y x)) (or x y))          --> T     (x is NIL and y is T)

(setf y NIL)
(and (not (and y x)) (or x y))          --> NIL   (x and y are both NIL)

(setf x T)
(and (not (and y x)) (or x y))          --> T     (x is T and y is NIL)


I could also define a function to more quickly evaluate this:
(defun test (x y)
  (and (not (and y x)) (or x y))
  )

NOTE: Line breaks, indentation, and capitalization do not matter, but the
parentheses are critical.

Then, to test the function, I can type:

(test T T)		--> NIL
(test NIL T)		--> T
(test NIL NIL)		--> NIL
(test T NIL)		--> T
What you can experiment with
  1. Do (run-ga) again, and you'll likely end up with a different solution.

  2. Edit the xor.lisp file to change the set of "primitive" functions. Initially, the set includes AND, OR, and NOT. You can remove some of these, and add IF and EQUAL.

    To do this, find the line that begins with (setf *functions* ...), and edit the list. Be sure to keep the parentheses paired! (And don't edit the line that begins with a semicolon, which is commented out.)

    Then, you have to recompile and reload the code:

    	(load "load-xor")	

    Then, you can run again:

    	(run-ga)	

    Caveat: if you find your Lisp program crashing after you've changed the primitives, you need to add extra terminal symbols. See the comments in the program about fixing this.

  3. Load the inhibit1.lisp program:
    	(load "load-inhibit1")	
    You can then run this (run-ga), look at the solutions, edit the set of primitive functions, reload, rerun, etc.

    You will probably need to reset the parameters to do more generations or to use a larger population size in order to find a solution. Remember that the file must be reloaded to have an effect.

  4. Load the inhibit2.lisp program:
    	(load "load-inhibit2")	
    You can then run this (run-ga), look at the solutions, edit the set of primitive functions, reload, rerun, etc.

    You will probably need to reset the parameters to do more generations or to use a larger population size in order to find a solution. Remember that the file must be reloaded to have an effect.

If you want to change the parameter settings to the GPP, edit the file parameters.lisp, reload it (load "parameters.lisp"), and run the program again.

Note that each time you run the GPP, your GA-individuals file will get overwritten. If you want to save one, give it another name. For example, at the Unix prompt:

	mv GA-individuals GA-xor

______________________________________________________________________
Maintained by:

Clare Bates Congdon (ccongdon@brynmawr.edu)
Paul Grobstein (pgrobste@brynmawr.edu)
______________________________________________________________________