Lsys GNN encoding method - Expansion algorithm for connectivity matrix (pseudo code)
Variable: n = number of neurons in GNN
Input: Genotype G = {cS[1..4], cABCD[1..NumLayers][1..16], ca_p[1..64]}
where NumLayers = logâ‚‚(n) - 2
Output: Connectivity matrix M[1..n][1..n]
// Expand L-system productions
current_string = cS[1..4]
for level = 1 to NumLayers do
next_string = []
for each symbol s in current_string do
if s = A then append cABCD[level][1..4] to next_string
if s = B then append cABCD[level][5..8] to next_string
if s = C then append cABCD[level][9..12] to next_string
if s = D then append cABCD[level][13..16] to next_string
end
current_string = next_string
end
// Expand terminal symbols to binary connection values
bit_string = []
for each symbol s in current_string do
index = ord(s) - ord('a') // a=0, b=1, ..., p=15
append bits(index, 4) to bit_string
end
// Fill connectivity matrix row by row
k = 1
for row = 1 to n do
for col = 1 to n do
M[row][col] = bit_string[k]
k = k + 1
end
end