Thanks for your question. You are absolutely right. You should only replace inequality sign. But for my opinion, will be better to replace F (goal function) by -F (minus F). It is a common practice for changing minimization on maximization and vice versa.
Thanks a lot for sharing. I tested the code accordaing to an example in a recent published book http://www.engr.colostate.edu/~echong/book3/ & the results were identical.
In the case of maximisation, would you only swap ''<'' in line 41 with ''>'' ?