Skip to content

Brain CGP

Clifford Bohm edited this page May 25, 2018 · 7 revisions

CGP (Cartesian Genetic Programming) Brains implement a simple flavor of classic CGP.

CGP Brain defines lists of math operations (one operator and two operands). One interesting element of CGPs is that each operation generates outputs which are then available to operations that follow it. CGP Brains have one for each output and one for each hidden) and implements memory over time by use of hidden nodes (additional outputs which are feed back into the brain as inputs on the following update.)

For more on CGP see: http://www.cartesiangp.co.uk/

If you are interested in developing other flavors of CGP a) please do and b) please let us know so we can use it too!

Parameters

CGP Brains have the following parameters...

% BRAIN_CGP
  availableOperators = [all]                 #(string) which opperators are allowed? all indicates, allow all opperators or, choose from: SUM,MULT,SUBTRACT,DIVIDE,SIN,COS,THRESH,RAND,IF,INV
  buildMode = linear                         #(string) How is the genome converted, "linear" : linear conversion starting at begining of genome, "codon" : start
                                             #  codons locate operator+in1+in2 along with the formula/output index and a location in formula
  codonMax = 100                             #(int) if using "genes" buildMode, values will be extracted from genome as integers [0..codonMax] and two sites that
                                             #  add to codonMax defines a start codon
  hiddenNodes = 8                            #(int) number of hidden nodes
  magnitudeMax = 1000000000.0                #(double) values generated which are larger then this will by clipped
  magnitudeMin = -1000000000.0               #(double) values generated which are smaller then this will by clipped
  operatorsPreFormula = 8                    #(int) number of instructions per formula. Ignored if buildMode is "genes"
  readFromOutputs = 1                        #(bool) if true, previous updates outputs will be available as inputs.

internally:

This CGP implementation does no optimization... all operations are run, even operations that are not connected with outputs. The output for each list of operations is the result of the last operation in the list.

direct vs. codon construction:

CGP brains can be built by directly converting a genome or by scanning a genome for start codons and then using the following genetic information to generate each operation and that operations relative location in the equation.

operators:

SUM : a + b

MULT : a * b

SUBTRACT: a - b

DIVIDE: a / b (return 0 in the case of a / 0)

SIN : sin(a) (b is ignored)

COS : cos(a) (b is ignored)

THRESH : if (a > b) then b else a

RAND : random value in the range (a,b)

IF : if (a > 0) ? b : 0

INV : -1 * a (b is ignored)

Clone this wiki locally