I have written some code in Java which tests the fitness of two solutions.
I am looking to then compare the two solutions and keep the one which has the best fitness and to discard the other.
if(fitness1 < fitness2)
keep fitness1 and discard/ignore fitness2
keep fitness2 and discard/ignore fitness1
I'd say, create an
ArrayList<Double> to keep the best values in and use this:
arrayList.add((fitness1 < fitness2) ? fitness1 : fitness2);
That way you'll have a list of the best values.