/** @author mrieser */ @Test public void testSetWriteEventsAlways() { final Config config = this.utils.loadConfig("test/scenarios/equil/config_plans1.xml"); config.controler().setLastIteration(1); config.controler().setWritePlansInterval(0); final Controler controler = new Controler(config); controler.getConfig().controler().setWriteEventsInterval(1); assertEquals(1, controler.getConfig().controler().getWriteEventsInterval()); controler.getConfig().controler().setCreateGraphs(false); controler.addOverridingModule( new AbstractModule() { @Override public void install() { bindMobsim() .toProvider( new Provider<Mobsim>() { @Override public Mobsim get() { return new FakeMobsim(); } }); } }); controler.setDumpDataAtEnd(false); controler.run(); assertTrue( new File(controler.getControlerIO().getIterationFilename(0, Controler.FILENAME_EVENTS_XML)) .exists()); assertTrue( new File(controler.getControlerIO().getIterationFilename(1, Controler.FILENAME_EVENTS_XML)) .exists()); }
@Test public void testTransimsSnapshotWriterOnQSim() { final Config config = this.utils.loadConfig("test/scenarios/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("transims")); config.qsim().setSnapshotPeriod(600); config.qsim().setSnapshotStyle(SnapshotStyle.equiDist); ; final Controler controler = new Controler(config); controler.getConfig().controler().setCreateGraphs(false); controler.setDumpDataAtEnd(false); controler.run(); assertTrue(new File(controler.getControlerIO().getIterationFilename(0, "T.veh.gz")).exists()); assertTrue(new File(controler.getControlerIO().getIterationFilename(1, "T.veh.gz")).exists()); assertTrue(new File(controler.getControlerIO().getIterationFilename(2, "T.veh.gz")).exists()); }
/** @author mrieser */ @Test public void testSetWriteEventsNever() { final Config config = this.utils.loadConfig("test/scenarios/equil/config_plans1.xml"); config.controler().setLastIteration(1); config.controler().setWritePlansInterval(0); final Controler controler = new Controler(config); assertFalse( "Default for Controler.writeEventsInterval should be different from the interval we plan to use, otherwise it's hard to decide if it works correctly.", 0 == controler.getConfig().controler().getWriteEventsInterval()); controler.getConfig().controler().setWriteEventsInterval(0); assertEquals(0, controler.getConfig().controler().getWriteEventsInterval()); controler.getConfig().controler().setCreateGraphs(false); controler.addOverridingModule( new AbstractModule() { @Override public void install() { bindMobsim() .toProvider( new Provider<Mobsim>() { @Override public Mobsim get() { return new FakeMobsim(); } }); } }); controler.setDumpDataAtEnd(false); controler.run(); assertFalse( new File(controler.getControlerIO().getIterationFilename(0, Controler.FILENAME_EVENTS_XML)) .exists()); assertFalse( new File(controler.getControlerIO().getIterationFilename(1, Controler.FILENAME_EVENTS_XML)) .exists()); }