Check if SortedPopulation_discarded exists
If no bad units are found, the code fails because SortedPopulation_discarded
is not instantiated properly and it deosn't have a save function.
This patch fixes it by checking if SortedPopulation_discarded
has a save
function.