public HouseholdsStreamingReaderV10(HouseholdsAlgorithmRunner algoRunner){ super(new HouseholdsImpl()); this.algoRunner = algoRunner; }
MutableScenario(Config config) { this.config = config; this.network = NetworkUtils.createNetwork(this.config); this.population = PopulationUtils.createPopulation(this.config, this.network); this.facilities = new ActivityFacilitiesImpl(); this.households = new HouseholdsImpl(); this.lanes = LanesUtils.createLanesContainer(); this.vehicles = VehicleUtils.createVehiclesContainer(); this.transitVehicles = VehicleUtils.createVehiclesContainer(); this.transitSchedule = new TransitScheduleFactoryImpl().createTransitSchedule(); this.config.network().setLocked(); }
public void testBasicReaderWriter() throws IOException { Households households = new HouseholdsImpl(); HouseholdsReaderV10 reader = new HouseholdsReaderV10(households); reader.readFile(this.getPackageInputDirectory() + TESTHOUSEHOLDSINPUT); checkContent(households); HouseholdsWriterV10 writer = new HouseholdsWriterV10(households); String outfilename = this.getOutputDirectory() + TESTXMLOUTPUT; writer.writeFile(outfilename); File outFile = new File(outfilename); assertTrue(outFile.exists()); //read it again to check if the same is read as at the very first beginning of test households = new HouseholdsImpl(); reader = new HouseholdsReaderV10(households); reader.readFile(outfilename); checkContent(households); }
/** * Test that households are accumulated if streaming is off. */ public void testAddHousehold_NoStreaming(){ HouseholdsImpl hhs = new HouseholdsImpl(); Household hh1 = new HouseholdImpl(Id.create("1", Household.class)); Household hh2 = new HouseholdImpl(Id.create("2", Household.class)); hhs.addHousehold(hh1); assertEquals("Should have the first household added.", 1, hhs.getHouseholds().size()); assertTrue("First household not present.", hhs.getHouseholds().containsValue(hh1)); hhs.addHousehold(hh2); assertEquals("Should have the first AND second household added.", 2, hhs.getHouseholds().size()); assertTrue("First household not present.", hhs.getHouseholds().containsValue(hh1)); assertTrue("Second household not present.", hhs.getHouseholds().containsValue(hh2)); }
/** * Test that households with the same {@link Id} are not accepted. */ public void testAddHousehold_DuplicateId(){ HouseholdsImpl hhs = new HouseholdsImpl(); Household hh1 = new HouseholdImpl(Id.create("1", Household.class)); Household hh2 = new HouseholdImpl(Id.create("1", Household.class)); assertEquals("Shouldn't have a household.", 0, hhs.getHouseholds().size()); hhs.addHousehold(hh1); assertEquals("Didn't add the household.", 1, hhs.getHouseholds().size()); assertEquals("Should have added the household.", hh1, hhs.getHouseholds().get(hh1.getId())); try{ hhs.addHousehold(hh2); fail("Should not have accepted household with similar Id."); } catch (IllegalArgumentException e){ } }