1 | # Copyright 2006 by Sean Luke and George Mason University
|
---|
2 | # Licensed under the Academic Free License version 3.0
|
---|
3 | # See the file "LICENSE" for more information
|
---|
4 |
|
---|
5 | ###### example params file, goes in ec/app/regression
|
---|
6 | parent.0 = ./noerc.params
|
---|
7 |
|
---|
8 | # To require that the root of a tree be a given node, you
|
---|
9 | # simply need to set up the typing so that that node is
|
---|
10 | # the only node which is compatable with the tree's return
|
---|
11 | # type. The way to do this is to make not one but two
|
---|
12 | # atomic types (in the example below, nil and root). nil
|
---|
13 | # is the default type used by our GP nodes. root will be
|
---|
14 | # the return type of the tree. Then we create a set type
|
---|
15 | # which is compatable with both of them called nil-and-root,
|
---|
16 | # and set it up so the return type of our desired node
|
---|
17 | # (in this case, 'div'), returns nil-and-root. Thus 'div'
|
---|
18 | # is legal to hang as root (and is the only such node), AND
|
---|
19 | # 'div' is still perfectly compatable as a child of other
|
---|
20 | # nodes as before.
|
---|
21 |
|
---|
22 | # The gotcha: many GP node builders require that for every
|
---|
23 | # reachable type used by nodes in the function set there
|
---|
24 | # must exist at least one terminal (and ideally one nonterminal)
|
---|
25 | # in the function set which returns that type. This is
|
---|
26 | # because many GP node builder algorithms insist on being
|
---|
27 | # able to emit a terminal whenever they so desire, regardless
|
---|
28 | # of what the current type situation is where the terminal
|
---|
29 | # has to be hung. The notable exception to this is Uniform.
|
---|
30 |
|
---|
31 | # Ordinarily this would be a problem for us as we use
|
---|
32 | # Ramped Half-and-Half as our builder, and it has this
|
---|
33 | # requirement. However since we are telling Ramped Half-and-Half
|
---|
34 | # to generate only trees of sizes 2 and up (NOT 1 and up),
|
---|
35 | # it will never attempt to select a terminal for the root
|
---|
36 | # and this gotcha will not occur. The issue would also come
|
---|
37 | # up if we use tree mutation as an operator rather than solely
|
---|
38 | # crossover. But we're not doing that.
|
---|
39 |
|
---|
40 | # Okay, here we go.
|
---|
41 |
|
---|
42 | # Add an atomic type (root) and a set type
|
---|
43 | # (nil-and-root) which is compatible with both
|
---|
44 | # nil and root
|
---|
45 | gp.type.a.size = 2
|
---|
46 | gp.type.a.0.name = nil
|
---|
47 | gp.type.a.1.name = root
|
---|
48 | gp.type.s.size = 1
|
---|
49 | gp.type.s.0.name = nil-and-root
|
---|
50 | gp.type.s.0.size = 2
|
---|
51 | gp.type.s.0.member.0 = nil
|
---|
52 | gp.type.s.0.member.1 = root
|
---|
53 |
|
---|
54 | # make a new contraints form for div which returns
|
---|
55 | # things of type nil-and-root. This is compatable
|
---|
56 | # with all elements that accept nil (which will be
|
---|
57 | # all other functions), so div will still fit right in.
|
---|
58 | gp.nc.size = 8
|
---|
59 | gp.nc.7 = ec.gp.GPNodeConstraints
|
---|
60 | gp.nc.7.name = nc-returning-nil-and-root
|
---|
61 | gp.nc.7.returns = nil-and-root
|
---|
62 | gp.nc.7.size = 2
|
---|
63 | gp.nc.7.child.0 = nil
|
---|
64 | gp.nc.7.child.1 = nil
|
---|
65 |
|
---|
66 | # redefine div to return things of type nil-and-root.
|
---|
67 | gp.fs.0.func.4.nc = nc-returning-nil-and-root
|
---|
68 |
|
---|
69 | # define the tree so that it only accepts items that
|
---|
70 | # are compatible with root. div will be the only
|
---|
71 | # such item.
|
---|
72 | gp.tc.0.returns = root
|
---|
73 |
|
---|
74 | ###### end example
|
---|