uw-cmg / StructOpt_modular

A flexible and modular Structure Optimization suite for combining experimental data with energy simulations to create atomic structures.
3 stars 5 forks source link

ENH: allow the population to be sorted by implementing <, >, ==, etc for individuals based on their total fitness values #20

Closed jjmaldonis closed 8 years ago

jjmaldonis commented 8 years ago

Make __lt__, __gt__, __eq__, etc functions for the Individual class.

Implement like:

def __lt__(self, other):
    return self.total_fitness < other.total_fitness

or something similar.

This will allow Population to be sortable very easily.

However, keep in mind that individuals can have a fitness of None, so we need to account for that somehow. We'd probably want to put all those individuals at the end of the sorted list.