-
Notifications
You must be signed in to change notification settings - Fork 0
/
eggp_init.gp2
executable file
·139 lines (132 loc) · 1.62 KB
/
eggp_init.gp2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
//********************************Generate Individual********************************
//Code for generating the first individual
Main = initNodeCounter; AddNode!; [connectOutput]!; deleteNodeCounter
AddNode = [addNode]; [addEdgeToArity]!; decolourNode
// INIT NODE COUNTER - Creates a counter for adding nodes
initNodeCounter
(
x : int
)
[
(n0(R), "Nodes":x)
|
]
=>
[
(n0(R), "Nodes":x)
(n1(R), "NodeCounter":x)
|
]
interface =
{
n0
}
// ADD NODE - Adds a function from the FunctionSet
addNode
(
f : string;
x, y : int
)
[1.0]
[
(n0(R), "NodeCounter":x)
(f0(R), "FunctionSet":f:y)
|
]
=>
[
(f0(R), "NodeCounter":x - 1)
(n0(R), "FunctionSet":f:y)
(t1, f#red)
|
]
interface =
{
f0, n0
}
where x > 0
// ADD EDGE TO ARITY - Adds an edge to a target node until it has sufficient arity, reused in mutations
addEdgeToArity
(
a, b : list;
f, s : string;
x : int
)
[1.0]
[
(n0, a:f#red)
(n1, b:s)
(f0(R), "FunctionSet":f:x)
|
]
=>
[
(n0, a:f#red)
(n1, b:s)
(f0(R), "FunctionSet":f:x)
|
(e0, n0, n1, outdeg(n0))
]
interface =
{
n0, n1, f0
}
where s != "OUT" and outdeg(n0) < x
// DECOLOUR NODE - Removes red colour so node can be used as input to other nodes
decolourNode
(
a : list
)
[
(n0, a#red)
|
]
=>
[
(n0, a)
|
]
interface =
{
n0
}
// CONNECT OUTPUT - CONNECT OUTPUT
connectOutput
(
a, b : list;
s : string
)
[1.0]
[
(n0, a:"OUT")
(n1, b:s)
|
]
=>
[
(n0, a:"OUT")
(n1, b:s)
|
(e0, n0, n1, 0)
]
interface =
{
n0, n1
}
where s !="OUT" and outdeg(n0) < 1
// Delete NODE COUNTER - Deletes the counter for adding nodes
deleteNodeCounter
(
x : int
)
[
(n1(R), "NodeCounter":x)
|
]
=>
[
|
]
interface =
{
}