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 } } } }
// Remove vehicles from the transitschedule according to the sample size public void removeVehicles(double sample) { VehicleRemover rveh = new VehicleRemover(scenario); rveh.removeVehicles(sample); rveh.removeDeletedVehicleDepartures(); }