# clean previous temp results
os.system('rm -f {}'.format(os.path.join(global_dst, '*')))
os.system('rm -f {}'.format(os.path.join(lake_dst, '*')))
os.system('rm -f {}'.format(os.path.join(veg_dst, '*')))
os.system('rm -rf {}'.format(os.path.join(results_dst, '*')))
start_time = time()
service = Service()
synthesis = Synthesis()

parent = synthesis.synthesize_population()
child = synthesis.create_child_population(parent)

for i in range(2, config.generations + 1):
    rankedFronts = service.fast_non_dominated_sort(
        service.combine_population(parent, child))
    nextChildPopulation = Population()
    childPopulace = []

    for j in range(1, len(rankedFronts) + 1):
        singularFront = []
        singularFront = rankedFronts[j]

        usableSpace = config.populationSize - len(childPopulace)

        if singularFront != [] and usableSpace > 0:
            if usableSpace >= len(singularFront):
                for chromosome in singularFront:
                    childPopulace.append(chromosome)
            else:
                latestFront = []