Skip to main content
. 2018 Oct 1;20(10):756. doi: 10.3390/e20100756
Algorithm 3: Modified chromosome evaluation procedure.
for Each gene in chromosome do
if The gene is an operator then
  Pop 2 operands from stack
  if Arity of the operator <2 then
   Discard the 2nd operand
  end if
  Execute the operation
  Push the result back on stack
else  //Comment: the gene is an operand
  Push the operand on stack
end if
end for
The element left on the stack is the value of the evaluated expression.