Module tutorial2
[hide private]
[frames] | no frames]

Module tutorial2

source code

tutorial2

Contains all parameters for the evolutionary run, grammar rules, constraints, and specifics about the terminal and function set of the trees in tutorial2. This example file gather all the settings for a simple polynomial regression using this time 2 variables x and y, and adding random integer constants between 1 and 5, and the following mathematical operators: '+','-','neg','*','^2'(or square). We try to find the following polynomial: x^2+3y+4 from 5 sets of testing data (5 different values for x and y). As Koza said, random constants are the "skeleton in Genetic Programming closet". Using them will definitely slow down a search... Any suggestions of current alternative strategies solving this problem would be highly welcomed :) Considering the constraints for building the trees, the root node will only have one child, and there will be no need for ADF in the function and terminal set. A typical way to run the tutorial would be to:

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


Author: by Mehdi Khoury

Version: 1.20

Copyright: (c) 2009 Mehdi Khoury under the mit license http://www.opensource.org/licenses/mit-license.html

Contact: mehdi.khoury at gmail.com

Functions [hide private]
 
add(listElem) source code
 
sub(listElem) source code
 
neg(listElem) source code
 
multiply(listElem) source code
 
square(listElem) source code
 
rootBranch(x) source code
 
GetIdealResultsData() source code
 
FitnessFunction(my_tree) source code
Variables [hide private]
  functions = {'+': add, '-': sub, 'neg': neg, '*': multiply, '^...
  nb_eval = 5
  all_x = [9.05151941577, 5.85064712651, 3.54487677941, 0.764382...
  all_y = [8.88963099206, 3.78237173159, 7.24519203927, 6.534622...
  ideal_results = []
  terminals = {':1': 0, ':2': 1, ':3': 2, ':4': 3, ':5': 4, 'x':...
  set_ERC = [(4, 0, ':1'), (4, 0, ':2'), (4, 0, ':3'), (4, 0, ':...
  crossover_mapping = []
  defaultFunctionSet = [(1, 2, '+'), (1, 2, '*'), (1, 2, '-'), (...
  defaultTerminalSet = [(3, 0, 'x'), (3, 0, 'y'), (4, 0, ':1'), ...
  treeRules = {'*': [([(1, 2, '+'), (1, 2, '*'), (1, 2, '-'), (1...
  Strongly_Typed_Crossover_degree = 0
  Substitute_Mutation = 0
  adfOrdered = False
  __package__ = None
  i = 4
Variables Details [hide private]

functions

Value:
{'+': add, '-': sub, 'neg': neg, '*': multiply, '^2': square, 'root': \
rootBranch}

all_x

Value:
[9.05151941577,
 5.85064712651,
 3.54487677941,
 0.764382854319,
 3.53968576678]

all_y

Value:
[8.88963099206,
 3.78237173159,
 7.24519203927,
 6.53462205748,
 2.55355799134]

terminals

Value:
{':1': 0,
 ':2': 1,
 ':3': 2,
 ':4': 3,
 ':5': 4,
 'x': [9.05151941577,
       5.85064712651,
       3.54487677941,
...

set_ERC

Value:
[(4, 0, ':1'), (4, 0, ':2'), (4, 0, ':3'), (4, 0, ':4'), (4, 0, ':5')]

defaultFunctionSet

Value:
[(1, 2, '+'), (1, 2, '*'), (1, 2, '-'), (1, 1, 'neg'), (1, 1, '^2')]

defaultTerminalSet

Value:
[(3, 0, 'x'),
 (3, 0, 'y'),
 (4, 0, ':1'),
 (4, 0, ':2'),
 (4, 0, ':3'),
 (4, 0, ':4'),
 (4, 0, ':5')]

treeRules

Value:
{'*': [([(1, 2, '+'),
         (1, 2, '*'),
         (1, 2, '-'),
         (1, 1, 'neg'),
         (1, 1, '^2')],
        [(3, 0, 'x'),
         (3, 0, 'y'),
         (4, 0, ':1'),
...