The Program Optimizer Package This package contains the mechanisms used to optimize programs.

Package Specification

This package contains the mechanisms used to optimize programs. Optimized programs are as size-reduced as possible while preserving their exact functionality. Small programs are good for evolution. If a program contains an instruction i which could be left away because it is useless or cannot be reached it wastes "evolutionary" power, because in the next mutation cycle, i might be changed. A change in i will probably not result in i becoming reachable or usefull, so we'll test the same program again.

Currently, there are three levels of optimization to be performed:

L0
Optimize all single instructions and expressions. mem[0]+(3*-1) will become mem[0]-3 and Write mem[1], mem[0]+(3*-1) will become Write mem[1], mem[0]-3.
L1
Remove unrechable and useless code. In
0: If 1 Goto 2
1: mem[1] = 1
2: mem[1] = 0
The instruction at index 1 will be removed, because it can never be reached. The result will be
0: If 1 Goto 2
1: mem[1] = 0
L2
Melt instructions together to shrink the program further.
0: Sleep 10
1: Sleep 10
will become
0: Sleep 20
.