public TransitRouterNetworkTravelTimeAndDisutilityWSV(final TransitRouterConfig config, TransitRouterNetworkWW routerNetwork, WaitTime waitTime, StopStopTime stopStopTime, VehicleOccupancy vehicleOccupancy, TravelTimeCalculatorConfigGroup tTConfigGroup, QSimConfigGroup qSimConfigGroup, PreparedTransitSchedule preparedTransitSchedule) { this(config, routerNetwork, waitTime, stopStopTime, vehicleOccupancy, tTConfigGroup, qSimConfigGroup.getStartTime(), qSimConfigGroup.getEndTime(), preparedTransitSchedule); } public TransitRouterNetworkTravelTimeAndDisutilityWSV(final TransitRouterConfig config, TransitRouterNetworkWW routerNetwork, WaitTime waitTime, StopStopTime stopStopTime, VehicleOccupancy vehicleOccupancy, TravelTimeCalculatorConfigGroup tTConfigGroup, double startTime, double endTime, PreparedTransitSchedule preparedTransitSchedule) {
private void prepareConfig() { Config config = this.scenario.getConfig(); config.transit().setUseTransit(true); config.qsim().setSnapshotStyle(SnapshotStyle.queue); config.qsim().setEndTime(24.0*3600); }
@Override public QSim createMobsim( final Scenario sc1, final EventsManager eventsManager) { final QSimConfigGroup conf = sc1.getConfig().qsim(); if (conf == null) { throw new NullPointerException("There is no configuration set for the QSim. Please add the module 'qsim' to your config file."); } if ( !conf.getMainModes().contains( JointActingTypes.DRIVER ) ) { log.warn( "adding the driver mode as a main mode in the config at "+getClass()+" initialisation!" ); final List<String> ms = new ArrayList<String>( conf.getMainModes() ); ms.add( JointActingTypes.DRIVER ); conf.setMainModes( ms ); } return new QSimBuilder(config) // .useDefaults() // .addQSimModule(new JointQSimModule()) // .configureQSimComponents(JointQSimModule::configureComponents ) // .build(sc1, eventsManager); } }
public SnapshotGenerator(final Network network, final double snapshotPeriod, final QSimConfigGroup config) { this.network = network; int initialCapacity = (int)(network.getLinks().size()*1.1); this.eventLinks = new HashMap<>(initialCapacity, 0.95f); this.linkList = new ArrayList<>(initialCapacity); this.eventAgents = new HashMap<>(1000, 0.95f); this.snapshotPeriod = snapshotPeriod; this.capCorrectionFactor = config.getFlowCapFactor() / network.getCapacityPeriod(); this.storageCapFactor = config.getStorageCapFactor(); this.snapshotStyle = config.getSnapshotStyle(); if (! Double.isNaN( config.getLinkWidthForVis() )){ this.linkWidthCalculator.setLinkWidthForVis( config.getLinkWidthForVis() ); } if (! Double.isNaN(network.getEffectiveLaneWidth())){ this.linkWidthCalculator.setLaneWidth(network.getEffectiveLaneWidth()); } reset(-1); }
flowCapacityPerTimeStep = flowCapacityPerTimeStep * context.qsimConfig.getTimeStepSize() * context.qsimConfig.getFlowCapFactor() ; inverseFlowCapacityPerTimeStep = 1.0 / flowCapacityPerTimeStep; switch (context.qsimConfig.getTrafficDynamics()) { case queue: case withHoles: wrnCnt++ ; log.warn( "max flow from fdiag < requested flow cap; linkId=" + qLink.getId() + "; req flow cap/h=" + 3600.*flowCapacityPerTimeStep/context.qsimConfig.getTimeStepSize() + "; max flow from fdiag/h=" + 3600*maxFlowFromFdiag/context.qsimConfig.getTimeStepSize() ) ; if ( wrnCnt==10 ) { log.warn( Gbl.FUTURE_SUPPRESSED ) ; default: throw new RuntimeException("The traffic dynamics "+context.qsimConfig.getTrafficDynamics()+" is not implemented yet.");
public SimpleNetwork(){ scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); config = scenario.getConfig(); config.qsim().setFlowCapFactor(1.0); config.qsim().setStorageCapFactor(1.0); config.qsim().setMainModes(Arrays.asList("car")); config.qsim().setLinkDynamics(QSimConfigGroup.LinkDynamics.PassingQ); config.qsim().setVehiclesSource(QSimConfigGroup.VehiclesSource.modeVehicleTypesFromVehiclesData); network = (Network) scenario.getNetwork(); this.network.setCapacityPeriod(Time.parseTime("1:00:00")); double x = -100.0; Node node1 = NetworkUtils.createAndAddNode(network, Id.create("1", Node.class), new Coord(x, 0.0)); Node node2 = NetworkUtils.createAndAddNode(network, Id.create("2", Node.class), new Coord(0.0, 0.0)); Node node3 = NetworkUtils.createAndAddNode(network, Id.create("3", Node.class), new Coord(0.0, 1000.0)); Node node4 = NetworkUtils.createAndAddNode(network, Id.create("4", Node.class), new Coord(0.0, 1100.0)); Set<String> allowedModes = new HashSet<String>(); allowedModes.addAll(Arrays.asList("car","bike")); final Node fromNode = node1; final Node toNode = node2; link1 = NetworkUtils.createAndAddLink(network,Id.create("1", Link.class), fromNode, toNode, (double) 100, MAX_SPEED_ON_LINK, (double) 60, (double) 1, null, "22"); final Node fromNode1 = node2; final Node toNode1 = node3; link2 = NetworkUtils.createAndAddLink(network,Id.create("2", Link.class), fromNode1, toNode1, (double) 1000, MAX_SPEED_ON_LINK, (double) 60, (double) 1, null, "22"); final Node fromNode2 = node3; final Node toNode2 = node4; link3 = NetworkUtils.createAndAddLink(network,Id.create("3", Link.class), fromNode2, toNode2, (double) 100, MAX_SPEED_ON_LINK, (double) 60, (double) 1, null, "22"); population = scenario.getPopulation(); } }
@StringSetter(END_TIME) private void setEndTime(String value) { setEndTime(Time.parseTime(value)); }
config.qsim().setStartTime(0.0); final double simEndTime = 7200.0; config.qsim().setEndTime(simEndTime); Scenario scenario = (MutableScenario) ScenarioUtils.createScenario(config);
config.qsim().setStartTime(0); config.qsim().setEndTime(3600 * 5); config.qsim().setUsingFastCapacityUpdate(false);
private void initSimTimer() { QSimConfigGroup qSimConfigGroup = this.scenario.getConfig().qsim(); Double configuredStartTime = qSimConfigGroup.getStartTime(); this.stopTime = qSimConfigGroup.getEndTime(); if (configuredStartTime == Time.UNDEFINED_TIME) { configuredStartTime = 0.0; } if ((this.stopTime == Time.UNDEFINED_TIME) || (this.stopTime == 0)) { this.stopTime = Double.MAX_VALUE; } double simStartTime; if (QSimConfigGroup.StarttimeInterpretation.maxOfStarttimeAndEarliestActivityEnd.equals(qSimConfigGroup.getSimStarttimeInterpretation())) { double firstAgentStartTime = calculateFirstAgentStartTime(); simStartTime = Math.floor(Math.max(configuredStartTime, firstAgentStartTime)); } else if (QSimConfigGroup.StarttimeInterpretation.onlyUseStarttime.equals(qSimConfigGroup.getSimStarttimeInterpretation())) { simStartTime = configuredStartTime; } else { throw new RuntimeException("unkonwn starttimeInterpretation; aborting ..."); } this.simTimer.setSimStartTime(simStartTime); this.simTimer.setTime(simStartTime); }
config.qsim().setFlowCapFactor(1.0); config.qsim().setStorageCapFactor(1.0); config.qsim().setMainModes(Arrays.asList(TransportMode.car,TransportMode.walk)); config.qsim().setLinkDynamics(LinkDynamics.SeepageQ); config.qsim().setSeepModes(Arrays.asList(TransportMode.walk) ); config.qsim().setSeepModeStorageFree(false); config.qsim().setRestrictingSeepage(true);
config.controler().setMobsim("qsim"); config.global().setNumberOfThreads(1); config.qsim().setRemoveStuckVehicles(false); config.qsim().setStuckTime(10000.0); config.qsim().setStartTime(0.0); config.qsim().setSimStarttimeInterpretation(QSimConfigGroup.StarttimeInterpretation.onlyUseStarttime); StrategySettings stratSets = new StrategySettings(Id.create(1, StrategySettings.class)); stratSets.setStrategyName(DefaultPlanStrategiesModule.DefaultStrategy.ReRoute.toString()); params.setTypicalDuration(24.0 * 3600.0); config.planCalcScore().addActivityParams(params); config.qsim().setUseLanes(doCreateLanes); config.qsim().setUseLanes(true); createLanes();
@StringGetter(END_TIME) private String getEndTimeAsString() { return Time.writeTime(getEndTime()); }
@Test public void testKMLSnapshotWriterOnQSim() { final Config config = utils.loadConfig(IOUtils.newUrl(ExamplesUtils.getTestScenarioURL("equil"), "config_plans1.xml")); config.controler().setLastIteration(2); config.controler().setWriteEventsInterval(0); config.controler().setWritePlansInterval(0); config.controler().setMobsim("qsim"); config.controler().setSnapshotFormat(Arrays.asList("googleearth")); config.qsim().setSnapshotPeriod(600); config.qsim().setSnapshotStyle( SnapshotStyle.equiDist ) ; final Controler controler = new Controler(config); controler.getConfig().controler().setCreateGraphs(false); controler.getConfig().controler().setDumpDataAtEnd(false); controler.run(); assertTrue(new File(controler.getControlerIO().getIterationFilename(0, "googleearth.kmz")).exists()); assertTrue(new File(controler.getControlerIO().getIterationFilename(1, "googleearth.kmz")).exists()); assertTrue(new File(controler.getControlerIO().getIterationFilename(2, "googleearth.kmz")).exists()); }
@Override void initializeFactory(AgentCounter agentCounter, MobsimTimer mobsimTimer, NetsimInternalInterface netsimEngine1) { double effectiveCellSize = ((Network)network).getEffectiveCellSize() ; SnapshotLinkWidthCalculator linkWidthCalculator = new SnapshotLinkWidthCalculator(); linkWidthCalculator.setLinkWidthForVis( qsimConfig.getLinkWidthForVis() ); if (! Double.isNaN(network.getEffectiveLaneWidth())){ linkWidthCalculator.setLaneWidth( network.getEffectiveLaneWidth() ); } AbstractAgentSnapshotInfoBuilder snapshotBuilder = QNetsimEngine.createAgentSnapshotInfoBuilder( scenario, linkWidthCalculator ); this.context = new NetsimEngineContext(events, effectiveCellSize, agentCounter, snapshotBuilder, qsimConfig, mobsimTimer, linkWidthCalculator ) ; this.netsimEngine = netsimEngine1 ; } @Override QNodeI createNetsimNode(Node node) {
@Override public void checkConsistency(Config config) { new BeanValidationConfigConsistencyChecker().checkConsistency(config); if (config.qsim().getStartTime() != 0 && !Time.isUndefinedTime(config.qsim().getStartTime())) { // If properly handled this should not be a concern log.warn("QSim.startTime should be 0:00:00 (or 0). This is what typically DynAgents assume"); } if (config.qsim().getTimeStepSize() != 1) { // If properly handled this should not be a concern log.warn("QSim.timeStepSize should be 1. This is what typically DynAgents assume"); } if (config.qsim().getSimStarttimeInterpretation() != StarttimeInterpretation.onlyUseStarttime) { throw new RuntimeException("DynAgents require simulation to start from the very beginning" + " Set 'QSim.simStarttimeInterpretation' to " + StarttimeInterpretation.onlyUseStarttime); } } }
if ( config.qsim().getUsePersonIdForMissingVehicleId() ) { log.log( lvl, "found qsim.usePersonIdForMissingVehicleId==true; this is only for backwards compatibility and should rather be set to false") ; if ( !config.qsim().isUsingTravelTimeCheckInTeleportation() ) { log.log( lvl, "found `qsim.usingTravelTimeCheckInTeleporation==false'; vsp should try out `true' and report." ) ; switch( config.qsim().getTrafficDynamics() ) { case withHoles: case kinematicWaves: case queue: default: log.log( lvl, " found 'qsim.trafficDynamics==" + config.qsim().getTrafficDynamics() + "'; vsp standard is`" + TrafficDynamics.kinematicWaves + "'." ) ; break; if ( config.qsim()!=null && config.qsim().isRemoveStuckVehicles() ) { problem = true ; System.out.flush() ; if ( config.qsim().getVehiclesSource()==VehiclesSource.fromVehiclesData && config.qsim().getUsePersonIdForMissingVehicleId() && containsModeChoice && config.qsim().getMainModes().size() > 1 )
@StringSetter(MAIN_MODE) private void setMainModes(String value) { setMainModes(Arrays.asList(value.split(","))); }
config.qsim().setTrafficDynamics(TrafficDynamics.withHoles); config.qsim().setSnapshotStyle(SnapshotStyle.withHoles); config.qsim().setNodeOffset(5.); config.qsim().setUsingFastCapacityUpdate(false);
config.qsim().setUseLanes(true); config.qsim().setNodeOffset(20.0); config.qsim().setSnapshotStyle(SnapshotStyle.queue);