@Override public void notifyStartup(final StartupEvent controlerStartupEvent) { if (counts != null) { for (Id<Link> linkId : counts.getCounts().keySet()) { this.linkStats.put(linkId, new double[24]); } } }
public MeasurementCadytsContext(Config config, Tuple<Counts<Measurement>, Measurements> tuple) { CadytsConfigGroup cadytsConfig = ConfigUtils.addOrGetModule(config, CadytsConfigGroup.GROUP_NAME, CadytsConfigGroup.class ) ; cadytsConfig.setWriteAnalysisFile(true); this.counts = tuple.getFirst() ; this.measurements = tuple.getSecond() ; Set<String> measurementsSet = new TreeSet<>(); for (Id<Measurement> id : this.counts.getCounts().keySet()) { measurementsSet.add(id.toString()); } cadytsConfig.setCalibratedItems(measurementsSet); this.writeAnalysisFile = cadytsConfig.isWriteAnalysisFile(); }
@Inject CadytsContext(Config config, Scenario scenario, @Named("calibration") Counts<Link> calibrationCounts, EventsManager eventsManager, VolumesAnalyzer volumesAnalyzer, OutputDirectoryHierarchy controlerIO) { this.scenario = scenario; this.calibrationCounts = calibrationCounts; this.eventsManager = eventsManager; this.volumesAnalyzer = volumesAnalyzer; this.controlerIO = controlerIO; this.countsScaleFactor = config.counts().getCountsScaleFactor(); CadytsConfigGroup cadytsConfig = ConfigUtils.addOrGetModule(config, CadytsConfigGroup.GROUP_NAME, CadytsConfigGroup.class); // addModule() also initializes the config group with the values read from the config file cadytsConfig.setWriteAnalysisFile(true); Set<String> countedLinks = new TreeSet<>(); for (Id<Link> id : this.calibrationCounts.getCounts().keySet()) { countedLinks.add(id.toString()); } cadytsConfig.setCalibratedItems(countedLinks); this.writeAnalysisFile = cadytsConfig.isWriteAnalysisFile(); }
public void calculateComparison() { double countValue; for (Count count : this.counts.getCounts().values()) { Id stopId = count.getId(); if (!isInRange(count.getCoord())) {
public static <T> AnalyticalCalibrator<T> buildCalibratorAndAddMeasurements(final Config config, final Counts<T> occupCounts, LookUpItemFromId<T> lookUp, Class<T> idType ) { if (occupCounts.getCounts().size() == 0) { log.warn("Counts container is empty."); for (Map.Entry<Id<T>, Count<T>> entry : occupCounts.getCounts().entrySet()) {
private void doTheWriting() throws IOException { // write custom header writeXmlHead(); this.handler.startCounts(this.counts, this.writer); this.handler.writeSeparator(this.writer); List<Count> countsTemp = new Vector<Count>(); countsTemp.addAll(this.counts.getCounts().values()); Collections.sort(countsTemp, new CountComparator()); for (Count c : countsTemp) { List<Volume> volumesTemp = new Vector<Volume>(); volumesTemp.addAll(c.getVolumes().values()); Collections.sort(volumesTemp, new VolumeComparator()); this.handler.startCount(c, this.writer); for (Volume v : volumesTemp) { this.handler.startVolume(v, this.writer); this.handler.endVolume(this.writer); } this.handler.endCount(this.writer); this.handler.writeSeparator(this.writer); this.writer.flush(); } this.handler.endCounts(this.writer); }
public static <T> AnalyticalCalibrator<T> buildCalibratorAndAddMeasurements(final Config config, final Counts<T> occupCounts, LookUpItemFromId<T> lookUp, Class<T> idType) { if (occupCounts.getCounts().size() == 0) { log.warn("Counts container is empty."); for (Map.Entry<Id<T>, Count<T>> entry : occupCounts.getCounts().entrySet()) {
/** * Creates the List with the counts vs sim values stored in the * countAttribute Attribute of this class. */ private void compare() { for (Count<Link> count : this.counts.getCounts().values()) { if (!distanceFilter.isInRange(count)) { continue; } double[] volumes = this.volumesPerLinkPerHour.getVolumesForStop(Id.create(count.getId(), TransitStopFacility.class)); if (volumes == null || volumes.length == 0) { log.warn("No volumes for count location: " + count.getId().toString()); continue; } for (int hour = 1; hour <= 24; hour++) { Volume volume = count.getVolume(hour); if (volume != null) { double countValue = volume.getValue(); double simValue=volumes[hour-1]; simValue *= this.countsScaleFactor; this.result.add(new CountSimComparisonImpl(count.getId(), count.getCsLabel(), hour, countValue, simValue)); } } } }
public void testGetCounts() { final Counts counts = new Counts(); counts.createAndAddCount(Id.create(0, Link.class), "1"); assertEquals("Getting counts failed", 1, counts.getCounts().size()); } }
private void assertCountsAreReprojectedCorrectly( Counts<Link> originalCounts, Counts<Link> reprojectedCounts) { Assert.assertEquals( "unexpected number of counts", originalCounts.getCounts().size(), reprojectedCounts.getCounts().size() ); for ( Id<Link> id : originalCounts.getCounts().keySet() ) { final Coord original = originalCounts.getCount( id ).getCoord(); final Coord transformed = reprojectedCounts.getCount( id ).getCoord(); Assert.assertEquals( "wrong reprojected X value", original.getX() + 1000 , transformed.getX(), MatsimTestUtils.EPSILON ); Assert.assertEquals( "wrong reprojected Y value", original.getY() + 1000 , transformed.getY(), MatsimTestUtils.EPSILON ); } }
ByteArrayInputStream stream = new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)); reader.parse(stream); Assert.assertEquals(1, counts.getCounts().size());
ByteArrayInputStream stream = new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)); reader.parse(stream); Assert.assertEquals(1, counts.getCounts().size());
for ( Id<Link> id : originalCounts.getCounts().keySet() ) { final Coord originalCoord = originalCounts.getCount( id ).getCoord(); final Coord internalCoord = internalCounts.getCount( id ).getCoord(); new MatsimCountsReader( dumpedCounts ).readFile( outputDirectory+"/output_counts.xml.gz" ); for ( Id<Link> id : originalCounts.getCounts().keySet() ) { final Coord originalCoord = originalCounts.getCount( id ).getCoord(); final Coord dumpedCoord = dumpedCounts.getCount( id ).getCoord();