true if the Link with the given Id is not farther away than the
- * distance specified by the distance filter from the center node of the filter.
- */
- boolean isInRange(final Coord stopCoord) {
- if ((this.distanceFilterNode == null) || (this.distanceFilter == null)) {
- return true;
- }
-
- double dist = CoordUtils.calcEuclideanDistance(stopCoord, this.distanceFilterNode.getCoord());
- return dist < this.distanceFilter.doubleValue();
- }
-
- /**
- *
- * @return the result list
- */
- public List getComparison() {
- return this.countSimComp;
- }
-
- /**
- * Set a distance filter, dropping everything out which is not in the distance given in meters
- * around the given Node Id.
- *
- * @param distance
- * @param nodeId
- */
- public void setDistanceFilter(final Double distance, final String nodeId) {
- this.distanceFilter = distance;
- this.distanceFilterNode = this.network.getNodes().get(Id.create(nodeId, Node.class));
- }
-
- public void write(final String outputFilename) {
- final SimpleWriter simpleWriter = new SimpleWriter(outputFilename);
- simpleWriter.write(this.content.toString());
- simpleWriter.close();
- }
-}
diff --git a/contribs/cadytsIntegration/src/main/java/org/matsim/contrib/cadyts/pt/CadytsPtModule.java b/contribs/cadytsIntegration/src/main/java/org/matsim/contrib/cadyts/pt/CadytsPtModule.java
deleted file mode 100644
index d9f459047b3..00000000000
--- a/contribs/cadytsIntegration/src/main/java/org/matsim/contrib/cadyts/pt/CadytsPtModule.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.matsim.contrib.cadyts.pt;
-
-
-import org.matsim.core.controler.AbstractModule;
-
-import jakarta.inject.Singleton;
-
-public class CadytsPtModule extends AbstractModule {
- @Override
- public void install() {
- bind(CadytsPtContext.class).in( Singleton.class );
- addControlerListenerBinding().to(CadytsPtContext.class);
- bind(CadytsPtOccupancyAnalyzerI.class).to(CadytsPtOccupancyAnalyzer.class);
- }
-}
diff --git a/contribs/cadytsIntegration/src/main/java/org/matsim/contrib/cadyts/pt/CadytsPtOccupancyAnalyzer.java b/contribs/cadytsIntegration/src/main/java/org/matsim/contrib/cadyts/pt/CadytsPtOccupancyAnalyzer.java
deleted file mode 100644
index c116c652e0c..00000000000
--- a/contribs/cadytsIntegration/src/main/java/org/matsim/contrib/cadyts/pt/CadytsPtOccupancyAnalyzer.java
+++ /dev/null
@@ -1,299 +0,0 @@
-/* *********************************************************************** *
- * project: org.matsim.*
- * *
- * *********************************************************************** *
- * *
- * copyright : (C) 2012 by the members listed in the COPYING, *
- * LICENSE and WARRANTY file. *
- * email : info at matsim dot org *
- * *
- * *********************************************************************** *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * See also COPYING, LICENSE and WARRANTY file *
- * *
- * *********************************************************************** */
-
-package org.matsim.contrib.cadyts.pt;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.Set;
-
-import jakarta.inject.Inject;
-
-import org.matsim.api.core.v01.Id;
-import org.matsim.api.core.v01.events.PersonEntersVehicleEvent;
-import org.matsim.api.core.v01.events.PersonLeavesVehicleEvent;
-import org.matsim.api.core.v01.events.TransitDriverStartsEvent;
-import org.matsim.api.core.v01.network.Link;
-import org.matsim.contrib.cadyts.general.CadytsConfigGroup;
-import org.matsim.core.api.experimental.events.VehicleArrivesAtFacilityEvent;
-import org.matsim.core.api.experimental.events.VehicleDepartsAtFacilityEvent;
-import org.matsim.core.config.Config;
-import org.matsim.core.config.ConfigUtils;
-import org.matsim.core.utils.misc.Time;
-import org.matsim.counts.Count;
-import org.matsim.counts.Counts;
-import org.matsim.counts.Volume;
-import org.matsim.pt.counts.SimpleWriter;
-import org.matsim.pt.transitSchedule.api.TransitLine;
-import org.matsim.pt.transitSchedule.api.TransitStopFacility;
-import org.matsim.vehicles.Vehicle;
-
-/**
- * Collects occupancy data of transit-line stations
- *
- * This is probably similar to code elsewhere. However, it makes some sense to keep this here since the correct workings of cadyts
- * (obviously) depends on the fact that the counts are actually what it thinks, and so it makes sense to decouple this from the upstream
- * counting method and leave it here. kai, sep'13
- */
-final class CadytsPtOccupancyAnalyzer implements CadytsPtOccupancyAnalyzerI {
- // can be/remain public as long as constructor is package-private. kai, feb'20
-
- private final int timeBinSize, maxSlotIndex;
- private final double maxTime;
- private Map, int[]> occupancies; // Map< stopFacilityId,value[]>
- private final Map, Id> vehStops = new HashMap<>(); // Map< vehId,stopFacilityId>
- private final Map, Integer> vehPassengers = new HashMap<>(); // Map
- private StringBuffer occupancyRecord = new StringBuffer("time\tvehId\tStopId\tno.ofPassengersInVeh\n");
- private final Set analyzedTransitDrivers = new HashSet<>();
- private final Set analyzedTransitVehicles = new HashSet<>();
- private final Set> calibratedLines;
-
- @Inject
- CadytsPtOccupancyAnalyzer( Config config ) {
- CadytsConfigGroup ccc = ConfigUtils.addOrGetModule(config, CadytsConfigGroup.class ) ;
-
- this.calibratedLines = toTransitLineIdSet( ccc.getCalibratedLines() ) ;
- this.timeBinSize = ccc.getTimeBinSize() ;
-
- this.maxTime = Time.MIDNIGHT-1; //24 * 3600 - 1;
- // (yy not completely clear if it might be better to use 24*this.timeBimSize, but it is overall not so great
- // to have this hardcoded. kai/manuel, jul'12)
-
- this.maxSlotIndex = ((int) this.maxTime) / this.timeBinSize + 1;
- this.occupancies = new HashMap<>();
- }
-
- @Override
- public void reset(final int iteration) {
- this.occupancies.clear();
- this.vehStops.clear();
- this.vehPassengers.clear();
- this.occupancyRecord = new StringBuffer("time\tvehId\tStopId\tno.ofPassengersInVeh\n");
- this.analyzedTransitDrivers.clear();
- this.analyzedTransitVehicles.clear();
- }
-
- @Override
- public void handleEvent(final TransitDriverStartsEvent event) {
- if (this.calibratedLines.contains(event.getTransitLineId())) {
- this.analyzedTransitDrivers.add(event.getDriverId());
- this.analyzedTransitVehicles.add(event.getVehicleId());
- }
- }
-
- @Override
- public void handleEvent(final PersonEntersVehicleEvent event) {
- if (this.analyzedTransitDrivers.contains(event.getPersonId()) || !this.analyzedTransitVehicles.contains(event.getVehicleId())) {
- return; // ignore transit drivers or persons entering non-(analyzed-)transit vehicles
- }
-
- // ------------------veh_passenger- (for occupancy)-----------------
- Id vehId = event.getVehicleId();
- Id stopId = this.vehStops.get(vehId);
- double time = event.getTime();
- Integer nPassengers = this.vehPassengers.get(vehId);
- this.vehPassengers.put(vehId, (nPassengers != null) ? (nPassengers + 1) : 1);
- this.occupancyRecord.append("time :\t").append(time).append(" veh :\t").append(vehId).append(" has Passenger\t").append(this.vehPassengers.get(vehId)).append(" \tat stop :\t").append(stopId).append(" ENTERING PERSON :\t").append(event.getPersonId()).append("\n");
- }
-
- @Override
- public void handleEvent(final PersonLeavesVehicleEvent event) {
- if (this.analyzedTransitDrivers.contains(event.getPersonId()) || !this.analyzedTransitVehicles.contains(event.getVehicleId())) {
- return; // ignore transit drivers or persons entering non-(analyzed-)transit vehicles
- }
-
- // ----------------veh_passenger-(for occupancy)--------------------------
- Id vehId = event.getVehicleId();
- double time = event.getTime();
- Integer nPassengers = this.vehPassengers.get(vehId);
- if (nPassengers == null) {
- throw new RuntimeException("null passenger-No. in vehicle ?");
- }
- this.vehPassengers.put(vehId, nPassengers - 1);
- if (this.vehPassengers.get(vehId) == 0) {
- this.vehPassengers.remove(vehId);
- }
- Integer passengers = this.vehPassengers.get(vehId);
- this.occupancyRecord.append("time :\t").append(time).append(" veh :\t").append(vehId).append(" has Passenger\t").append((passengers != null) ? passengers : 0).append("\n");
- }
-
- @Override
- public void handleEvent(final VehicleDepartsAtFacilityEvent event) {
- Id vehId = event.getVehicleId();
- Id facId = event.getFacilityId();
-
- // -----------------------occupancy--------------------------------
- this.vehStops.remove(vehId);
- int[] occupancyAtStop = this.occupancies.get(facId);
- if (occupancyAtStop == null) { // no previous departure from this stop, therefore no occupancy
- // record yet. Create this:
- occupancyAtStop = new int[this.maxSlotIndex + 1];
- this.occupancies.put(facId, occupancyAtStop);
- }
-
- Integer noPassengersInVeh = this.vehPassengers.get(vehId);
-
- if (noPassengersInVeh != null) {
- occupancyAtStop[this.getTimeSlotIndex(event.getTime())] += noPassengersInVeh;
- this.occupancyRecord.append(event.getTime());
- this.occupancyRecord.append("\t");
- this.occupancyRecord.append(vehId);
- this.occupancyRecord.append("\t");
- this.occupancyRecord.append(facId);
- this.occupancyRecord.append("\t");
- this.occupancyRecord.append(noPassengersInVeh);
- this.occupancyRecord.append("\n");
- }
- }
-
- @Override
- public void handleEvent(final VehicleArrivesAtFacilityEvent event) {
- Id stopId = event.getFacilityId();
-
- this.vehStops.put(event.getVehicleId(), stopId);
- // (constructing a table with vehId as key, and stopId as value; constructed when veh arrives at
- // stop; necessary
- // since personEnters/LeavesVehicle does not carry stop id)
- }
-
- private int getTimeSlotIndex(final double time) {
- if (time > this.maxTime) {
- return this.maxSlotIndex;
- }
- return ((int) time / this.timeBinSize);
- }
-
- /**
- * @param stopId
- * @return Array containing the number of passengers in bus after the transfer at the stop
- * {@code stopId} per time bin, starting with time bin 0 from 0 seconds to
- * (timeBinSize-1)seconds.
- */
- @Override
- public int[] getOccupancyVolumesForStop(final Id stopId) {
- return this.occupancies.get(stopId);
- }
- /* (non-Javadoc)
- * @see org.matsim.contrib.cadyts.pt.CadytsPtOccupancyAnalyzerI#getOccupancyVolumeForStopAndTime(org.matsim.api.core.v01.Id, int)
- */
- @Override
- public int getOccupancyVolumeForStopAndTime(final Id stopId, final int time_s ) {
- if ( this.occupancies.get(stopId) != null ) {
- int timeBinIndex = getTimeSlotIndex( time_s ) ;
- return this.occupancies.get(stopId)[timeBinIndex] ;
- } else {
- return 0 ;
- }
- }
-
- public Set> getOccupancyStopIds() {
- return this.occupancies.keySet();
- }
-
- @Override
- public void writeResultsForSelectedStopIds(final String filename, final Counts occupCounts, final Collection> stopIds) {
- SimpleWriter writer = new SimpleWriter(filename);
-
- final String TAB = "\t";
- final String NL = "\n";
-
- // write header
- writer.write("stopId\t");
- for (int i = 0; i < 24; i++) {
- writer.write("oc" + i + "-" + (i + 1) + TAB);
- }
- for (int i = 0; i < 24; i++) {
- writer.write("scalSim" + i + "-" + (i + 1) + TAB);
- }
- writer.write("coordinate\tcsId\n");
-
- // write content
- for (Id stopId : stopIds) {
- // get count data
- Count count = occupCounts.getCounts().get(Id.create(stopId, TransitStopFacility.class));
- if (!occupCounts.getCounts().containsKey(Id.create(stopId, TransitStopFacility.class))) {
- continue;
- }
-
- // get sim-Values
- int[] ocuppancy = this.occupancies.get(stopId);
- writer.write(stopId.toString() + TAB);
- for (int i = 0; i < ocuppancy.length; i++) {
- Volume v = count.getVolume(i + 1);
- if (v != null) {
- writer.write(v.getValue() + TAB);
- } else {
- writer.write("n/a" + TAB);
- }
- }
- for (int anOcuppancy : ocuppancy) {
- writer.write((anOcuppancy) + TAB);
- }
- writer.write(count.getCoord().toString() + TAB + count.getCsLabel() + NL);
- }
- writer.write(this.occupancyRecord.toString());
- writer.close();
- }
-
- @Override
- public String toString() {
- final StringBuilder stringBuffer2 = new StringBuilder();
- final String STOPID = "stopId: ";
- final String VALUES = "; values:";
- final char TAB = '\t';
- final char RETURN = '\n';
-
- for (Id stopId : this.getOccupancyStopIds()) { // Only occupancy!
- StringBuilder stringBuffer = new StringBuilder();
- stringBuffer.append(STOPID);
- stringBuffer.append(stopId);
- stringBuffer.append(VALUES);
-
- boolean hasValues = false; // only prints stops with volumes > 0
- int[] values = this.getOccupancyVolumesForStop(stopId);
-
- for (int value : values) {
- hasValues = hasValues || (value > 0);
-
- stringBuffer.append(TAB);
- stringBuffer.append(value);
- }
- stringBuffer.append(RETURN);
- if (hasValues)
- stringBuffer2.append(stringBuffer.toString());
-
- }
- return stringBuffer2.toString();
- }
-
- public static Set> toTransitLineIdSet(Set list) {
- Set> converted = new LinkedHashSet<>();
-
- for ( String id : list) {
- converted.add(Id.create(id, TransitLine.class));
- }
-
- return converted;
- }
-
-
-}
diff --git a/contribs/cadytsIntegration/src/main/java/org/matsim/contrib/cadyts/pt/CadytsPtOccupancyAnalyzerI.java b/contribs/cadytsIntegration/src/main/java/org/matsim/contrib/cadyts/pt/CadytsPtOccupancyAnalyzerI.java
deleted file mode 100644
index 069fe358fd9..00000000000
--- a/contribs/cadytsIntegration/src/main/java/org/matsim/contrib/cadyts/pt/CadytsPtOccupancyAnalyzerI.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package org.matsim.contrib.cadyts.pt;
-
-import java.util.Collection;
-
-import org.matsim.api.core.v01.Id;
-import org.matsim.api.core.v01.events.handler.PersonEntersVehicleEventHandler;
-import org.matsim.api.core.v01.events.handler.PersonLeavesVehicleEventHandler;
-import org.matsim.api.core.v01.events.handler.TransitDriverStartsEventHandler;
-import org.matsim.api.core.v01.network.Link;
-import org.matsim.core.api.experimental.events.handler.VehicleArrivesAtFacilityEventHandler;
-import org.matsim.core.api.experimental.events.handler.VehicleDepartsAtFacilityEventHandler;
-import org.matsim.counts.Counts;
-import org.matsim.pt.transitSchedule.api.TransitStopFacility;
-
-public interface CadytsPtOccupancyAnalyzerI extends TransitDriverStartsEventHandler, PersonEntersVehicleEventHandler,
-PersonLeavesVehicleEventHandler, VehicleArrivesAtFacilityEventHandler, VehicleDepartsAtFacilityEventHandler {
-
- int getOccupancyVolumeForStopAndTime(Id stopId, int time_s);
-
- void writeResultsForSelectedStopIds(String filename, Counts occupCounts, Collection> stopIds);
-
- int[] getOccupancyVolumesForStop(Id stopId);
-
-}
diff --git a/contribs/cadytsIntegration/src/main/java/org/matsim/contrib/cadyts/pt/PtPlanToPlanStepBasedOnEvents.java b/contribs/cadytsIntegration/src/main/java/org/matsim/contrib/cadyts/pt/PtPlanToPlanStepBasedOnEvents.java
deleted file mode 100644
index f9ab329ad5a..00000000000
--- a/contribs/cadytsIntegration/src/main/java/org/matsim/contrib/cadyts/pt/PtPlanToPlanStepBasedOnEvents.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/* *********************************************************************** *
- * project: org.matsim.*
- * *
- * *********************************************************************** *
- * *
- * copyright : (C) 2012 by the members listed in the COPYING, *
- * LICENSE and WARRANTY file. *
- * email : info at matsim dot org *
- * *
- * *********************************************************************** *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * See also COPYING, LICENSE and WARRANTY file *
- * *
- * *********************************************************************** */
-
-package org.matsim.contrib.cadyts.pt;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.matsim.api.core.v01.Id;
-import org.matsim.api.core.v01.Scenario;
-import org.matsim.api.core.v01.events.PersonEntersVehicleEvent;
-import org.matsim.api.core.v01.events.PersonLeavesVehicleEvent;
-import org.matsim.api.core.v01.events.TransitDriverStartsEvent;
-import org.matsim.api.core.v01.events.handler.PersonEntersVehicleEventHandler;
-import org.matsim.api.core.v01.events.handler.PersonLeavesVehicleEventHandler;
-import org.matsim.api.core.v01.events.handler.TransitDriverStartsEventHandler;
-import org.matsim.api.core.v01.population.Person;
-import org.matsim.api.core.v01.population.Plan;
-import org.matsim.contrib.cadyts.general.PlansTranslator;
-import org.matsim.core.api.experimental.events.VehicleDepartsAtFacilityEvent;
-import org.matsim.core.api.experimental.events.handler.VehicleDepartsAtFacilityEventHandler;
-import org.matsim.core.scenario.MutableScenario;
-import org.matsim.pt.transitSchedule.api.TransitLine;
-import org.matsim.pt.transitSchedule.api.TransitSchedule;
-import org.matsim.pt.transitSchedule.api.TransitStopFacility;
-
-import cadyts.demand.PlanBuilder;
-
-/*package*/ class PtPlanToPlanStepBasedOnEvents implements TransitDriverStartsEventHandler, PersonEntersVehicleEventHandler,
- PersonLeavesVehicleEventHandler, VehicleDepartsAtFacilityEventHandler, PlansTranslator {
- private static final Logger log = LogManager.getLogger(PtPlanToPlanStepBasedOnEvents.class);
-
- private final Scenario sc;
- private final TransitSchedule schedule;
-
- private final Map> personsFromVehId = new HashMap<>();
-
- private int iteration = -1;
-
- // this is _only_ there for output:
- Set plansEverSeen = new HashSet<>();
-
- private static final String STR_PLANSTEPFACTORY = "planStepFactory";
- private static final String STR_ITERATION = "iteration";
- // (better to do it this way since when plans are removed, this additional info is removed as well)
-
- private final Set transitDrivers = new HashSet<>();
- private final Set transitVehicles = new HashSet<>();
- private final Set> calibratedLines;
-
- PtPlanToPlanStepBasedOnEvents(final Scenario sc, final Set> calibratedLines) {
- this.sc = sc;
- this.schedule = ((MutableScenario) sc).getTransitSchedule();
- this.calibratedLines = calibratedLines;
- }
-
- private long plansFound = 0;
- private long plansNotFound = 0;
-
- @Override
- public final cadyts.demand.Plan getCadytsPlan(final Plan plan) {
- @SuppressWarnings("unchecked") // getting stuff from custom attributes has to be untyped.
- PlanBuilder planStepFactory = (PlanBuilder) plan.getCustomAttributes().get(STR_PLANSTEPFACTORY);
- if (planStepFactory == null) {
- this.plansNotFound++;
- return null;
- }
- this.plansFound++;
- final cadyts.demand.Plan planSteps = planStepFactory.getResult();
- return planSteps;
- }
-
- @Override
- public void reset(final int it) {
- this.iteration = it;
-
- log.warn("found " + this.plansFound + " out of " + (this.plansFound + this.plansNotFound) + " ("
- + (100. * this.plansFound / (this.plansFound + this.plansNotFound)) + "%)");
- log.warn("(above values may both be at zero for a couple of iterations if multiple plans per agent all have no score)");
-
- long nPlans = 0 ;
- long nMemorizedPlans = 0 ;
-
- for ( Person person : this.sc.getPopulation().getPersons().values() ) {
- for ( Plan plan : person.getPlans() ) {
- nPlans ++ ;
- @SuppressWarnings("unchecked") // getting stuff from custom attributes has to be untyped.
- PlanBuilder planStepFactory = (PlanBuilder) plan.getCustomAttributes().get(STR_PLANSTEPFACTORY);
- if ( planStepFactory!=null ) {
- nMemorizedPlans ++ ;
- }
- }
- }
-
- log.warn( "nPlans=" + nPlans + ", nMemorizedPlans=" + nMemorizedPlans );
-
- this.personsFromVehId.clear();
- this.transitDrivers.clear();
- this.transitVehicles.clear();
- }
-
- @Override
- public void handleEvent(final TransitDriverStartsEvent event) {
- if (this.calibratedLines.contains(event.getTransitLineId())) {
- this.transitDrivers.add(event.getDriverId());
- this.transitVehicles.add(event.getVehicleId());
- }
- }
-
- @Override
- public void handleEvent(final PersonEntersVehicleEvent event) {
- if (this.transitDrivers.contains(event.getPersonId()) || !this.transitVehicles.contains(event.getVehicleId())) {
- return; // ignore transit drivers or persons entering non-(analyzed-)transit vehicles
- }
- addPersonToVehicleContainer(event.getPersonId(), event.getVehicleId());
- }
-
- @Override
- public void handleEvent(final PersonLeavesVehicleEvent event) {
- if (this.transitDrivers.contains(event.getPersonId()) || !this.transitVehicles.contains(event.getVehicleId())) {
- return; // ignore transit drivers or persons entering non-(analyzed-)transit vehicles
- }
- removePersonFromVehicleContainer(event.getPersonId(), event.getVehicleId());
- }
-
- @Override
- public void handleEvent(final VehicleDepartsAtFacilityEvent event) {
- double time = event.getTime();
- Id vehId = event.getVehicleId();
- Id facId = event.getFacilityId();
- if (this.personsFromVehId.get(vehId) == null) {
- // (means nobody has entered the vehicle yet)
- return;
- }
- TransitStopFacility fac = this.schedule.getFacilities().get(facId);
-
- for (Id personId : this.personsFromVehId.get(vehId)) {
- // get the "Person" behind the id:
- Person person = this.sc.getPopulation().getPersons().get(personId);
-
- // get the selected plan:
- Plan selectedPlan = person.getSelectedPlan();
-
- // get the planStepFactory for the plan (or create one):
- PlanBuilder tmpPlanStepFactory = getPlanStepFactoryForPlan(selectedPlan);
-
- if (tmpPlanStepFactory != null) {
- // add the "turn" to the planStepfactory
- tmpPlanStepFactory.addTurn(fac, (int) time);
- }
- }
- }
-
- // ###################################################################################
- // only private functions below here (low level functionality)
-
- private void addPersonToVehicleContainer(final Id personId, final Id vehId) {
- // get the personsContainer that belongs to the vehicle:
- Collection personsInVehicle = this.personsFromVehId.get(vehId);
-
- if (personsInVehicle == null) {
- // means does not exist yet
- personsInVehicle = new ArrayList<>();
- this.personsFromVehId.put(vehId, personsInVehicle);
- }
-
- personsInVehicle.add(personId);
- }
-
- private void removePersonFromVehicleContainer(final Id personId, final Id vehId) {
- // get the personsContainer that belongs to the vehicle:
- Collection personsInVehicle = this.personsFromVehId.get(vehId);
-
- if (personsInVehicle == null) {
- throw new RuntimeException("should not be possible: person should enter before leaving, and then construct the container");
- }
-
- // remove the person from the personsContainer:
- personsInVehicle.remove(personId); // linear time operation; a HashMap might be better.
- }
-
- private PlanBuilder getPlanStepFactoryForPlan(final Plan selectedPlan) {
- PlanBuilder planStepFactory = null;
-
- planStepFactory = (PlanBuilder) selectedPlan.getCustomAttributes().get(STR_PLANSTEPFACTORY);
- Integer factoryIteration = (Integer) selectedPlan.getCustomAttributes().get(STR_ITERATION);
- if (planStepFactory == null || factoryIteration == null || factoryIteration != this.iteration) {
- // attach the iteration number to the plan:
- selectedPlan.getCustomAttributes().put(STR_ITERATION, this.iteration);
-
- // construct a new PlanBulder and attach it to the plan:
- planStepFactory = new PlanBuilder<>();
- selectedPlan.getCustomAttributes().put(STR_PLANSTEPFACTORY, planStepFactory);
-
- // memorize the plan as being seen:
- this.plansEverSeen.add(selectedPlan);
- }
-
- return planStepFactory;
- }
-
- static void printCadytsPlan(final cadyts.demand.Plan cadytsPlan) {
- // prints Cadyts plan
- String sepCadStr = "==printing Cadyts Plan==";
- System.err.println(sepCadStr);
- if (cadytsPlan != null) {
- for (int ii = 0; ii < cadytsPlan.size(); ii++) {
- cadyts.demand.PlanStep cadytsPlanStep = cadytsPlan.getStep(ii);
- System.err.println("stopId" + cadytsPlanStep.getLink().getId() + " time: " + cadytsPlanStep.getEntryTime_s());
- }
- } else {
- System.err.println(" cadyts plan is null ");
- }
- }
-
-}
diff --git a/contribs/cadytsIntegration/src/main/java/org/matsim/contrib/cadyts/pt/TransitStopFacilityLookUp.java b/contribs/cadytsIntegration/src/main/java/org/matsim/contrib/cadyts/pt/TransitStopFacilityLookUp.java
deleted file mode 100644
index 651b2a99c66..00000000000
--- a/contribs/cadytsIntegration/src/main/java/org/matsim/contrib/cadyts/pt/TransitStopFacilityLookUp.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/* *********************************************************************** *
- * project: org.matsim.* *
- * *
- * *********************************************************************** *
- * *
- * copyright : (C) 2008 by the members listed in the COPYING, *
- * LICENSE and WARRANTY file. *
- * email : info at matsim dot org *
- * *
- * *********************************************************************** *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * See also COPYING, LICENSE and WARRANTY file *
- * *
- * *********************************************************************** */
-package org.matsim.contrib.cadyts.pt;
-
-import org.matsim.api.core.v01.Id;
-import org.matsim.api.core.v01.Scenario;
-import org.matsim.contrib.cadyts.general.LookUpItemFromId;
-import org.matsim.pt.transitSchedule.api.TransitSchedule;
-import org.matsim.pt.transitSchedule.api.TransitStopFacility;
-
-/**
- * @author nagel
- *
- */
-class TransitStopFacilityLookUp implements LookUpItemFromId {
-
- private TransitSchedule schedule;
-
- public TransitStopFacilityLookUp( Scenario sc ) {
- this.schedule = sc.getTransitSchedule() ;
- }
-
- public TransitStopFacilityLookUp( TransitSchedule schedule ) {
- this.schedule = schedule ;
- }
-
- @Override
- public TransitStopFacility getItem(Id id) {
- return this.schedule.getFacilities().get(id);
- }
-
-}
diff --git a/contribs/cadytsIntegration/src/main/java/org/matsim/contrib/cadyts/pt/package-info.java b/contribs/cadytsIntegration/src/main/java/org/matsim/contrib/cadyts/pt/package-info.java
deleted file mode 100644
index 0b45babafa5..00000000000
--- a/contribs/cadytsIntegration/src/main/java/org/matsim/contrib/cadyts/pt/package-info.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/* *********************************************************************** *
- * project: org.matsim.* *
- * *
- * *********************************************************************** *
- * *
- * copyright : (C) 2008 by the members listed in the COPYING, *
- * LICENSE and WARRANTY file. *
- * email : info at matsim dot org *
- * *
- * *********************************************************************** *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * See also COPYING, LICENSE and WARRANTY file *
- * *
- * *********************************************************************** */
-/**
- * Integrates automatic calibration upon public transport line occupancies using Cadyts into MATSim.
- *
- * Entry point / How to use
- *
- * - Use
org.matsim.contrib.cadyts.pt.CadytsPtPlanStrategy
as a replanning strategy.
- * - Add the following configuration parameters (approximately; this has changed since inception;
- * check auto-generated config comments; use second config dump for that):
- *
- * <module name="cadytsPt">
- * <param name="startTime" value="05:00:00" />
- *
- * <param name="endTime" value="21:00:00" />
- *
- * <!-- Comma-separated list of transit lines to be calibrated. ->
- * <param name="calibratedLines" value="M44" />
- *
- * <param name="writeAnalysisFile" value="false" />
- *
- * <!-- see cadyts documentation for the meaning of the following values. -->
- * <param name="regressionInertia" value="0.95" />
- * <param name="minFlowStddevVehH" value="8.0" />
- * <param name="freezeIteration" value="2147483647" />
- * <param name="preparatoryIterations" value="1" />
- * <param name="varianceScale" value="1.0" />
- * <param name="useBruteForce" value="true" />
- *
- * </module>
- * These parameters are defined in {@link org.matsim.contrib.cadyts.general.CadytsConfigGroup}
- *
- *
- * - There also needs to be a ptCounts entry, something like:
- *
- *
- * <module name="ptCounts">
- * <param name="inputOccupancyCountsFile" value="path-to-counts-file" />
- * </module>
- * And (obviously) a working ptCounts file.
- *
- * - It is a unfortunate that the counts file takes measurements in hourly values, while cadyts takes arbitrary time spans.
- * (The cadyts convention seems more powerful, thus we did not want to reduce it to the "Counts" convention.)
- * As long as the cadytsPt timeBinSize is set to 3600, things should be straightforward, and there is also (I think) no
- * problem if there are measurements for times outside the cadytsPt startTime/endTime interval. yyyy Unfortunately,
- * I cannot remember how the counts file is interpreted once the cadytsPt timeBinSize is set to something different: Does the
- * Counts file than think in terms of time bins rather than in terms of hours? In fact, I think not; rather, it is probably as
- * follows: Counts still refer to hours. If, say, you use timeBinSize of 7200 and start/endTime as 05:00/09:00, then the code
- * will aggregate counts from the 6th and 7th hour into one time bin, etc. If things do not correspond, the code will probably
- * complain. See CadytsBuilder.buildCalibrator, since there are some consistency checks. (kai, oct'12)
- *
- Typically, {@link org.matsim.contrib.cadyts.pt.CadytsPtPlanStrategy} should be the only
- * plan strategy being used. So it is advised to first run the simulation until every
- * agent has a few (different) plans, and then do some iterations using only the
- * calibration strategy.
- *
- *
- */
-package org.matsim.contrib.cadyts.pt;
diff --git a/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/pt/CadytsPtIT.java b/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/pt/CadytsPtIT.java
deleted file mode 100644
index 9185653ccd5..00000000000
--- a/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/pt/CadytsPtIT.java
+++ /dev/null
@@ -1,689 +0,0 @@
-/* *********************************************************************** *
- * project: org.matsim.*
- * CadytsIntegrationTest.java
- * *
- * *********************************************************************** *
- * *
- * copyright : (C) 2011 by the members listed in the COPYING, *
- * LICENSE and WARRANTY file. *
- * email : info at matsim dot org *
- * *
- * *********************************************************************** *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * See also COPYING, LICENSE and WARRANTY file *
- * *
- * *********************************************************************** */
-
-package org.matsim.contrib.cadyts.pt;
-
-import cadyts.measurements.SingleLinkMeasurement;
-import cadyts.utilities.io.tabularFileParser.TabularFileParser;
-import cadyts.utilities.misc.DynamicData;
-import com.google.inject.Provider;
-import org.junit.Assert;
-import org.junit.Rule;
-import org.junit.Test;
-import org.matsim.api.core.v01.Id;
-import org.matsim.api.core.v01.Scenario;
-import org.matsim.api.core.v01.network.Link;
-import org.matsim.api.core.v01.network.Network;
-import org.matsim.api.core.v01.population.Person;
-import org.matsim.contrib.cadyts.general.CadytsConfigGroup;
-import org.matsim.contrib.cadyts.general.CadytsCostOffsetsXMLFileIO;
-import org.matsim.contrib.cadyts.general.CadytsPlanChanger;
-import org.matsim.contrib.cadyts.general.CadytsScoring;
-import org.matsim.contrib.cadyts.utils.CalibrationStatReader;
-import org.matsim.core.api.experimental.events.EventsManager;
-import org.matsim.core.config.Config;
-import org.matsim.core.config.ConfigUtils;
-import org.matsim.core.config.groups.ControllerConfigGroup.MobsimType;
-import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams;
-import org.matsim.core.config.groups.PlansConfigGroup.HandlingOfPlansWithoutRoutingMode;
-import org.matsim.core.config.groups.ReplanningConfigGroup.StrategySettings;
-import org.matsim.core.controler.AbstractModule;
-import org.matsim.core.controler.Controler;
-import org.matsim.core.mobsim.framework.Mobsim;
-import org.matsim.core.mobsim.framework.MobsimFactory;
-import org.matsim.core.replanning.PlanStrategy;
-import org.matsim.core.replanning.PlanStrategyImpl;
-import org.matsim.core.scenario.ScenarioUtils;
-import org.matsim.core.scoring.ScoringFunction;
-import org.matsim.core.scoring.ScoringFunctionFactory;
-import org.matsim.core.scoring.SumScoringFunction;
-import org.matsim.core.scoring.functions.CharyparNagelActivityScoring;
-import org.matsim.core.scoring.functions.CharyparNagelAgentStuckScoring;
-import org.matsim.core.scoring.functions.CharyparNagelLegScoring;
-import org.matsim.core.scoring.functions.ScoringParameters;
-import org.matsim.core.scoring.functions.ScoringParametersForPerson;
-import org.matsim.counts.Count;
-import org.matsim.counts.Counts;
-import org.matsim.counts.MatsimCountsReader;
-import org.matsim.pt.transitSchedule.api.TransitSchedule;
-import org.matsim.pt.transitSchedule.api.TransitStopFacility;
-import org.matsim.testcases.MatsimTestUtils;
-
-import jakarta.inject.Inject;
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Set;
-
-public class CadytsPtIT {
-
- @Rule
- public MatsimTestUtils utils = new MatsimTestUtils();
-
- @Test
- public final void testInitialization() {
- String inputDir = this.utils.getClassInputDirectory();
-
- Config config = createTestConfig(inputDir, this.utils.getOutputDirectory());
- config.controller().setLastIteration(0);
- StrategySettings stratSets = new StrategySettings();
- stratSets.setStrategyName("ccc") ;
- stratSets.setWeight(1.) ;
- config.replanning().addStrategySettings(stratSets) ;
-
- final Scenario scenario = ScenarioUtils.loadScenario(config) ;
- final Controler controler = new Controler(scenario);
- controler.addOverridingModule(new CadytsPtModule());
- controler.addOverridingModule(new AbstractModule() {
- @Override
- public void install() {
- addPlanStrategyBinding("ccc").toProvider(new jakarta.inject.Provider() {
- @Inject CadytsPtContext context;
- @Override
- public PlanStrategy get() {
- return new PlanStrategyImpl(new CadytsPlanChanger<>(scenario, context));
- }
- });
- }
- });
-
- controler.getConfig().controller().setCreateGraphs(false);
- controler.getConfig().controller().setWriteEventsInterval(0);
- controler.getConfig().controller().setDumpDataAtEnd(true);
- controler.addOverridingModule(new AbstractModule() {
- @Override
- public void install() {
- bindMobsim().toProvider(new Provider() {
- @Override
- public Mobsim get() {
- return new DummyMobsimFactory().createMobsim(controler.getScenario(), controler.getEvents());
- }
- });
- }
- });
- controler.run();
-
- CadytsPtContext context = controler.getInjector().getInstance(CadytsPtContext.class);
-
- //test calibration settings
- Assert.assertEquals(true, context.getCalibrator().getBruteForce());
- Assert.assertEquals(false, context.getCalibrator().getCenterRegression());
- Assert.assertEquals(Integer.MAX_VALUE, context.getCalibrator().getFreezeIteration());
- Assert.assertEquals(8.0, context.getCalibrator().getMinStddev(SingleLinkMeasurement.TYPE.FLOW_VEH_H), MatsimTestUtils.EPSILON);
- Assert.assertEquals(1, context.getCalibrator().getPreparatoryIterations());
- Assert.assertEquals(0.95, context.getCalibrator().getRegressionInertia(), MatsimTestUtils.EPSILON);
- Assert.assertEquals(1.0, context.getCalibrator().getVarianceScale(), MatsimTestUtils.EPSILON);
- Assert.assertEquals(3600.0, context.getCalibrator().getTimeBinSize_s(), MatsimTestUtils.EPSILON);
- }
-
-
- @Test
- public final void testCalibrationAsScoring() throws IOException {
- final double beta=30. ;
- final int lastIteration = 20 ;
-
- String inputDir = this.utils.getClassInputDirectory();
- String outputDir = this.utils.getOutputDirectory();
-
- final Config config = createTestConfig(inputDir, outputDir);
-
- config.controller().setLastIteration(lastIteration) ;
-
- config.scoring().setBrainExpBeta(beta) ;
-
- StrategySettings stratSets = new StrategySettings() ;
- stratSets.setStrategyName("ChangeExpBeta") ;
- stratSets.setWeight(1.0) ;
- config.replanning().addStrategySettings(stratSets) ;
-
- // ===
-
- final Controler controler = new Controler(config);
- controler.getConfig().controller().setCreateGraphs(false);
- controler.addOverridingModule(new CadytsPtModule());
-
- controler.setScoringFunctionFactory(new ScoringFunctionFactory() {
- @Inject ScoringParametersForPerson parameters;
- @Inject Network network;
- @Inject CadytsPtContext cContext;
- @Override
- public ScoringFunction createNewScoringFunction(Person person) {
- final ScoringParameters params = parameters.getScoringParameters(person);
-
- SumScoringFunction scoringFunctionAccumulator = new SumScoringFunction();
- scoringFunctionAccumulator.addScoringFunction(new CharyparNagelLegScoring(params, network, config.transit().getTransitModes()));
- scoringFunctionAccumulator.addScoringFunction(new CharyparNagelActivityScoring(params)) ;
- scoringFunctionAccumulator.addScoringFunction(new CharyparNagelAgentStuckScoring(params));
-
- final CadytsScoring scoringFunction = new CadytsScoring(person.getSelectedPlan() ,config, cContext);
- scoringFunction.setWeightOfCadytsCorrection(beta*30.) ;
- scoringFunctionAccumulator.addScoringFunction(scoringFunction );
-
- return scoringFunctionAccumulator;
- }
- }) ;
-
- controler.run();
-
- //scenario data test
- Assert.assertNotNull("Config is null" , controler.getConfig());
- Assert.assertEquals("Different number of links in network.", controler.getScenario().getNetwork().getLinks().size() , 23 );
- Assert.assertEquals("Different number of nodes in network.", controler.getScenario().getNetwork().getNodes().size() , 15 );
- Assert.assertNotNull("Transit schedule is null.", controler.getScenario().getTransitSchedule());
- Assert.assertEquals("Num. of trLines is wrong.", 2, controler.getScenario().getTransitSchedule().getTransitLines().size() );
- Assert.assertEquals("Num of facilities in schedule is wrong.", controler.getScenario().getTransitSchedule().getFacilities().size() , 5);
- Assert.assertNotNull("Population is null.", controler.getScenario().getPopulation());
- Assert.assertEquals("Num. of persons in population is wrong.", controler.getScenario().getPopulation().getPersons().size() , 4);
- Assert.assertEquals("Scale factor is wrong.", controler.getScenario().getConfig().ptCounts().getCountsScaleFactor(), 1.0, MatsimTestUtils.EPSILON);
- // Assert.assertEquals("Distance filter is wrong.", controler.getTestScenarioURL().getConfig().ptCounts().getDistanceFilter() , 30000.0, MatsimTestUtils.EPSILON);
- // Assert.assertEquals("DistanceFilterCenterNode is wrong.", controler.getTestScenarioURL().getConfig().ptCounts().getDistanceFilterCenterNode(), "7");
- //counts
- Assert.assertEquals("Occupancy count file is wrong.", controler.getScenario().getConfig().ptCounts().getOccupancyCountsFileName(), inputDir + "counts/counts_occupancy.xml");
- Counts occupCounts = new Counts();
- new MatsimCountsReader(occupCounts).readFile(controler.getScenario().getConfig().ptCounts().getOccupancyCountsFileName());
- Count count = occupCounts.getCount(Id.create("stop1", Link.class)); // casting id from stop to link, not nice
- Assert.assertEquals("Occupancy counts description is wrong", occupCounts.getDescription(), "counts values for equil net");
- Assert.assertEquals("CsId is wrong.", count.getCsLabel() , "stop1");
- Assert.assertEquals("Volume of hour 4 is wrong", count.getVolume(7).getValue(), 4.0 , MatsimTestUtils.EPSILON);
- Assert.assertEquals("Max count volume is wrong.", count.getMaxVolume().getValue(), 4.0 , MatsimTestUtils.EPSILON);
-
- // test resulting simulation volumes
- {
- String outCounts = outputDir + "ITERS/it." + lastIteration + "/" + lastIteration + ".simCountCompareOccupancy.txt";
- CountsReaderPt reader = new CountsReaderPt(outCounts);
- double[] simValues;
- double[] realValues;
-
- Id stopId1 = Id.create("stop1", TransitStopFacility.class);
- simValues = reader.getSimulatedValues(stopId1);
- realValues= reader.getRealValues(stopId1);
- Assert.assertEquals("Volume of hour 6 is wrong", 4.0, simValues[6], MatsimTestUtils.EPSILON);
- Assert.assertEquals("Volume of hour 6 is wrong", 4.0, realValues[6], MatsimTestUtils.EPSILON);
-
- Id stopId2 = Id.create("stop2", TransitStopFacility.class);
- simValues = reader.getSimulatedValues(stopId2);
- realValues= reader.getRealValues(stopId2);
-// Assert.assertEquals("Volume of hour 6 is wrong", 0.0, simValues[6], MatsimTestUtils.EPSILON);
- Assert.assertEquals("Volume of hour 6 is wrong", 2.0, simValues[6], MatsimTestUtils.EPSILON); // Altered after using ChangeExpBeta instead of "ccc"
- Assert.assertEquals("Volume of hour 6 is wrong", 1.0, realValues[6] , MatsimTestUtils.EPSILON);
-
- Id stopId6 = Id.create("stop6", TransitStopFacility.class);
- simValues = reader.getSimulatedValues(stopId6);
- realValues= reader.getRealValues(stopId6);
- Assert.assertEquals("Volume of hour 6 is wrong", 0.0, simValues[6], MatsimTestUtils.EPSILON);
- Assert.assertEquals("Volume of hour 6 is wrong", 2.0, realValues[6], MatsimTestUtils.EPSILON);
-
- Id stopId10 = Id.create("stop10", TransitStopFacility.class);
- simValues = reader.getSimulatedValues(stopId10);
- realValues= reader.getRealValues(stopId10);
-// Assert.assertEquals("Volume of hour 6 is wrong", 4.0, simValues[6], MatsimTestUtils.EPSILON);
- Assert.assertEquals("Volume of hour 6 is wrong", 2.0, simValues[6], MatsimTestUtils.EPSILON); // Altered after using ChangeExpBeta instead of "ccc"
- Assert.assertEquals("Volume of hour 6 is wrong", 5.0, realValues[6], MatsimTestUtils.EPSILON);
-
- // test calibration statistics
- String testCalibStatPath = outputDir + "calibration-stats.txt";
- CalibrationStatReader calibrationStatReader = new CalibrationStatReader();
- new TabularFileParser().parse(testCalibStatPath, calibrationStatReader);
-
- CalibrationStatReader.StatisticsData outStatData= calibrationStatReader.getCalStatMap().get(lastIteration);
-// Assert.assertEquals("different Count_ll", "-0.046875", outStatData.getCount_ll() );
- Assert.assertEquals("different Count_ll", "-0.109375", outStatData.getCount_ll() ); // Altered after using ChangeExpBeta instead of "ccc"
-// Assert.assertEquals("different Count_ll_pred_err", "0.01836234363152515" , outStatData.getCount_ll_pred_err() );
- Assert.assertEquals("different Count_ll_pred_err", "0.008411478550953913" , outStatData.getCount_ll_pred_err() ); // Altered after using ChangeExpBeta instead of "ccc"
- // Assert.assertEquals("different Link_lambda_avg", "-2.2604922388914356E-10", outStatData.getLink_lambda_avg() );
- // Assert.assertEquals("different Link_lambda_max", "0.0" , outStatData.getLink_lambda_max() );
- // Assert.assertEquals("different Link_lambda_min", "-7.233575164452593E-9", outStatData.getLink_lambda_min() );
- // Assert.assertEquals("different Link_lambda_stddev", "1.261054219517188E-9", outStatData.getLink_lambda_stddev());
- // Assert.assertEquals("different P2p_ll", "--" , outStatData.getP2p_ll());
- // Assert.assertEquals("different Plan_lambda_avg", "-7.233575164452594E-9", outStatData.getPlan_lambda_avg() );
- // Assert.assertEquals("different Plan_lambda_max", "-7.233575164452593E-9" , outStatData.getPlan_lambda_max() );
- // Assert.assertEquals("different Plan_lambda_min", "-7.233575164452593E-9" , outStatData.getPlan_lambda_min() );
- // Assert.assertEquals("different Plan_lambda_stddev", "0.0" , outStatData.getPlan_lambda_stddev());
-// Assert.assertEquals("different Total_ll", "-0.046875", outStatData.getTotal_ll() );
- Assert.assertEquals("different Total_ll", "-0.109375", outStatData.getTotal_ll() ); // Altered after using ChangeExpBeta instead of "ccc"
-
-
- //test link offsets
- final TransitSchedule schedule = controler.getScenario().getTransitSchedule();
- String linkOffsetFile = outputDir + "ITERS/it." + lastIteration + "/" + lastIteration + ".linkCostOffsets.xml";
- // CadytsPtLinkCostOffsetsXMLFileIO offsetReader = new CadytsPtLinkCostOffsetsXMLFileIO (schedule);
- CadytsCostOffsetsXMLFileIO offsetReader
- = new CadytsCostOffsetsXMLFileIO (new TransitStopFacilityLookUp(controler.getScenario()), TransitStopFacility.class);
- DynamicData stopOffsets = offsetReader.read(linkOffsetFile);
-
- TransitStopFacility stop2 = schedule.getFacilities().get(stopId2);
- TransitStopFacility stop10 = schedule.getFacilities().get(stopId10);
-
- //find first offset value different from null to compare. Useful to test with different time bin sizes
- int binIndex=-1;
- boolean isZero;
- do {
- binIndex++;
- isZero = (Math.abs(stopOffsets.getBinValue(stop2 , binIndex) - 0.0) < MatsimTestUtils.EPSILON);
- } while (isZero && binIndex<86400);
-
- Assert.assertEquals("Wrong bin index for first link offset", 6, binIndex);
-// Assert.assertEquals("Wrong link offset of stop 10", 0.03515757824042241, stopOffsets.getBinValue(stop10 , binIndex), MatsimTestUtils.EPSILON);
- Assert.assertEquals("Wrong link offset of stop 10", 0.022383938774904025, stopOffsets.getBinValue(stop10 , binIndex), MatsimTestUtils.EPSILON); // Altered after using ChangeExpBeta instead of "ccc"
-// Assert.assertEquals("Wrong link offset of stop 2", -0.011353248321030008, stopOffsets.getBinValue(stop2 , binIndex), MatsimTestUtils.EPSILON);
- Assert.assertEquals("Wrong link offset of stop 2", -0.008477236625252698, stopOffsets.getBinValue(stop2 , binIndex), MatsimTestUtils.EPSILON); // Altered after using ChangeExpBeta instead of "ccc"
- }
- }
-
-
- @Test
- public final void testCalibration() throws IOException {
- final double beta = 30. ;
- final int lastIteration = 20 ;
-
- String inputDir = this.utils.getClassInputDirectory();
- String outputDir = this.utils.getOutputDirectory();
-
- Config config = createTestConfig(inputDir, outputDir) ;
-
- config.controller().setWriteEventsInterval(0) ;
- config.controller().setLastIteration(lastIteration) ;
- // seems to need 15 iterations as "warm-up"; at least the cadyts corrections are much smaller until then.
-
- config.scoring().setBrainExpBeta(beta) ;
-
- StrategySettings stratSets = new StrategySettings();
- stratSets.setStrategyName("ccc") ;
- stratSets.setWeight(1.) ;
- config.replanning().addStrategySettings(stratSets) ;
-
- final Scenario scenario = ScenarioUtils.loadScenario(config) ;
-
- final Controler controler = new Controler( scenario );
- controler.getConfig().controller().setCreateGraphs(false);
- controler.getConfig().controller().setDumpDataAtEnd(true);
-
- controler.addOverridingModule(new CadytsPtModule());
- controler.addOverridingModule(new AbstractModule() {
- @Override
- public void install() {
- addPlanStrategyBinding("ccc").toProvider(new jakarta.inject.Provider() {
- @Inject CadytsPtContext context;
- @Override
- public PlanStrategy get() {
- final CadytsPlanChanger planSelector = new CadytsPlanChanger(scenario, context);
- planSelector.setCadytsWeight(beta * 30.);
- return new PlanStrategyImpl(planSelector);
- }
- });
- }
- });
-
- controler.run();
-
- //scenario data test
- Assert.assertNotNull("config is null" , controler.getConfig());
- Assert.assertEquals("Different number of links in network.", controler.getScenario().getNetwork().getLinks().size() , 23 );
- Assert.assertEquals("Different number of nodes in network.", controler.getScenario().getNetwork().getNodes().size() , 15 );
- Assert.assertNotNull("Transit schedule is null.", controler.getScenario().getTransitSchedule());
- Assert.assertEquals("Num. of trLines is wrong.", 2, controler.getScenario().getTransitSchedule().getTransitLines().size() );
- Assert.assertEquals("Num of facilities in schedule is wrong.", controler.getScenario().getTransitSchedule().getFacilities().size() , 5);
- Assert.assertNotNull("Population is null.", controler.getScenario().getPopulation());
- Assert.assertEquals("Num. of persons in population is wrong.", controler.getScenario().getPopulation().getPersons().size() , 4);
- Assert.assertEquals("Scale factor is wrong.", controler.getScenario().getConfig().ptCounts().getCountsScaleFactor(), 1.0, MatsimTestUtils.EPSILON);
- // Assert.assertEquals("Distance filter is wrong.", controler.getTestScenarioURL().getConfig().ptCounts().getDistanceFilter() , 30000.0, MatsimTestUtils.EPSILON);
- // Assert.assertEquals("DistanceFilterCenterNode is wrong.", controler.getTestScenarioURL().getConfig().ptCounts().getDistanceFilterCenterNode(), "7");
- //counts
- Assert.assertEquals("Occupancy count file is wrong.", controler.getScenario().getConfig().ptCounts().getOccupancyCountsFileName(), inputDir + "counts/counts_occupancy.xml");
- Counts occupCounts = new Counts();
- new MatsimCountsReader(occupCounts).readFile(controler.getScenario().getConfig().ptCounts().getOccupancyCountsFileName());
- Count count = occupCounts.getCount(Id.create("stop1", Link.class)); // casting the id from a stop to a link, not nice..
- Assert.assertEquals("Occupancy counts description is wrong", occupCounts.getDescription(), "counts values for equil net");
- Assert.assertEquals("CsId is wrong.", count.getCsLabel() , "stop1");
- Assert.assertEquals("Volume of hour 4 is wrong", count.getVolume(7).getValue(), 4.0 , MatsimTestUtils.EPSILON);
- Assert.assertEquals("Max count volume is wrong.", count.getMaxVolume().getValue(), 4.0 , MatsimTestUtils.EPSILON);
-
- // test resulting simulation volumes
- {
- String outCounts = outputDir + "ITERS/it." + lastIteration + "/" + lastIteration + ".simCountCompareOccupancy.txt";
- CountsReaderPt reader = new CountsReaderPt(outCounts);
- double[] simValues;
- double[] realValues;
-
- Id stopId1 = Id.create("stop1", TransitStopFacility.class);
- simValues = reader.getSimulatedValues(stopId1);
- realValues= reader.getRealValues(stopId1);
- Assert.assertEquals("Volume of hour 6 is wrong", 4.0, simValues[6], MatsimTestUtils.EPSILON);
- Assert.assertEquals("Volume of hour 6 is wrong", 4.0, realValues[6], MatsimTestUtils.EPSILON);
-
- Id stopId2 = Id.create("stop2", TransitStopFacility.class);
- simValues = reader.getSimulatedValues(stopId2);
- realValues= reader.getRealValues(stopId2);
- Assert.assertEquals("Volume of hour 6 is wrong", 0.0, simValues[6], MatsimTestUtils.EPSILON);
- Assert.assertEquals("Volume of hour 6 is wrong", 1.0, realValues[6] , MatsimTestUtils.EPSILON);
-
- Id stopId6 = Id.create("stop6", TransitStopFacility.class);
- simValues = reader.getSimulatedValues(stopId6);
- realValues= reader.getRealValues(stopId6);
- Assert.assertEquals("Volume of hour 6 is wrong", 0.0, simValues[6], MatsimTestUtils.EPSILON);
- Assert.assertEquals("Volume of hour 6 is wrong", 2.0, realValues[6], MatsimTestUtils.EPSILON);
-
- Id stopId10 = Id.create("stop10", TransitStopFacility.class);
- simValues = reader.getSimulatedValues(stopId10);
- realValues= reader.getRealValues(stopId10);
- Assert.assertEquals("Volume of hour 6 is wrong", 4.0, simValues[6], MatsimTestUtils.EPSILON);
- Assert.assertEquals("Volume of hour 6 is wrong", 5.0, realValues[6], MatsimTestUtils.EPSILON);
-
- // test calibration statistics
- String testCalibStatPath = outputDir + "calibration-stats.txt";
- CalibrationStatReader calibrationStatReader = new CalibrationStatReader();
- new TabularFileParser().parse(testCalibStatPath, calibrationStatReader);
-
- CalibrationStatReader.StatisticsData outStatData= calibrationStatReader.getCalStatMap().get(lastIteration);
- Assert.assertEquals("different Count_ll", "-0.046875", outStatData.getCount_ll() );
- Assert.assertEquals("different Count_ll_pred_err", "0.008670972399424905" , outStatData.getCount_ll_pred_err() );
- Assert.assertEquals("different Link_lambda_avg", "3.642292018550638E-4", outStatData.getLink_lambda_avg() );
- Assert.assertEquals("different Link_lambda_max", "0.032081715026130615" , outStatData.getLink_lambda_max() );
- Assert.assertEquals("different Link_lambda_min", "-0.008771046107406533", outStatData.getLink_lambda_min() );
- Assert.assertEquals("different Link_lambda_stddev", "0.0041495140513996154", outStatData.getLink_lambda_stddev());
- Assert.assertEquals("different P2p_ll", "--" , outStatData.getP2p_ll());
- Assert.assertEquals("different Plan_lambda_avg", "0.011655334459362041", outStatData.getPlan_lambda_avg() );
- Assert.assertEquals("different Plan_lambda_max", "0.032081715026130615" , outStatData.getPlan_lambda_max() );
- Assert.assertEquals("different Plan_lambda_min", "-0.008771046107406533" , outStatData.getPlan_lambda_min() );
- Assert.assertEquals("different Plan_lambda_stddev", "0.02183671935220152" , outStatData.getPlan_lambda_stddev());
- Assert.assertEquals("different Total_ll", "-0.046875", outStatData.getTotal_ll() );
-
- //test link offsets
- final TransitSchedule schedule = controler.getScenario().getTransitSchedule();
- String linkOffsetFile = outputDir + "ITERS/it." + lastIteration + "/" + lastIteration + ".linkCostOffsets.xml";
- // CadytsPtLinkCostOffsetsXMLFileIO offsetReader = new CadytsPtLinkCostOffsetsXMLFileIO (schedule);
- CadytsCostOffsetsXMLFileIO offsetReader
- = new CadytsCostOffsetsXMLFileIO (new TransitStopFacilityLookUp(controler.getScenario()), TransitStopFacility.class);
- DynamicData stopOffsets = offsetReader.read(linkOffsetFile);
-
- TransitStopFacility stop2 = schedule.getFacilities().get(stopId2);
- TransitStopFacility stop10 = schedule.getFacilities().get(stopId10);
-
- //find first offset value different from null to compare. Useful to test with different time bin sizes
- int binIndex=-1;
- boolean isZero;
- do {
- binIndex++;
- isZero = (Math.abs(stopOffsets.getBinValue(stop2 , binIndex) - 0.0) < MatsimTestUtils.EPSILON);
- }while (isZero && binIndex<86400);
-
- Assert.assertEquals("Wrong bin index for first link offset", 6, binIndex);
- Assert.assertEquals("Wrong link offset of stop 10", 0.031842616249416734, stopOffsets.getBinValue(stop10 , binIndex), MatsimTestUtils.EPSILON);
- Assert.assertEquals("Wrong link offset of stop 2", -0.0079478186053482, stopOffsets.getBinValue(stop2 , binIndex), MatsimTestUtils.EPSILON);
- }
- }
-
-
- /**
- * @author mmoyo
- */
- @Test
- public final void testCalibrationTwo() throws IOException {
- // yyyy I cannot fully certify that this test is doing something reasonable, since simCountComparisonOccupancy.txt and
- // cadytsSimCountComparisonOccupancy.txt are returning different results. kai, feb'13
- // There is a comment in CadytsContext that the "cadyts" version may be wrong for time bins different from one hour. kai, dec'13
-
- final double beta = 30. ;
- final int lastIteration = 20 ;
-
- String inputDir = this.utils.getClassInputDirectory();
- String outputDir = this.utils.getOutputDirectory();
-
- Config config = createTestConfig(inputDir, this.utils.getOutputDirectory());
-
- config.controller().setLastIteration(lastIteration) ;
- config.controller().setWritePlansInterval(1) ;
- config.controller().setWriteEventsInterval(1) ;
-
- config.ptCounts().setPtCountsInterval(1) ;
-
- StrategySettings stratSets = new StrategySettings();
- stratSets.setStrategyName("ccc") ;
- stratSets.setWeight(1.) ;
- config.replanning().addStrategySettings(stratSets) ;
-
- CadytsConfigGroup cConfig = (CadytsConfigGroup) config.getModule(CadytsConfigGroup.GROUP_NAME) ;
- cConfig.setTimeBinSize(7200) ;
-
- // ---
-
- final Controler controler = new Controler(config);
- controler.addOverridingModule(new CadytsPtModule());
-// controler.setOverwriteFiles(true);
- controler.addOverridingModule(new AbstractModule() {
- @Override
- public void install() {
- addPlanStrategyBinding("ccc").toProvider(new jakarta.inject.Provider() {
- @Inject Scenario scenario;
- @Inject CadytsPtContext context;
- @Override
- public PlanStrategy get() {
- final CadytsPlanChanger planSelector = new CadytsPlanChanger(scenario, context);
- planSelector.setCadytsWeight(beta * 30.);
- return new PlanStrategyImpl(planSelector);
- }
- });
- }
- });
-
- controler.getConfig().controller().setCreateGraphs(false);
- controler.getConfig().controller().setWriteEventsInterval(0);
- controler.getConfig().controller().setDumpDataAtEnd(true);
- controler.run();
-
- // ====================================
-
- //scenario data test
- Assert.assertNotNull("config is null" , controler.getConfig());
- Assert.assertEquals("Different number of links in network.", controler.getScenario().getNetwork().getLinks().size() , 23 );
- Assert.assertEquals("Different number of nodes in network.", controler.getScenario().getNetwork().getNodes().size() , 15 );
- Assert.assertNotNull("Transit schedule is null.", controler.getScenario().getTransitSchedule());
- Assert.assertEquals("Num. of trLines is wrong.", 2, controler.getScenario().getTransitSchedule().getTransitLines().size() );
- Assert.assertEquals("Num of facilities in schedule is wrong.", controler.getScenario().getTransitSchedule().getFacilities().size() , 5);
- Assert.assertNotNull("Population is null.", controler.getScenario().getPopulation());
- Assert.assertEquals("Num. of persons in population is wrong.", controler.getScenario().getPopulation().getPersons().size() , 4);
- Assert.assertEquals("Scale factor is wrong.", controler.getScenario().getConfig().ptCounts().getCountsScaleFactor(), 1.0, MatsimTestUtils.EPSILON);
- // Assert.assertEquals("Distance filter is wrong.", controler.getTestScenarioURL().getConfig().ptCounts().getDistanceFilter() , 30000.0, MatsimTestUtils.EPSILON);
- // Assert.assertEquals("DistanceFilterCenterNode is wrong.", controler.getTestScenarioURL().getConfig().ptCounts().getDistanceFilterCenterNode(), "7");
- //counts
- Assert.assertEquals("Occupancy count file is wrong.", controler.getScenario().getConfig().ptCounts().getOccupancyCountsFileName(), inputDir + "counts/counts_occupancy.xml");
- Counts occupCounts = new Counts();
- new MatsimCountsReader(occupCounts).readFile(controler.getScenario().getConfig().ptCounts().getOccupancyCountsFileName());
- Count count = occupCounts.getCount(Id.create("stop1", Link.class));
- Assert.assertEquals("Occupancy counts description is wrong", occupCounts.getDescription(), "counts values for equil net");
- Assert.assertEquals("CsId is wrong.", count.getCsLabel() , "stop1");
-
- Assert.assertEquals("Volume of hour 4 is wrong", count.getVolume(7).getValue(), 4.0 , MatsimTestUtils.EPSILON);
- // yy I don't know why it says "hour 4" but "getVolume(7)". kai, sep'14
-
- Assert.assertEquals("Max count volume is wrong.", count.getMaxVolume().getValue(), 4.0 , MatsimTestUtils.EPSILON);
-
- // test resulting simulation volumes
- String outCounts = outputDir + "ITERS/it." + lastIteration + "/" + lastIteration + ".simCountCompareOccupancy.txt";
- CountsReaderPt reader = new CountsReaderPt(outCounts);
- Id stopId1 = Id.create("stop1", TransitStopFacility.class);
- {
- double[] simValues = reader.getSimulatedValues(stopId1);
- double[] realValues= reader.getRealValues(stopId1);
- Assert.assertEquals("Volume of hour 6 (probably: 7) is wrong", 4.0, simValues[6], MatsimTestUtils.EPSILON);
- Assert.assertEquals("Volume of hour 6 (probably: 7) is wrong", 4.0, realValues[6], MatsimTestUtils.EPSILON);
- }
- Id stopId2 = Id.create("stop2", TransitStopFacility.class);
- {
- double[] simValues = reader.getSimulatedValues(stopId2);
- double[] realValues= reader.getRealValues(stopId2);
- Assert.assertEquals("Volume of hour 6 (probably: 7) is wrong", 0.0, simValues[6], MatsimTestUtils.EPSILON);
- Assert.assertEquals("Volume of hour 6 (probably: 7) is wrong", 1.0, realValues[6] , MatsimTestUtils.EPSILON);
- }
- Id stopId6 = Id.create("stop6", TransitStopFacility.class);
- {
- double[] simValues = reader.getSimulatedValues(stopId6);
- double[] realValues= reader.getRealValues(stopId6);
- Assert.assertEquals("Volume of hour 6 (probably: 7) is wrong", 0.0, simValues[6], MatsimTestUtils.EPSILON);
- Assert.assertEquals("Volume of hour 6 (probably: 7) is wrong", 2.0, realValues[6], MatsimTestUtils.EPSILON);
- }
- Id stopId10 = Id.create("stop10", TransitStopFacility.class);
- {
- double[] simValues = reader.getSimulatedValues(stopId10);
- double[] realValues= reader.getRealValues(stopId10);
- Assert.assertEquals("Volume of hour 6 (probably: 7) is wrong", 4.0, simValues[6], MatsimTestUtils.EPSILON);
- Assert.assertEquals("Volume of hour 6 (probably: 7) is wrong", 5.0, realValues[6], MatsimTestUtils.EPSILON);
- }
- // 2 bus lines, one using stops 1, 2, 12, the other using 1, 10, 12. Counts say:
- // stop1: 4 (should always be satisfied)
- // stop2: 1 (should be possible to satisfy bus see below)
- // stop6: 2 (not possible to satisfy (no line going there))
- // stop10: 5 (not possible to satisfy (we have not enough plans) but see below)
- // and they say this at h=7 (which may, or may not, be the entry "6" in the counts array, but then the error messages are wrong).
- //
- // stop2 and stop10 are pulling in different directions; would need 7 plans to satisfy but have only 4. Satisfying the higher
- // volume station better is the cadyts-conforming solution.
-
- // test calibration statistics
- String testCalibStatPath = outputDir + "calibration-stats.txt";
- CalibrationStatReader calibrationStatReader = new CalibrationStatReader();
- new TabularFileParser().parse(testCalibStatPath, calibrationStatReader);
-
- CalibrationStatReader.StatisticsData outStatData= calibrationStatReader.getCalStatMap().get(lastIteration);
- // Assert.assertEquals("different Count_ll", "-0.01171875", outStatData.getCount_ll() );
- // Assert.assertEquals("different Count_ll_pred_err", "0.004590585907794875" , outStatData.getCount_ll_pred_err() );
- // Assert.assertEquals("different Link_lambda_avg", "-1.8081427328702926E-9", outStatData.getLink_lambda_avg() );
- // Assert.assertEquals("different Link_lambda_max", "0.0" , outStatData.getLink_lambda_max() );
- // Assert.assertEquals("different Link_lambda_min", "-1.4465142715757458E-8", outStatData.getLink_lambda_min() );
- // Assert.assertEquals("different Link_lambda_stddev", "4.501584893410135E-9" , outStatData.getLink_lambda_stddev());
- // Assert.assertEquals("different P2p_ll", "--" , outStatData.getP2p_ll());
- // Assert.assertEquals("different Plan_lambda_avg", "-2.5313998260184097E-8", outStatData.getPlan_lambda_avg() );
- // Assert.assertEquals("different Plan_lambda_max", "-2.5313998260184097E-8" , outStatData.getPlan_lambda_max() );
- // Assert.assertEquals("different Plan_lambda_min", "-2.5313998260184097E-8" , outStatData.getPlan_lambda_min() );
- // Assert.assertEquals("different Plan_lambda_stddev", "NaN" , outStatData.getPlan_lambda_stddev());
- // Assert.assertEquals("different Total_ll", "-0.01171875", outStatData.getTotal_ll() );
- //
- // I think that the above quantities change when changing between FLOW_VEH_H and COUNT_VEH. The calibration result, though,
- // seems the same.
-
-
- //test link offsets
- final TransitSchedule schedule = controler.getScenario().getTransitSchedule();
- CadytsCostOffsetsXMLFileIO offsetReader =
- new CadytsCostOffsetsXMLFileIO (new TransitStopFacilityLookUp(controler.getScenario()), TransitStopFacility.class);
- DynamicData stopOffsets =
- offsetReader.read(outputDir + "ITERS/it." + lastIteration + "/" + lastIteration + ".linkCostOffsets.xml");
-
- TransitStopFacility stop1 = schedule.getFacilities().get(stopId1);
- TransitStopFacility stop2 = schedule.getFacilities().get(stopId2);
- //TransitStopFacility stop6 = schedule.getFacilities().get(stopId6);
- TransitStopFacility stop10 = schedule.getFacilities().get(stopId10);
-
- //find first offset value different from zero to compare. Useful to test with different time bin sizes
- int binIndex=-1;
- boolean isZero;
- do {
- binIndex++;
- isZero = (Math.abs(stopOffsets.getBinValue(stop2 , binIndex) - 0.0) < MatsimTestUtils.EPSILON);
- }while (isZero && binIndex<86400);
-
- Assert.assertEquals("Wrong Bin index for first link offset", 3, binIndex); // bin size = 3600; fix! //done manuel jul.2012
- Assert.assertEquals("Wrong link offset of stop 1", 0.0, stopOffsets.getBinValue(stop1 , binIndex), MatsimTestUtils.EPSILON);
-// Assert.assertEquals("Wrong link offset of stop 2", -0.0028383120802772956, stopOffsets.getBinValue(stop2 , binIndex), MatsimTestUtils.EPSILON);
-// Assert.assertEquals("Wrong link offset of stop 10", 0.00878939456017082, stopOffsets.getBinValue(stop10 , binIndex), MatsimTestUtils.EPSILON);
-
- Assert.assertTrue("Offset at stop 2 has wrong sign.", stopOffsets.getBinValue(stop2, binIndex) < 0. ) ;
- Assert.assertTrue("Offset at stop 10 has wrong sign.", stopOffsets.getBinValue(stop10, binIndex) > 0. ) ;
- }
-
-
- private static Config createTestConfig(String inputDir, String outputDir) {
- Config config = ConfigUtils.createConfig() ;
- // ---
- config.global().setRandomSeed(4711) ;
- // ---
- config.network().setInputFile(inputDir + "network.xml") ;
- // ---
- config.plans().setInputFile(inputDir + "4plans.xml") ;
- config.plans().setHandlingOfPlansWithoutRoutingMode(HandlingOfPlansWithoutRoutingMode.useMainModeIdentifier);
- // ---
- config.transit().setUseTransit(true) ;
- // ---
- config.controller().setFirstIteration(1) ;
- config.controller().setLastIteration(10) ;
- config.controller().setOutputDirectory(outputDir) ;
- config.controller().setWriteEventsInterval(1) ;
- config.controller().setMobsim(MobsimType.qsim.toString()) ;
- // ---
-
- config.qsim().setFlowCapFactor(0.02) ;
- config.qsim().setStorageCapFactor(0.06) ;
- config.qsim().setStuckTime(10.) ;
- config.qsim().setRemoveStuckVehicles(false) ; // ??
- // ---
- config.transit().setTransitScheduleFile(inputDir + "transitSchedule1bus.xml") ;
- config.transit().setVehiclesFile(inputDir + "vehicles.xml") ;
- Set modes = new HashSet() ;
- modes.add("pt") ;
- config.transit().setTransitModes(modes) ;
- // ---
- {
- ActivityParams params = new ActivityParams("h") ;
- config.scoring().addActivityParams(params ) ;
- params.setTypicalDuration(12*60*60.) ;
- }{
- ActivityParams params = new ActivityParams("w") ;
- config.scoring().addActivityParams(params ) ;
- params.setTypicalDuration(8*60*60.) ;
- }
- // ---
-// ConfigGroup cadytsPtConfig = config.createModule(CadytsConfigGroup.GROUP_NAME ) ;
- CadytsConfigGroup cadytsPtConfig = ConfigUtils.addOrGetModule( config, CadytsConfigGroup.class );
-
-// cadytsPtConfig.addParam(CadytsConfigGroup.START_TIME, "04:00:00") ;
- cadytsPtConfig.setStartTime( 4*3600 );
-// cadytsPtConfig.addParam(CadytsConfigGroup.END_TIME, "20:00:00" ) ;
- cadytsPtConfig.setEndTime( 20*3600 );
- cadytsPtConfig.addParam(CadytsConfigGroup.REGRESSION_INERTIA, "0.95") ;
- cadytsPtConfig.addParam(CadytsConfigGroup.USE_BRUTE_FORCE, "true") ;
- cadytsPtConfig.addParam(CadytsConfigGroup.MIN_FLOW_STDDEV, "8") ;
- cadytsPtConfig.addParam(CadytsConfigGroup.PREPARATORY_ITERATIONS, "1") ;
- cadytsPtConfig.addParam(CadytsConfigGroup.TIME_BIN_SIZE, "3600") ;
- cadytsPtConfig.addParam(CadytsConfigGroup.CALIBRATED_LINES, "M44,M43") ;
-
-// CadytsConfigGroup ccc = new CadytsConfigGroup() ;
-// config.addModule(ccc) ;
-
-
- // ---
- config.ptCounts().setOccupancyCountsFileName(inputDir + "counts/counts_occupancy.xml") ;
- config.ptCounts().setBoardCountsFileName(inputDir + "counts/counts_boarding.xml") ;
- config.ptCounts().setAlightCountsFileName(inputDir + "counts/counts_alighting.xml") ;
- // config.ptCounts().setDistanceFilter(30000.) ; // why?
- // config.ptCounts().setDistanceFilterCenterNode("7") ; // why?
- config.ptCounts().setOutputFormat("txt");
- config.ptCounts().setCountsScaleFactor(1.) ;
- // ---
- return config;
- }
-
- private static class DummyMobsimFactory implements MobsimFactory {
- @Override
- public Mobsim createMobsim(final Scenario sc, final EventsManager eventsManager) {
- return new Mobsim() {
- @Override public void run() { }
- } ;
- }
- }
-}
diff --git a/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/pt/CountsReaderPt.java b/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/pt/CountsReaderPt.java
deleted file mode 100644
index a312c472c48..00000000000
--- a/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/pt/CountsReaderPt.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/* *********************************************************************** *
- * project: org.matsim.*
- * *
- * *********************************************************************** *
- * *
- * copyright : (C) 2012 by the members listed in the COPYING, *
- * LICENSE and WARRANTY file. *
- * email : info at matsim dot org *
- * *
- * *********************************************************************** *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * See also COPYING, LICENSE and WARRANTY file *
- * *
- * *********************************************************************** */
-
-package org.matsim.contrib.cadyts.pt;
-
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.util.Map;
-import java.util.TreeMap;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.matsim.api.core.v01.Id;
-import org.matsim.core.utils.misc.StringUtils;
-import org.matsim.pt.transitSchedule.api.TransitStopFacility;
-
-/**
- * parses a output text file containing counts comparisons
- *
- * this class is only there in order to read the column-oriented output back in for testing.
- * It should not be used elsewhere without further thinking. kai, sep'14
- * */
-final class CountsReaderPt {
-
- private final static Logger log = LogManager.getLogger(CountsReaderPt.class);
-
- final String STOP_ID_STRING_0 = "StopId :";
- final String HEAD_STRING_0 = "hour";
- final String ZERO = "0.0";
-
- String countsTextFile;
- Map, Map> count = new TreeMap<>();
-
- CountsReaderPt(final String countsTextFile){
- this.countsTextFile = countsTextFile;
- readValues();
- }
-
- private void readValues() {
- try {
- FileReader fileReader = new FileReader(this.countsTextFile);
- // ->:correct this : reads first row
- BufferedReader bufferedReader = new BufferedReader(fileReader);
- String row = bufferedReader.readLine(); // TODO : include the first row inside the iteration
- String[] values = StringUtils.explode(row, '\t');
-
- Id id = Id.create(values[1], TransitStopFacility.class);
- while (row != null) {
- row = bufferedReader.readLine();
- if (row != null && row != "") {
- values = StringUtils.explode(row, '\t');
- if (values[0].equals(this.STOP_ID_STRING_0)) {
- id = Id.create(values[1], TransitStopFacility.class);
- } else if (values[0].equals(this.HEAD_STRING_0)) {
- // it does nothing, correct this condition
- } else {
- if (!this.count.containsKey(id)) {
- this.count.put(id, new TreeMap());
- }
- this.count.get(id).put(values[0],
- new double[] { Double.parseDouble(values[1]), Double.parseDouble(values[2]), Double.parseDouble(values[3]) });
- }
- }
- }
- bufferedReader.close();
- fileReader.close();
- } catch (Exception e) {
- log.error(e);
- }
- }
-
- /**
- * I am reasonably sure that the first entry (hour 1) is at array-position 0. kai, sep'14
- */
- double[]getSimulatedValues(final Id stopId) {
- return this.getCountValues(stopId, 0);
- }
-
- /**
- * I am reasonably sure that the first entry (hour 1) is at array-position 0. kai, sep'14
- */
- double[]getSimulatedScaled(final Id stopId) {
- return this.getCountValues(stopId, 1);
- }
-
- /**
- * I am reasonably sure that the first entry (hour 1) is at array-position 0. kai, sep'14
- */
- double[]getRealValues(final Id stopId) {
- return this.getCountValues(stopId, 2);
- }
-
- /**
- * I am reasonably sure that the first entry (hour 1) is at array-position 0. kai, sep'14
- */
- double[]getCountValues(final Id stopId, final int col) {
- double[] valueArray = new double[24];
- for (byte i= 0; i<24 ; i++) {
- String hour = String.valueOf(i+1);
- if (this.count.keySet().contains(stopId)) {
- double[] value = this.count.get(stopId).get(hour);
- if (value == null){
- valueArray[i] = 0.0;
- } else {
- valueArray[i] = value[col] ; //0 = simulated; 1= simulatedEscaled ; 2=realValues
- }
- } else {
- valueArray = null;
- }
- }
- return valueArray;
- }
-
-}
diff --git a/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/utils/CalibrationStatReaderTest.java b/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/utils/CalibrationStatReaderTest.java
index 5733a037c50..cf1c31b9126 100644
--- a/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/utils/CalibrationStatReaderTest.java
+++ b/contribs/cadytsIntegration/src/test/java/org/matsim/contrib/cadyts/utils/CalibrationStatReaderTest.java
@@ -20,12 +20,10 @@
package org.matsim.contrib.cadyts.utils;
import java.io.IOException;
-import java.net.URL;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
-import org.matsim.contrib.cadyts.pt.CadytsPtIT;
import org.matsim.testcases.MatsimTestUtils;
import cadyts.utilities.io.tabularFileParser.TabularFileParser;
@@ -42,17 +40,17 @@ public void testReader() throws IOException {
CalibrationStatReader calibrationStatReader = new CalibrationStatReader();
tabularFileParser.parse(calibStatFile, calibrationStatReader);
CalibrationStatReader.StatisticsData statData6= calibrationStatReader.getCalStatMap().get(Integer.valueOf(6));
- Assert.assertEquals("differrent Count_ll", "-1.546875", statData6.getCount_ll() );
- Assert.assertEquals("differrent Count_ll_pred_err", "9.917082938182276E-8" , statData6.getCount_ll_pred_err() );
- Assert.assertEquals("differrent Link_lambda_avg", "0.0013507168476099964", statData6.getLink_lambda_avg() );
- Assert.assertEquals("differrent Link_lambda_max", "0.031434867572002166" , statData6.getLink_lambda_max() );
- Assert.assertEquals("differrent Link_lambda_min", "0.0", statData6.getLink_lambda_min() );
- Assert.assertEquals("differrent Link_lambda_stddev", "0.0058320747961925256" , statData6.getLink_lambda_stddev());
- Assert.assertEquals("differrent P2p_ll", "--" , statData6.getP2p_ll());
- Assert.assertEquals("differrent Plan_lambda_avg", "0.04322293912351989", statData6.getPlan_lambda_avg() );
- Assert.assertEquals("differrent Plan_lambda_max", "0.04715229919344063" , statData6.getPlan_lambda_max() );
- Assert.assertEquals("differrent Plan_lambda_min", "0.03929357905359915" , statData6.getPlan_lambda_min() );
- Assert.assertEquals("differrent Plan_lambda_stddev", "0.004200662608832472" , statData6.getPlan_lambda_stddev());
- Assert.assertEquals("differrent Total_ll", "-1.546875", statData6.getTotal_ll() );
+ Assert.assertEquals("different Count_ll", "-1.546875", statData6.getCount_ll() );
+ Assert.assertEquals("different Count_ll_pred_err", "9.917082938182276E-8" , statData6.getCount_ll_pred_err() );
+ Assert.assertEquals("different Link_lambda_avg", "0.0013507168476099964", statData6.getLink_lambda_avg() );
+ Assert.assertEquals("different Link_lambda_max", "0.031434867572002166" , statData6.getLink_lambda_max() );
+ Assert.assertEquals("different Link_lambda_min", "0.0", statData6.getLink_lambda_min() );
+ Assert.assertEquals("different Link_lambda_stddev", "0.0058320747961925256" , statData6.getLink_lambda_stddev());
+ Assert.assertEquals("different P2p_ll", "--" , statData6.getP2p_ll());
+ Assert.assertEquals("different Plan_lambda_avg", "0.04322293912351989", statData6.getPlan_lambda_avg() );
+ Assert.assertEquals("different Plan_lambda_max", "0.04715229919344063" , statData6.getPlan_lambda_max() );
+ Assert.assertEquals("different Plan_lambda_min", "0.03929357905359915" , statData6.getPlan_lambda_min() );
+ Assert.assertEquals("different Plan_lambda_stddev", "0.004200662608832472" , statData6.getPlan_lambda_stddev());
+ Assert.assertEquals("different Total_ll", "-1.546875", statData6.getTotal_ll() );
}
}
diff --git a/contribs/commercialTrafficApplications/scenarios/grid/jointDemand_config.xml b/contribs/commercialTrafficApplications/scenarios/grid/jointDemand_config.xml
index 8dcb998aa8d..eba2edb7fe4 100644
--- a/contribs/commercialTrafficApplications/scenarios/grid/jointDemand_config.xml
+++ b/contribs/commercialTrafficApplications/scenarios/grid/jointDemand_config.xml
@@ -383,24 +383,6 @@
stopId
per time bin, starting with time bin 0 from 0
- * seconds to (timeBinSize-1)seconds.
- */
- public int[] getBoardVolumesForStop(final Id