@Override
 protected void prepareForSim() {
   ControlerUtils.checkConfigConsistencyAndWriteToLog(
       this.config, "Config dump before doIterations:");
   ParallelPersonAlgorithmRunner.run(
       this.population,
       this.config.global().getNumberOfThreads(),
       new ParallelPersonAlgorithmRunner.PersonAlgorithmProvider() {
         @Override
         public AbstractPersonAlgorithm getPersonAlgorithm() {
           return new PersonPrepareForSim(
               createRoutingAlgorithm(), KnSimplifiedController.this.scenario);
         }
       });
 }
  @Override
  public void run() {
    if (scenario instanceof MutableScenario) {
      ((MutableScenario) scenario).setLocked();
      // see comment in ScenarioImpl. kai, sep'14
    }

    /*
     * Create single-mode network here and hand it over to PersonPrepareForSim. Otherwise, each instance would create its
     * own single-mode network. However, this assumes that the main mode is car - which PersonPrepareForSim also does. Should
     * be probably adapted in a way that other main modes are possible as well. cdobler, oct'15.
     */
    final Network net;
    if (NetworkUtils.isMultimodal(network)) {
      log.info(
          "Network seems to be multimodal. Create car-only network which is handed over to PersonPrepareForSim.");
      TransportModeNetworkFilter filter = new TransportModeNetworkFilter(network);
      net = NetworkUtils.createNetwork();
      HashSet<String> modes = new HashSet<>();
      modes.add(TransportMode.car);
      filter.filter(net, modes);
    } else {
      net = network;
    }

    // make sure all routes are calculated.
    ParallelPersonAlgorithmRunner.run(
        population,
        globalConfigGroup.getNumberOfThreads(),
        new ParallelPersonAlgorithmRunner.PersonAlgorithmProvider() {
          @Override
          public AbstractPersonAlgorithm getPersonAlgorithm() {
            return new MyPersonPrepareForSim(
                new PlanRouter(tripRouterProvider.get(), activityFacilities), scenario, net);
          }
        });
    if (population instanceof Lockable) {
      ((Lockable) population).setLocked();
    }
  }