public void savePopulationFor(Population pop, Run run, int generation) {
    File file = getFileFor(run, generation);

    if (file != null) {
      if (mode == JSON_MODE) JSONPopulationCoder.encode(pop, file);
      else XMLPopulationCoder.encode(pop, file);
    }
  }
  public Population getPopulationFor(Run run, int generation) {
    File file = getFileFor(run, generation);
    Population pop = null;

    if (file != null) {
      if (mode == JSON_MODE) pop = JSONPopulationCoder.decode(file, run);
      else pop = XMLPopulationCoder.decode(file, run);
    } else pop = new InMemoryPopulation();

    return pop;
  }