コード例 #1
0
  public static void main(String[] args) {
    String path = "./ihop2/matsim-input/config.xml";
    Config config = ConfigUtils.loadConfig(path);
    final Scenario scenario = ScenarioUtils.loadScenario(config);
    Controler controler = new Controler(scenario);
    double samplesize = config.qsim().getStorageCapFactor();
    String outputRoot = "./ihop2/matsim-output/output";
    //		LogToOutputSaver.setOutputDirectory(outputRoot);

    double departureTime = 8. * 60 * 60;

    // Changing vehicle and road capacity according to sample size
    PTCapacityAdjusmentPerSample capadjuster = new PTCapacityAdjusmentPerSample();
    capadjuster.adjustStoarageAndFlowCapacity(scenario, samplesize);

    //		controler.getConfig().qsim().setInflowConstraint(InflowConstraint.maxflowFromFdiag);
    //		controler.getConfig().qsim().setTrafficDynamics(TrafficDynamics.withHoles);

    Network network = scenario.getNetwork();
    TransitSchedule schedule = scenario.getTransitSchedule();
    new CreatePseudoNetwork(schedule, network, "tr_").createNetwork();
    //		NetworkWriter networkWriter =  new NetworkWriter(network);
    //		networkWriter.write("/home/saleem/input/PseudoNetwork.xml");
    //		networkWriter.write("H:\\Matsim\\Stockholm
    // Scenario\\teleportation\\input\\PseudoNetwork.xml");
    //		controler.addControlerListener(new FareControlListener());
    //		controler.setScoringFunctionFactory(new ScoringFunctionFactory() {
    //			@Inject CharyparNagelScoringParametersForPerson parameters;
    //			@Override
    //			public ScoringFunction createNewScoringFunction(Person person) {
    //				final CharyparNagelScoringParameters params = parameters.getScoringParameters( person );
    //				SumScoringFunction sumScoringFunction = new SumScoringFunction();
    //				sumScoringFunction.addScoringFunction(new CharyparNagelActivityScoring( params ));
    //				sumScoringFunction.addScoringFunction(new StockholmLegScoring( person, params ,
    // scenario.getNetwork()));
    //				sumScoringFunction.addScoringFunction(new StockholmMoneyScoring(person, params ));
    //				sumScoringFunction.addScoringFunction(new CharyparNagelAgentStuckScoring( params ));
    //				return sumScoringFunction;			}
    //		});
    //		controler.addControlerListener(new FareControlListener());
    controler.run();

    TransitRouter trouter =
        controler.getInjector().getBinding(TransitRouter.class).getProvider().get();
    createStopsFile(scenario.getTransitSchedule().getFacilities(), outputRoot + "ptStops.csv", ",");
    //
    //		// The locationFacilitiesMap is passed twice: Once for origins and once for destinations.
    //		// In other uses the two maps may be different -- thus the duplication here.
    new ThreadedMatrixCreator(
        scenario,
        scenario.getTransitSchedule().getFacilities(),
        scenario.getTransitSchedule().getFacilities(),
        departureTime,
        outputRoot,
        " ",
        1,
        trouter);
  }
コード例 #2
0
ファイル: NetConverter.java プロジェクト: sebhoerl/matsim
  public void convertTransitSchedule(String file) {

    Config config = ConfigUtils.createConfig();
    config.scenario().setUseTransit(true);
    config.scenario().setUseVehicles(true);
    Scenario scenario = ScenarioUtils.createScenario(config);

    TransitScheduleReader ts = new TransitScheduleReader(scenario);
    ts.readFile(file);

    PointFeatureFactory.Builder builder = new PointFeatureFactory.Builder();
    builder.setName("nodes");
    builder.addAttribute("id", String.class);
    PointFeatureFactory factory = builder.create();

    List<SimpleFeature> features = new ArrayList<SimpleFeature>();

    for (TransitStopFacility stop : scenario.getTransitSchedule().getFacilities().values()) {
      features.add(factory.createPoint(MGC.coord2Coordinate(stop.getCoord())));
    }

    ShapeFileWriter.writeGeometries(
        features,
        "C:/Users/Daniel/Documents/work/shared-svn/studies/countries/cl/Kai_und_Daniel/Visualisierungen/stops.shp");
  }
コード例 #3
0
 public EventsToTravelDiaries(Scenario scenario) {
   this.network = scenario.getNetwork();
   isTransitScenario = scenario.getConfig().transit().isUseTransit();
   if (isTransitScenario) {
     this.transitSchedule = scenario.getTransitSchedule();
     this.walkSpeed = new TransitRouterConfig(scenario.getConfig()).getBeelineWalkSpeed();
   }
 }
コード例 #4
0
 private static Population getPopulationTypesTransitLine(Scenario scenario, String[] args) {
   scenario.getConfig().transit().setUseTransit(true);
   (new TransitScheduleReader(scenario)).readFile(args[4]);
   TransitLine line =
       scenario.getTransitSchedule().getTransitLines().get(Id.create(args[5], TransitLine.class));
   MutableScenario sc = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig());
   Population population = PopulationUtils.createPopulation(sc.getConfig(), sc.getNetwork());
   for (Person person : scenario.getPopulation().getPersons().values())
     if (isRelatedWithLine(person, line))
       population.addPerson(new PersonImplPops(person, Id.create(line.getId(), Population.class)));
     else population.addPerson(new PersonImplPops(person, PersonImplPops.DEFAULT_POP_ID));
   return population;
 }
コード例 #5
0
  private final void convertPseudoNetwork() {
    List<Id> nodeIds = new ArrayList<Id>(scenario.getNetwork().getNodes().keySet());
    for (Id id : nodeIds) {
      scenario.getNetwork().removeNode(id);
    }
    new CreatePseudoNetwork(scenario.getTransitSchedule(), scenario.getNetwork(), "")
        .createNetwork();

    for (Link l : scenario.getNetwork().getLinks().values()) {
      l.setCapacity(WagonSimConstants.DEFAULT_CAPACITY);
      l.setFreespeed(WagonSimConstants.DEFAULT_FREESPEED);
    }
  }
コード例 #6
0
 private LazyScheduleBasedMatrixRoutingModule(
     final Cache cache,
     final LazyScheduleBasedMatrixConfigGroup config,
     final Scenario scenario,
     final TransitRouter router,
     final RoutingModule walkRouter) {
   this(
       config.getTimeBinDuration_s(),
       cache,
       router,
       scenario.getTransitSchedule(),
       scenario.getNetwork(),
       walkRouter);
 }
コード例 #7
0
  private final void convertStations(OTTDataContainer dataContainer, Network infraNetwork) {
    TransitScheduleFactory factory = scenario.getTransitSchedule().getFactory();

    // get station ids
    Set<Id> stationIds = new HashSet<Id>();
    for (Locomotive locomotive : dataContainer.locomotives.values()) {
      for (StationData stationData : locomotive.trips.values()) {
        stationIds.add(stationData.stationId);
      }
    }

    for (Id stationId : stationIds) {
      Node node = infraNetwork.getNodes().get(stationId);
      if (node != null) {
        TransitStopFacility stopFacility =
            factory.createTransitStopFacility(stationId, node.getCoord(), false);
        stopFacility.setName(node.getId().toString());
        scenario.getTransitSchedule().addStopFacility(stopFacility);
      } else {
        throw new RuntimeException(
            "node id=" + stationId.toString() + " not found in the network. Bailing out.");
      }
    }
  }
コード例 #8
0
ファイル: VWRCreateDemand.java プロジェクト: nkuehnel/matsim
 void createAgentGroupNearTransitstrops(
     Scenario scenario, double distance, String transitScheduleFile) {
   new TransitScheduleReader(scenario).readFile(transitScheduleFile);
   for (Person p : scenario.getPopulation().getPersons().values()) {
     if (scenario
             .getPopulation()
             .getPersonAttributes()
             .getAttribute(p.getId().toString(), "subpopulation")
         != null) {
       return;
     }
     ArrayList<Boolean> isIt = new ArrayList<>();
     for (Plan plan : p.getPlans()) {
       for (PlanElement pe : plan.getPlanElements()) {
         if (pe instanceof Activity) {
           boolean setAct = false;
           Coord ac = ((Activity) pe).getCoord();
           for (TransitStopFacility stop :
               scenario.getTransitSchedule().getFacilities().values()) {
             double dist = CoordUtils.calcDistance(stop.getCoord(), ac);
             if (dist <= distance) {
               setAct = true;
               break;
             }
           }
           isIt.add(setAct);
         }
       }
     }
     boolean truth = true;
     for (Boolean t : isIt) {
       if (!t) truth = false;
     }
     if (truth) {
       scenario
           .getPopulation()
           .getPersonAttributes()
           .putAttribute(p.getId().toString(), "subpopulation", "schedulePt");
     } else {
       scenario
           .getPopulation()
           .getPersonAttributes()
           .putAttribute(p.getId().toString(), "subpopulation", "teleportPt");
       this.teleportPtUsers.add(p.getId());
     }
   }
 }
コード例 #9
0
 public void updateSchedule() {
   VehicleRemover vehremover = new VehicleRemover(scenario);
   VehicleAdder vehadder = new VehicleAdder(scenario);
   Map<Id<TransitLine>, TransitLine> lines = scenario.getTransitSchedule().getTransitLines();
   Iterator<Id<TransitLine>> lineids = lines.keySet().iterator();
   while (lineids.hasNext()) {
     TransitLine tline = lines.get(lineids.next());
     if (Math.random() <= 0.05) { // With 5% probability
       if (Math.random() <= 0.5) { // With 50% probability
         vehadder.addDeparturesToLine(
             tline, 0.1); // Adds 10 % departures and corresponding vehicles from tline
       } else {
         vehremover.removeDeparturesFromLine(
             tline, 0.1); // Removes  10 % departures and corresponding vehicles from tline
       }
     }
   }
 }
コード例 #10
0
  private final void createVehicleLinkSpeedAttributes() {
    for (TransitLine transitLine : scenario.getTransitSchedule().getTransitLines().values()) {
      for (TransitRoute transitRoute : transitLine.getRoutes().values()) {
        Set<Id> vehIds = new HashSet<Id>();
        for (Departure departure : transitRoute.getDepartures().values()) {
          vehIds.add(departure.getVehicleId());
        }

        Iterator<TransitRouteStop> iterator = transitRoute.getStops().iterator();
        double departure = iterator.next().getDepartureOffset();
        while (iterator.hasNext()) {
          TransitRouteStop routeStop = iterator.next();
          double arrival = routeStop.getArrivalOffset();
          Link link = scenario.getNetwork().getLinks().get(routeStop.getStopFacility().getLinkId());
          double speed = link.getLength() / (arrival - departure);
          if (speed >= 200.0) {
            System.out.println(
                "line="
                    + transitLine.getId()
                    + ";route="
                    + transitRoute.getId()
                    + "stop="
                    + routeStop.getStopFacility().getId()
                    + ": lLenth="
                    + link.getLength()
                    + ";arr="
                    + arrival
                    + ";dep="
                    + departure
                    + "");
          }

          for (Id vehId : vehIds) {
            this.vehicleAttributes.putAttribute(vehId.toString(), link.getId().toString(), speed);
          }

          departure = routeStop.getDepartureOffset();
        }
      }
    }
  }
コード例 #11
0
  @Override
  public TripRouter get() {
    final TripRouter tripRouter = defaultFactory.get();

    final TransitRouterWrapper routingModule =
        new TransitRouterWrapper(
            transitRouterFactory.get(),
            scenario.getTransitSchedule(),
            scenario.getNetwork(), // use a walk router in case no PT path is found
            DefaultRoutingModules.createTeleportationRouter(
                TransportMode.transit_walk,
                scenario.getPopulation().getFactory(),
                scenario
                    .getConfig()
                    .plansCalcRoute()
                    .getModeRoutingParams()
                    .get(TransportMode.walk)));

    tripRouter.setRoutingModule(TransportMode.pt, routingModule);

    return tripRouter;
  }
コード例 #12
0
  public void writeSchedule(String name) {

    TransitScheduleWriter tw = new TransitScheduleWriter(scenario.getTransitSchedule());
    tw.writeFile("H:\\Matsim\\Stockholm Scenario\\teleportation\\input\\" + name);
  }
コード例 #13
0
 @Override
 public TransitSchedule getTransitSchedule() {
   return delegate.getTransitSchedule();
 }
コード例 #14
0
  private final void convertSchedules(
      OTTDataContainer dataContainer, ObjectAttributes trainTypes, boolean isPerformance) {
    TransitScheduleFactory scheduleFactory = scenario.getTransitSchedule().getFactory();
    VehiclesFactory vehiclesFactory = ((ScenarioImpl) scenario).getVehicles().getFactory();

    VehicleType vehicleType =
        vehiclesFactory.createVehicleType(new IdImpl(WagonSimConstants.DEFAULT_VEHICLE_TYPE));
    VehicleCapacity vehicleCapacity = vehiclesFactory.createVehicleCapacity();
    // we do not use this capacity. Therefore it should infinite, otherwise this capacity may exceed
    // before ``our'' capacities are exceeded // dr, oct'13
    vehicleCapacity.setSeats(999999);
    vehicleCapacity.setStandingRoom(999999);
    // we defined the vehicle-enter/leave-time is implicit included in transfer-times which
    // are defined in the transitrouterconfig (for handling see
    // WagonSimTripRouterFactoryImpl#WagonSimRouterWrapper)
    // dr, oct'13
    vehicleType.setAccessTime(0);
    vehicleType.setEgressTime(0);
    vehicleType.setCapacity(vehicleCapacity);
    ((ScenarioImpl) scenario).getVehicles().addVehicleType(vehicleType);

    Date startDate = extractStartDate(dataContainer, isPerformance);
    System.out.println("startDate=" + startDate.toString());

    for (Locomotive locomotive : dataContainer.locomotives.values()) {

      Departure departure = null;
      List<TransitRouteStop> transitRouteStops = new ArrayList<TransitRouteStop>();
      for (StationData stationData : locomotive.trips.values()) {

        TransitStopFacility stopFacility =
            scenario.getTransitSchedule().getFacilities().get(stationData.stationId);
        if (stopFacility == null) {
          throw new RuntimeException(
              "locomotive id="
                  + locomotive.id
                  + ": station id="
                  + stationData.stationId
                  + " not found. Bailing out.");
        }

        double arrivalDelay = Double.NaN;
        double departureDelay = Double.NaN;
        if (departure == null) {
          double lineDepartureOffset =
              (stationData.departure.getTime() - startDate.getTime()) / 1000.0;
          if (!isPerformance) {
            lineDepartureOffset -= stationData.delayDeparture;
          }
          departure = scheduleFactory.createDeparture(locomotive.id, lineDepartureOffset);
          arrivalDelay = 0.0;
        } else {
          arrivalDelay =
              (stationData.arrival.getTime() - startDate.getTime()) / 1000.0
                  - departure.getDepartureTime();
          if (!isPerformance) {
            arrivalDelay -= stationData.delayArrival;
          }
        }
        departureDelay =
            (stationData.departure.getTime() - startDate.getTime()) / 1000.0
                - departure.getDepartureTime();
        if (!isPerformance) {
          departureDelay -= stationData.delayDeparture;
        }

        if (departureDelay < arrivalDelay) {
          throw new RuntimeException(
              "locomotive id="
                  + locomotive.id
                  + ": arrival="
                  + stationData.arrival.toString()
                  + " does not fit with departure="
                  + stationData.departure.toString()
                  + ". ("
                  + departureDelay
                  + "<"
                  + arrivalDelay
                  + ") Bailing out.");
        }

        TransitRouteStop stop =
            scheduleFactory.createTransitRouteStop(stopFacility, arrivalDelay, departureDelay);
        stop.setAwaitDepartureTime(true);
        transitRouteStops.add(stop);
      }

      if (transitRouteStops.size() > 1) {

        // check if train type is given
        if (trainTypes.getAttribute(locomotive.type.toString(), WagonSimConstants.TRAIN_MAX_SPEED)
            == null) {
          throw new RuntimeException(
              "locomotive id="
                  + locomotive.id
                  + ": type="
                  + locomotive.type
                  + " is not defined by the train type table. Bailing out.");
        }

        TransitLine line = scheduleFactory.createTransitLine(locomotive.id);
        scenario.getTransitSchedule().addTransitLine(line);
        TransitRoute route =
            scheduleFactory.createTransitRoute(
                line.getId(), null, transitRouteStops, TransportMode.pt);
        line.addRoute(route);

        Vehicle vehicle = vehiclesFactory.createVehicle(route.getId(), vehicleType);
        ((ScenarioImpl) scenario).getVehicles().addVehicle(vehicle);
        departure.setVehicleId(vehicle.getId());
        route.addDeparture(departure);
        this.vehicleAttributes.putAttribute(
            vehicle.getId().toString(), WagonSimConstants.TRAIN_TYPE, locomotive.type);
        this.vehicleAttributes.putAttribute(
            vehicle.getId().toString(),
            WagonSimConstants.TRAIN_MAX_SPEED,
            (Double)
                trainTypes.getAttribute(
                    locomotive.type.toString(), WagonSimConstants.TRAIN_MAX_SPEED));
        this.vehicleAttributes.putAttribute(
            vehicle.getId().toString(),
            WagonSimConstants.TRAIN_MAX_WEIGHT,
            (Double)
                trainTypes.getAttribute(
                    locomotive.type.toString(), WagonSimConstants.TRAIN_MAX_WEIGHT));
        this.vehicleAttributes.putAttribute(
            vehicle.getId().toString(),
            WagonSimConstants.TRAIN_MAX_LENGTH,
            (Double)
                trainTypes.getAttribute(
                    locomotive.type.toString(), WagonSimConstants.TRAIN_MAX_LENGTH));

        // the next day
        vehicle = vehiclesFactory.createVehicle(new IdImpl(route.getId() + ".1"), vehicleType);
        ((ScenarioImpl) scenario).getVehicles().addVehicle(vehicle);
        departure =
            scheduleFactory.createDeparture(
                vehicle.getId(), departure.getDepartureTime() + 24 * 3600);
        departure.setVehicleId(vehicle.getId());
        route.addDeparture(departure);
        this.vehicleAttributes.putAttribute(
            vehicle.getId().toString(), WagonSimConstants.TRAIN_TYPE, locomotive.type);
        this.vehicleAttributes.putAttribute(
            vehicle.getId().toString(),
            WagonSimConstants.TRAIN_MAX_SPEED,
            (Double)
                trainTypes.getAttribute(
                    locomotive.type.toString(), WagonSimConstants.TRAIN_MAX_SPEED));
        this.vehicleAttributes.putAttribute(
            vehicle.getId().toString(),
            WagonSimConstants.TRAIN_MAX_WEIGHT,
            (Double)
                trainTypes.getAttribute(
                    locomotive.type.toString(), WagonSimConstants.TRAIN_MAX_WEIGHT));
        this.vehicleAttributes.putAttribute(
            vehicle.getId().toString(),
            WagonSimConstants.TRAIN_MAX_LENGTH,
            (Double)
                trainTypes.getAttribute(
                    locomotive.type.toString(), WagonSimConstants.TRAIN_MAX_LENGTH));

        // the day after the next day
        vehicle = vehiclesFactory.createVehicle(new IdImpl(route.getId() + ".2"), vehicleType);
        ((ScenarioImpl) scenario).getVehicles().addVehicle(vehicle);
        departure =
            scheduleFactory.createDeparture(
                vehicle.getId(), departure.getDepartureTime() + 24 * 3600);
        departure.setVehicleId(vehicle.getId());
        route.addDeparture(departure);
        this.vehicleAttributes.putAttribute(
            vehicle.getId().toString(), WagonSimConstants.TRAIN_TYPE, locomotive.type);
        this.vehicleAttributes.putAttribute(
            vehicle.getId().toString(),
            WagonSimConstants.TRAIN_MAX_SPEED,
            (Double)
                trainTypes.getAttribute(
                    locomotive.type.toString(), WagonSimConstants.TRAIN_MAX_SPEED));
        this.vehicleAttributes.putAttribute(
            vehicle.getId().toString(),
            WagonSimConstants.TRAIN_MAX_WEIGHT,
            (Double)
                trainTypes.getAttribute(
                    locomotive.type.toString(), WagonSimConstants.TRAIN_MAX_WEIGHT));
        this.vehicleAttributes.putAttribute(
            vehicle.getId().toString(),
            WagonSimConstants.TRAIN_MAX_LENGTH,
            (Double)
                trainTypes.getAttribute(
                    locomotive.type.toString(), WagonSimConstants.TRAIN_MAX_LENGTH));
      } else if (transitRouteStops.size() == 1) {
        System.out.println(
            "locomotive id="
                + locomotive.id
                + ": only one station given. Therefore, no transitLine created.");
      } else {
        System.out.println(
            "locomotive id="
                + locomotive.id
                + ": no station is given. Therefore, no transitLine created.");
      }
    }
  }
コード例 #15
0
  @Override
  public TripRouter instantiateAndConfigureTripRouter(RoutingContext routingContext) {

    TripRouter tripRouter = new TripRouter();

    PlansCalcRouteConfigGroup routeConfigGroup = scenario.getConfig().plansCalcRoute();

    LeastCostPathCalculator routeAlgo =
        leastCostPathCalculatorFactory.createPathCalculator(
            scenario.getNetwork(),
            routingContext.getTravelDisutility(),
            routingContext.getTravelTime());

    FreespeedTravelTimeAndDisutility ptTimeCostCalc =
        new FreespeedTravelTimeAndDisutility(-1.0, 0.0, 0.0);
    LeastCostPathCalculator routeAlgoPtFreeFlow =
        leastCostPathCalculatorFactory.createPathCalculator(
            scenario.getNetwork(), ptTimeCostCalc, ptTimeCostCalc);

    final boolean networkIsMultimodal = NetworkUtils.isMultimodal(scenario.getNetwork());
    if (networkIsMultimodal) {
      // note: LinkImpl has a default allowed mode of "car" so that all links
      // of a monomodal network are actually restricted to car, making the check
      // of multimodality unecessary from a behavioral point of view.
      // However, checking the mode restriction for each link is expensive,
      // so it is not worth doing it if it is not necessary. (td, oct. 2012)
      if (routeAlgo instanceof IntermodalLeastCostPathCalculator) {
        ((IntermodalLeastCostPathCalculator) routeAlgo)
            .setModeRestriction(Collections.singleton(TransportMode.car));
        ((IntermodalLeastCostPathCalculator) routeAlgoPtFreeFlow)
            .setModeRestriction(Collections.singleton(TransportMode.car));
      } else {
        // this is impossible to reach when using the algorithms of org.matsim.*
        // (all implement IntermodalLeastCostPathCalculator)
        log.warn(
            "network is multimodal but least cost path algorithm is not an instance of IntermodalLeastCostPathCalculator!");
      }
    }

    for (String mode : routeConfigGroup.getTeleportedModeFreespeedFactors().keySet()) {
      final RoutingModule routingModule =
          DefaultRoutingModules.createPseudoTransitRouter(
              mode,
              scenario.getPopulation().getFactory(),
              scenario.getNetwork(),
              routeAlgoPtFreeFlow,
              routeConfigGroup.getModeRoutingParams().get(mode));
      tripRouter.setRoutingModule(mode, routingModule);
    }

    for (String mode : routeConfigGroup.getTeleportedModeSpeeds().keySet()) {
      final RoutingModule routingModule =
          DefaultRoutingModules.createTeleportationRouter(
              mode,
              scenario.getPopulation().getFactory(),
              routeConfigGroup.getModeRoutingParams().get(mode));
      final RoutingModule result = tripRouter.setRoutingModule(mode, routingModule);

      if (result != null) {
        log.error("inconsistent router configuration for mode " + mode);
        log.error(
            "One situation which triggers this warning: setting both speed and speedFactor for a mode (this used to be possible).");
        throw new RuntimeException(
            "there was already a module set when trying to set teleporting module for mode "
                + mode
                + ": "
                + result);
      }
    }

    for (String mode : routeConfigGroup.getNetworkModes()) {
      final RoutingModule routingModule =
          DefaultRoutingModules.createNetworkRouter(
              mode, scenario.getPopulation().getFactory(), scenario.getNetwork(), routeAlgo);
      final RoutingModule result = tripRouter.setRoutingModule(mode, routingModule);

      if (result != null) {
        log.error("inconsistent router configuration for mode " + mode);
        throw new RuntimeException(
            "there was already a module set when trying to set network routing module for mode "
                + mode
                + ": "
                + result);
      }

      // The default router will always route on the car network.  A user may, however, have
      // prepared a network with dedicated bicycle
      // links and then expect the router to route on that.  The following test tries to catch that.
      //  If someone improves on this,
      // the test can be removed.  kai, feb'15
      if (networkIsMultimodal) {
        switch (mode) {
          case TransportMode.car:
          case TransportMode.ride:
            break;
          default:
            throw new RuntimeException(
                "you have a multi-modal network and configured "
                    + mode
                    + " to be routed as a network mode.  "
                    + "The present configuration will route this "
                    + "mode on the car network.  This may be ok (e.g. with ``truck'' or ``motorbike''), or not (e.g. with ``bicycle''). "
                    + "Throwing an exception anyways; please use a uni-modal network if you want to keep this configuration.");
        }
      }
    }

    if (scenario.getConfig().transit().isUseTransit()) {
      TransitRouterWrapper routingModule =
          new TransitRouterWrapper(
              transitRouterFactory.get(),
              scenario.getTransitSchedule(),
              scenario.getNetwork(), // use a walk router in case no PT path is found
              DefaultRoutingModules.createTeleportationRouter(
                  TransportMode.transit_walk,
                  scenario.getPopulation().getFactory(),
                  routeConfigGroup.getModeRoutingParams().get(TransportMode.walk)));
      for (String mode : scenario.getConfig().transit().getTransitModes()) {
        // XXX one can't check for inconsistent setting here...
        // because the setting is inconsistent by default (defaults
        // set a teleportation setting for pt routing, which is overriden
        // here) (td, may 2013)
        tripRouter.setRoutingModule(mode, routingModule);
      }
    }
    return tripRouter;
  }