diff --git a/contribs/pseudosimulation/pom.xml b/contribs/pseudosimulation/pom.xml index 3c8e45cc647..56b3b3b9bfc 100644 --- a/contribs/pseudosimulation/pom.xml +++ b/contribs/pseudosimulation/pom.xml @@ -15,11 +15,6 @@ common 16.0-SNAPSHOT - - org.matsim.contrib - events-based-pt-router - 16.0-SNAPSHOT - commons-cli commons-cli diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/ChoiceGenerationControler.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/ChoiceGenerationControler.java index 00fc950cbcc..f3acb572ce8 100644 --- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/ChoiceGenerationControler.java +++ b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/ChoiceGenerationControler.java @@ -6,9 +6,9 @@ import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; -import org.matsim.contrib.eventsBasedPTRouter.TransitRouterEventsWSFactory; -import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTimeCalculatorImpl; -import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTimeStuckCalculator; +//import org.matsim.contrib.eventsBasedPTRouter.TransitRouterEventsWSFactory; +//import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTimeCalculatorImpl; +//import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTimeStuckCalculator; import org.matsim.contrib.pseudosimulation.mobsim.PSimProvider; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; @@ -34,8 +34,8 @@ */ public class ChoiceGenerationControler implements BeforeMobsimListener{ - final WaitTimeStuckCalculator waitTimeCalculator; - final StopStopTimeCalculatorImpl stopStopTimeCalculator; +// final WaitTimeStuckCalculator waitTimeCalculator; +// final StopStopTimeCalculatorImpl stopStopTimeCalculator; final TravelTimeCalculator travelTimeCalculator; private PSimProvider pSimProvider; Config config; @@ -49,23 +49,23 @@ public ChoiceGenerationControler(String[] args) { scenario = ScenarioUtils.loadScenario(config); controler = new Controler(scenario); - waitTimeCalculator = new WaitTimeStuckCalculator( - controler.getScenario().getPopulation(), - controler.getScenario().getTransitSchedule(), - controler.getConfig().travelTimeCalculator().getTraveltimeBinSize(), - (int) (controler.getConfig().qsim().getEndTime().seconds() - controler.getConfig().qsim().getStartTime().seconds())); - stopStopTimeCalculator = new StopStopTimeCalculatorImpl( - controler.getScenario().getTransitSchedule(), - controler.getConfig().travelTimeCalculator().getTraveltimeBinSize(), - (int) (controler.getConfig().qsim().getEndTime().seconds() - controler.getConfig().qsim().getStartTime().seconds())); - controler.addOverridingModule(new AbstractModule() { - @Override - public void install() { - bind(TransitRouter.class).toProvider(new TransitRouterEventsWSFactory(controler.getScenario(), - waitTimeCalculator.get(), - stopStopTimeCalculator.get())); - } - }); +// waitTimeCalculator = new WaitTimeStuckCalculator( +// controler.getScenario().getPopulation(), +// controler.getScenario().getTransitSchedule(), +// controler.getConfig().travelTimeCalculator().getTraveltimeBinSize(), +// (int) (controler.getConfig().qsim().getEndTime().seconds() - controler.getConfig().qsim().getStartTime().seconds())); +// stopStopTimeCalculator = new StopStopTimeCalculatorImpl( +// controler.getScenario().getTransitSchedule(), +// controler.getConfig().travelTimeCalculator().getTraveltimeBinSize(), +// (int) (controler.getConfig().qsim().getEndTime().seconds() - controler.getConfig().qsim().getStartTime().seconds())); +// controler.addOverridingModule(new AbstractModule() { +// @Override +// public void install() { +// bind(TransitRouter.class).toProvider(new TransitRouterEventsWSFactory(controler.getScenario(), +// waitTimeCalculator.get(), +// stopStopTimeCalculator.get())); +// } +// }); // controler.setScoringFunctionFactory( // new CharyparNagelOpenTimesScoringFunctionFactory(controler.getConfig().planCalcScore(), // controler.getScenario())); @@ -73,8 +73,8 @@ public void install() { EventsManagerImpl eventsManager = new EventsManagerImpl(); EventsReaderXMLv1 reader = new EventsReaderXMLv1(eventsManager); - eventsManager.addHandler(waitTimeCalculator); - eventsManager.addHandler(stopStopTimeCalculator); +// eventsManager.addHandler(waitTimeCalculator); +// eventsManager.addHandler(stopStopTimeCalculator); eventsManager.addHandler(travelTimeCalculator); reader.readFile(args[1]); @@ -106,8 +106,8 @@ public void notifyBeforeMobsim(BeforeMobsimEvent event) { for(Person person:controler.getScenario().getPopulation().getPersons().values()){ plans.add(person.getSelectedPlan()); } - pSimProvider.setWaitTime(waitTimeCalculator.get()); +// pSimProvider.setWaitTime(waitTimeCalculator.get()); pSimProvider.setTravelTime(travelTimeCalculator.getLinkTravelTimes()); - pSimProvider.setStopStopTime(stopStopTimeCalculator.get()); +// pSimProvider.setStopStopTime(stopStopTimeCalculator.get()); } } diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/PSimDataProvider.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/PSimDataProvider.java index 7c6368c7528..461999c0120 100644 --- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/PSimDataProvider.java +++ b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/PSimDataProvider.java @@ -1,7 +1,7 @@ package org.matsim.contrib.pseudosimulation; -import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTime; -import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTime; +//import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTime; +//import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTime; import org.matsim.contrib.pseudosimulation.distributed.listeners.events.transit.TransitPerformance; import org.matsim.contrib.pseudosimulation.replanning.PlanCatcher; import org.matsim.core.router.util.TravelTime; @@ -10,8 +10,8 @@ * Created by fouriep on 4/21/15. */ public interface PSimDataProvider { - public StopStopTime getStopStopTime(); - public WaitTime getWaitTime(); +// public StopStopTime getStopStopTime(); +// public WaitTime getWaitTime(); public TransitPerformance getTransitPerformance(); public PlanCatcher getPlanCatcher(); public TravelTime getTravelTime(); diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/RunPSim.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/RunPSim.java index 3df6ab05ecf..fde2b4a010c 100644 --- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/RunPSim.java +++ b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/RunPSim.java @@ -23,18 +23,16 @@ import com.google.inject.Singleton; import org.matsim.api.core.v01.Scenario; -import org.matsim.contrib.eventsBasedPTRouter.TransitRouterEventsWSFactory; -import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTime; -import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTimeCalculator; -import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTime; -import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTimeCalculator; +//import org.matsim.contrib.eventsBasedPTRouter.TransitRouterEventsWSFactory; +//import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTime; +//import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTimeCalculator; +//import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTime; +//import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTimeCalculator; //import org.matsim.contrib.pseudosimulation.distributed.listeners.events.transit.TransitPerformanceRecorder; import org.matsim.contrib.pseudosimulation.mobsim.PSimProvider; import org.matsim.contrib.pseudosimulation.mobsim.SwitchingMobsimProvider; import org.matsim.contrib.pseudosimulation.replanning.PlanCatcher; -import org.matsim.contrib.pseudosimulation.trafficinfo.PSimStopStopTimeCalculator; import org.matsim.contrib.pseudosimulation.trafficinfo.PSimTravelTimeCalculator; -import org.matsim.contrib.pseudosimulation.trafficinfo.PSimWaitTimeCalculator; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.controler.AbstractModule; @@ -43,7 +41,6 @@ import org.matsim.core.mobsim.qsim.QSimProvider; import org.matsim.core.router.util.TravelTime; import org.matsim.core.scenario.ScenarioUtils; -import org.matsim.pt.router.TransitRouter; /** * @author pieterfourie @@ -74,10 +71,10 @@ public RunPSim(Config config, PSimConfigGroup pSimConfigGroup) { public void install() { bind(MobSimSwitcher.class).toInstance(mobSimSwitcher); bindMobsim().toProvider(SwitchingMobsimProvider.class); - bind(WaitTimeCalculator.class).to(PSimWaitTimeCalculator.class); - bind(WaitTime.class).toProvider(PSimWaitTimeCalculator.class); - bind(StopStopTimeCalculator.class).to(PSimStopStopTimeCalculator.class); - bind(StopStopTime.class).toProvider(PSimStopStopTimeCalculator.class); +// bind(WaitTimeCalculator.class).to(PSimWaitTimeCalculator.class); +// bind(WaitTime.class).toProvider(PSimWaitTimeCalculator.class); +// bind(StopStopTimeCalculator.class).to(PSimStopStopTimeCalculator.class); +// bind(StopStopTime.class).toProvider(PSimStopStopTimeCalculator.class); // bind(TravelTimeCalculator.class).to(PSimTravelTimeCalculator.class); // I made TravelTimeCalculator final, so PSimTravelTimeCalculator can no longer inherit from it. The following statement binds PSimTravelTimeCalculator @@ -85,7 +82,7 @@ public void install() { bind(PSimTravelTimeCalculator.class).in( Singleton.class ) ; bind(TravelTime.class).toProvider(PSimTravelTimeCalculator.class); - bind(TransitRouter.class).toProvider(TransitRouterEventsWSFactory.class); +// bind(TransitRouter.class).toProvider(TransitRouterEventsWSFactory.class); bind(PlanCatcher.class).toInstance(new PlanCatcher()); bind(PSimProvider.class).toInstance(new PSimProvider(scenario,matsimControler.getEvents())); bind(QSimProvider.class); diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/MasterControler.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/MasterControler.java index 9e1e85a8450..acd92e861e5 100644 --- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/MasterControler.java +++ b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/MasterControler.java @@ -23,8 +23,6 @@ import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; -import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTimeCalculatorSerializable; -import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTimeCalculatorSerializable; import org.matsim.contrib.pseudosimulation.distributed.instrumentation.scorestats.SlaveScoreStats; import org.matsim.contrib.pseudosimulation.distributed.listeners.controler.GenomeAnalysis; import org.matsim.contrib.pseudosimulation.distributed.listeners.controler.SlaveScoreWriter; @@ -73,8 +71,8 @@ public class MasterControler implements AfterMobsimListener, ShutdownListener, S private Config config; private Controler matsimControler; private TreeMap slaveHandlerTreeMap; - private WaitTimeCalculatorSerializable waitTimeCalculator; - private StopStopTimeCalculatorSerializable stopStopTimeCalculator; +// private WaitTimeCalculatorSerializable waitTimeCalculator; +// private StopStopTimeCalculatorSerializable stopStopTimeCalculator; private TransitPerformanceRecorder transitPerformanceRecorder; private SerializableLinkTravelTimes linkTravelTimes; private AtomicInteger numThreads = new AtomicInteger(0); @@ -180,13 +178,13 @@ public MasterControler(String configFile) throws NumberFormatException, IOExcept if (this.config.transit().isUseTransit()) { - waitTimeCalculator = new WaitTimeCalculatorSerializable(matsimControler.getScenario().getTransitSchedule(), this.config.travelTimeCalculator().getTraveltimeBinSize(), - (int) (this.config.qsim().getEndTime().seconds() - this.config.qsim().getStartTime().seconds())); - matsimControler.getEvents().addHandler(waitTimeCalculator); - stopStopTimeCalculator = new StopStopTimeCalculatorSerializable(matsimControler.getScenario().getTransitSchedule(), - this.config.travelTimeCalculator().getTraveltimeBinSize(), (int) (this.config.qsim() - .getEndTime().seconds() - this.config.qsim().getStartTime().seconds())); - matsimControler.getEvents().addHandler(stopStopTimeCalculator); +// waitTimeCalculator = new WaitTimeCalculatorSerializable(matsimControler.getScenario().getTransitSchedule(), this.config.travelTimeCalculator().getTraveltimeBinSize(), +// (int) (this.config.qsim().getEndTime().seconds() - this.config.qsim().getStartTime().seconds())); +// matsimControler.getEvents().addHandler(waitTimeCalculator); +// stopStopTimeCalculator = new StopStopTimeCalculatorSerializable(matsimControler.getScenario().getTransitSchedule(), +// this.config.travelTimeCalculator().getTraveltimeBinSize(), (int) (this.config.qsim() +// .getEndTime().seconds() - this.config.qsim().getStartTime().seconds())); +// matsimControler.getEvents().addHandler(stopStopTimeCalculator); //tell PlanSerializable to record transit routes PlanSerializable.isUseTransit = true; if (fullTransitPerformanceTransmission) { @@ -778,8 +776,8 @@ public void transmitTravelTimes() throws IOException { writer.writeInt(currentIteration); writer.writeObject(linkTravelTimes); if (config.transit().isUseTransit()) { - writer.writeObject(stopStopTimeCalculator.getStopStopTimes()); - writer.writeObject(waitTimeCalculator.getWaitTimes()); +// writer.writeObject(stopStopTimeCalculator.getStopStopTimes()); +// writer.writeObject(waitTimeCalculator.getWaitTimes()); if (fullTransitPerformanceTransmission) writer.writeObject(transitPerformanceRecorder.getTransitPerformance()); } diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/SlaveControler.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/SlaveControler.java index a45f80ba4d6..5ec460d62d9 100644 --- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/SlaveControler.java +++ b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/SlaveControler.java @@ -28,11 +28,6 @@ import org.matsim.api.core.v01.population.Person; import org.matsim.api.core.v01.population.Plan; import org.matsim.contrib.common.diversitygeneration.planselectors.DiversityGeneratingPlansRemover; -import org.matsim.contrib.eventsBasedPTRouter.TransitRouterEventsWSFactory; -import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTime; -import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTimeCalculatorSerializable; -import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTime; -import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTimeCalculatorSerializable; import org.matsim.contrib.pseudosimulation.distributed.instrumentation.scorestats.SlaveScoreStatsCalculator; import org.matsim.contrib.pseudosimulation.distributed.listeners.events.transit.TransitPerformance; import org.matsim.contrib.pseudosimulation.mobsim.PSimProvider; @@ -86,8 +81,6 @@ public class SlaveControler implements IterationStartsListener, StartupListener, private double totalIterationTime; private Controler matsimControler; private TravelTime linkTravelTimes; - private WaitTime waitTimes; - private StopStopTime stopStopTimes; private ObjectInputStream reader; private ObjectOutputStream writer; private PSimProvider pSimProvider; @@ -97,7 +90,6 @@ public class SlaveControler implements IterationStartsListener, StartupListener, private boolean isOkForNextIter = true; private Map, Double> selectedPlanScoreMemory; private TransitPerformance transitPerformance; - private TransitRouterEventsWSFactory transitRouterEventsWSFactory; private void printHelp(Options options) { String header = "The MasterControler takes the following options:\n\n"; @@ -268,15 +260,6 @@ public void install() { }); if (config.transit().isUseTransit()) { - - stopStopTimes = new StopStopTimeCalculatorSerializable(scenario.getTransitSchedule(), - config.travelTimeCalculator().getTraveltimeBinSize(), (int) (config - .qsim().getEndTime().seconds() - config.qsim().getStartTime().seconds())).getStopStopTimes(); - - waitTimes = new WaitTimeCalculatorSerializable(scenario.getTransitSchedule(), - config.travelTimeCalculator().getTraveltimeBinSize(), (int) (config - .qsim().getEndTime().seconds() - config.qsim().getStartTime().seconds())).getWaitTimes(); - // tell PlanSerializable to record transit routes PlanSerializable.isUseTransit = true; @@ -285,11 +268,11 @@ public void install() { matsimControler.addOverridingModule(new AbstractModule() { @Override public void install() { - System.out.println("init routers"); +// System.out.println("init routers"); // transitRouterEventsWSFactory = new TransitRouterEventsWSFactory(scenario, // waitTimes, // stopStopTimes); - bind(TransitRouter.class).toProvider(transitRouterEventsWSFactory); +// bind(TransitRouter.class).toProvider(transitRouterEventsWSFactory); } }); @@ -387,13 +370,13 @@ public void notifyIterationStarts(IterationStartsEvent event) { travelTime.setTravelTime(linkTravelTimes); pSimProvider.setTravelTime(linkTravelTimes); if (config.transit().isUseTransit()) { - pSimProvider.setStopStopTime(stopStopTimes); - pSimProvider.setWaitTime(waitTimes); - pSimProvider.setTransitPerformance(transitPerformance); - if (transitRouterEventsWSFactory != null) { +// pSimProvider.setStopStopTime(stopStopTimes); +// pSimProvider.setWaitTime(waitTimes); +// pSimProvider.setTransitPerformance(transitPerformance); +// if (transitRouterEventsWSFactory != null) { // transitRouterEventsWSFactory.setStopStopTimeCalculator(stopStopTimes); // transitRouterEventsWSFactory.setWaitTimeCalculator(waitTimes); - } +// } } plancatcher.init(); numberOfIterations++; @@ -449,8 +432,8 @@ public void transmitTravelTimes() throws IOException, ClassNotFoundException { masterCurrentIteration = reader.readInt(); linkTravelTimes = (SerializableLinkTravelTimes) reader.readObject(); if (config.transit().isUseTransit()) { - stopStopTimes = (StopStopTime) reader.readObject(); - waitTimes = (WaitTime) reader.readObject(); +// stopStopTimes = (StopStopTime) reader.readObject(); +// waitTimes = (WaitTime) reader.readObject(); if (fullTransitPerformanceTransmission) { Object o = reader.readObject(); transitPerformance = (TransitPerformance) o; @@ -619,8 +602,8 @@ public void notifyBeforeMobsim(BeforeMobsimEvent event) { @Override public void notifyIterationEnds(IterationEndsEvent event) { Iterator, Double>> iterator = selectedPlanScoreMemory.entrySet().iterator(); - StopStopTimeCalculatorSerializable.printCallStatisticsAndReset(); - WaitTimeCalculatorSerializable.printCallStatisticsAndReset(); +// StopStopTimeCalculatorSerializable.printCallStatisticsAndReset(); +// WaitTimeCalculatorSerializable.printCallStatisticsAndReset(); while (iterator.hasNext()) { Map.Entry, Double> entry = iterator.next(); scenario.getPopulation().getPersons().get(entry.getKey()).getSelectedPlan().setScore(entry.getValue()); diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/mobsim/PSimProvider.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/mobsim/PSimProvider.java index 2759e9c38be..baa9619edc4 100644 --- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/mobsim/PSimProvider.java +++ b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/mobsim/PSimProvider.java @@ -4,8 +4,6 @@ package org.matsim.contrib.pseudosimulation.mobsim; import org.matsim.api.core.v01.Scenario; -import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTime; -import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTime; import org.matsim.contrib.pseudosimulation.distributed.listeners.events.transit.TransitPerformance; import org.matsim.contrib.pseudosimulation.mobsim.transitperformance.TransitEmulator; import org.matsim.contrib.pseudosimulation.replanning.PlanCatcher; @@ -42,25 +40,25 @@ public void setTravelTime(TravelTime travelTime) { this.travelTime = travelTime; } - @Deprecated - public void setWaitTime(WaitTime waitTime) { - throw new RuntimeException("Use an instance of " + TransitEmulator.class.getSimpleName() + " instead."); - } +// @Deprecated +// public void setWaitTime(WaitTime waitTime) { +// throw new RuntimeException("Use an instance of " + TransitEmulator.class.getSimpleName() + " instead."); +// } - @Deprecated - public void setStopStopTime(StopStopTime stopStopTime) { - throw new RuntimeException("Use an instance of " + TransitEmulator.class.getSimpleName() + " instead."); - } +// @Deprecated +// public void setStopStopTime(StopStopTime stopStopTime) { +// throw new RuntimeException("Use an instance of " + TransitEmulator.class.getSimpleName() + " instead."); +// } @Deprecated public void setTransitPerformance(TransitPerformance transitPerformance) { throw new RuntimeException("Use an instance of " + TransitEmulator.class.getSimpleName() + " instead."); } - @Deprecated - public void setTimes(TravelTime travelTime, WaitTime waitTime, StopStopTime stopStopTime) { - throw new RuntimeException("Use an instance of " + TransitEmulator.class.getSimpleName() + " instead."); - } +// @Deprecated +// public void setTimes(TravelTime travelTime, WaitTime waitTime, StopStopTime stopStopTime) { +// throw new RuntimeException("Use an instance of " + TransitEmulator.class.getSimpleName() + " instead."); +// } @Deprecated //will replace where necessary diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/mobsim/transitperformance/TransitPerformanceFromEventBasedRouterInterfaces.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/mobsim/transitperformance/TransitPerformanceFromEventBasedRouterInterfaces.java index 13f2536ddf9..e767a863b02 100644 --- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/mobsim/transitperformance/TransitPerformanceFromEventBasedRouterInterfaces.java +++ b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/mobsim/transitperformance/TransitPerformanceFromEventBasedRouterInterfaces.java @@ -1,6 +1,6 @@ /* * Copyright 2018 Gunnar Flötteröd - * + * * 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 3 of the License, or @@ -23,8 +23,8 @@ import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.population.Leg; -import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTime; -import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTime; +//import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTime; +//import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTime; import org.matsim.pt.routes.TransitPassengerRoute; import org.matsim.pt.transitSchedule.TransitRouteImpl; import org.matsim.pt.transitSchedule.api.TransitLine; @@ -44,16 +44,16 @@ */ public class TransitPerformanceFromEventBasedRouterInterfaces implements TransitEmulator { - private WaitTime waitTimes; - private StopStopTime stopStopTimes; +// private WaitTime waitTimes; +// private StopStopTime stopStopTimes; private Map, TransitLine> transitLines; private Map, TransitStopFacility> stopFacilities; @Inject - public TransitPerformanceFromEventBasedRouterInterfaces(WaitTime waitTimes, StopStopTime stopStopTimes, + public TransitPerformanceFromEventBasedRouterInterfaces(/*WaitTime waitTimes, StopStopTime stopStopTimes,*/ TransitSchedule transitSchedule) { - this.waitTimes = waitTimes; - this.stopStopTimes = stopStopTimes; +// this.waitTimes = waitTimes; +// this.stopStopTimes = stopStopTimes; this.transitLines = transitSchedule.getTransitLines(); this.stopFacilities = transitSchedule.getFacilities(); } @@ -65,8 +65,8 @@ public Trip findTrip(Leg prevLeg, double earliestDepartureTime_s) { TransitLine line = this.transitLines.get(route.getLineId()); TransitRoute transitRoute = line.getRoutes().get(route.getRouteId()); - final double accessTime_s = earliestDepartureTime_s + this.waitTimes.getRouteStopWaitTime(route.getLineId(), - transitRoute.getId(), route.getAccessStopId(), earliestDepartureTime_s); + final double accessTime_s = earliestDepartureTime_s /*+ this.waitTimes.getRouteStopWaitTime(route.getLineId(), + transitRoute.getId(), route.getAccessStopId(), earliestDepartureTime_s)*/; final double egressTime_s = accessTime_s + this.findTransitTravelTime(route, accessTime_s); return new Trip(null, accessTime_s, egressTime_s); } @@ -99,7 +99,7 @@ private double findTransitTravelTime(TransitPassengerRoute route, double prevEnd Id fromId = transitRoute.getStops().get(i).getStopFacility().getId(); TransitRouteStop toStop = transitRoute.getStops().get(i + 1); Id toId = toStop.getStopFacility().getId(); - travelTime += stopStopTimes.getStopStopTime(fromId, toId, prevStopTime); +// travelTime += stopStopTimes.getStopStopTime(fromId, toId, prevStopTime); prevStopTime += travelTime; if (toStop.getStopFacility().getId().equals(dest)) { destinationFound = true; diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/PSimStopStopTimeCalculator.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/PSimStopStopTimeCalculator.java deleted file mode 100644 index 4b1a0e49a21..00000000000 --- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/PSimStopStopTimeCalculator.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.matsim.contrib.pseudosimulation.trafficinfo; - -import com.google.inject.Singleton; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.matsim.api.core.v01.Scenario; -import org.matsim.api.core.v01.events.PersonLeavesVehicleEvent; -import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTimeCalculatorSerializable; -import org.matsim.contrib.pseudosimulation.MobSimSwitcher; -import org.matsim.core.api.experimental.events.EventsManager; -import org.matsim.core.api.experimental.events.VehicleArrivesAtFacilityEvent; -import org.matsim.core.config.Config; -import org.matsim.pt.transitSchedule.api.TransitSchedule; - -import jakarta.inject.Inject; - -@Singleton -public class PSimStopStopTimeCalculator extends StopStopTimeCalculatorSerializable { - private final MobSimSwitcher switcher; - - @Inject - PSimStopStopTimeCalculator(Scenario scenario, MobSimSwitcher switcher, EventsManager eventsManager) { - super(scenario.getTransitSchedule(),scenario.getConfig() ); - this.switcher = switcher; - eventsManager.addHandler(this); - } - - @Override - public void reset(int iteration) { - if (switcher.isQSimIteration()) { - LogManager.getLogger(this.getClass()).error( - "Calling reset on traveltimecalc"); - super.reset(iteration); - } - } - - @Override - public void handleEvent(VehicleArrivesAtFacilityEvent event) { - if (switcher.isQSimIteration()) - super.handleEvent(event); - } - - @Override - public void handleEvent(PersonLeavesVehicleEvent event) { - if (switcher.isQSimIteration()) - super.handleEvent(event); - } - -} diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/PSimWaitTimeCalculator.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/PSimWaitTimeCalculator.java deleted file mode 100644 index f618a5c8a45..00000000000 --- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/PSimWaitTimeCalculator.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.matsim.contrib.pseudosimulation.trafficinfo; - -import com.google.inject.Inject; -import com.google.inject.Singleton; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.matsim.api.core.v01.Scenario; -import org.matsim.api.core.v01.events.PersonDepartureEvent; -import org.matsim.api.core.v01.events.PersonEntersVehicleEvent; -import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTimeCalculatorSerializable; -import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTimeStuckCalculator; -import org.matsim.contrib.pseudosimulation.MobSimSwitcher; -import org.matsim.core.api.experimental.events.EventsManager; - - -/** - * @author fouriep - *

- * Extends Ordonez's {@link WaitTimeStuckCalculator} to only handle - * events during QSim iterations. - */ -@Singleton -public class PSimWaitTimeCalculator extends WaitTimeCalculatorSerializable { - private final MobSimSwitcher switcher; - - @Inject - public PSimWaitTimeCalculator(Scenario scenario, - MobSimSwitcher switcher, EventsManager eventsManager) { - super(scenario.getTransitSchedule(),scenario.getConfig()); - this.switcher = switcher; - eventsManager.addHandler(this); - } - - @Override - public void reset(int iteration) { - if (switcher.isQSimIteration()) { - LogManager.getLogger(this.getClass()).error( - "Calling reset on traveltimecalc"); - super.reset(iteration); - } - } - - @Override - public void handleEvent(PersonDepartureEvent event) { - if (switcher.isQSimIteration()) - super.handleEvent(event); - } - - @Override - public void handleEvent(PersonEntersVehicleEvent event) { - if (switcher.isQSimIteration()) - super.handleEvent(event); - } - - - -} diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/deterministic/DeterministicStopStopTimeCalculator.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/deterministic/DeterministicStopStopTimeCalculator.java deleted file mode 100644 index 567187f053d..00000000000 --- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/deterministic/DeterministicStopStopTimeCalculator.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.matsim.contrib.pseudosimulation.trafficinfo.deterministic; - -import java.util.List; - -import org.matsim.api.core.v01.Id; -import org.matsim.api.core.v01.population.Leg; -import org.matsim.api.core.v01.population.PlanElement; -import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTime; -import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTimeCalculator; -import org.matsim.core.router.DefaultRoutingRequest; -import org.matsim.pt.router.TransitRouter; -import org.matsim.pt.transitSchedule.api.TransitSchedule; -import org.matsim.pt.transitSchedule.api.TransitStopFacility; -import org.matsim.utils.objectattributes.attributable.Attributes; - -import com.google.inject.Inject; -import com.google.inject.Singleton; - -@Singleton -public class DeterministicStopStopTimeCalculator implements StopStopTimeCalculator { - private final TransitRouter transitRouter; - private final TransitSchedule schedule; - - @Inject - public DeterministicStopStopTimeCalculator(TransitRouter transitRouter, TransitSchedule schedule) { - this.transitRouter = transitRouter; - this.schedule = schedule; - } - - @Override - public double getStopStopTime(Id stopOId, Id stopDId, double time) { - // ATTENTION! This could be optimized. Basically, we probably don't need to - // route here. However, finding the travel time even on one route is not a - // computationally efficient task, because the same transit stop id may occur - // multiple times on the same route. - - TransitStopFacility originFacility = schedule.getFacilities().get(stopOId); - TransitStopFacility destinationFacility = schedule.getFacilities().get(stopDId); - - List legs = transitRouter.calcRoute(DefaultRoutingRequest.withoutAttributes(originFacility, destinationFacility, time, null)); - return legs.stream().mapToDouble(l -> ((Leg)l).getTravelTime().seconds()).sum(); - } - - @Override - public double getStopStopTimeVariance(Id stopOId, Id stopDId, - double time) { - return 0.0; - } - - @Override - public StopStopTime get() { - return new StopStopTime() { - @Override - public double getStopStopTimeVariance(Id stopOId, Id stopDId, - double time) { - return 0.0; - } - - @Override - public double getStopStopTime(Id stopOId, Id stopDId, - double time) { - return DeterministicStopStopTimeCalculator.this.getStopStopTime(stopOId, stopDId, time); - } - }; - } -} diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/deterministic/DeterministicWaitTimeCalculator.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/deterministic/DeterministicWaitTimeCalculator.java deleted file mode 100644 index d1aa43ce61b..00000000000 --- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/deterministic/DeterministicWaitTimeCalculator.java +++ /dev/null @@ -1,84 +0,0 @@ -package org.matsim.contrib.pseudosimulation.trafficinfo.deterministic; - -import java.util.LinkedList; -import java.util.List; - -import org.matsim.api.core.v01.Id; -import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTime; -import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTimeCalculator; -import org.matsim.pt.transitSchedule.api.Departure; -import org.matsim.pt.transitSchedule.api.TransitLine; -import org.matsim.pt.transitSchedule.api.TransitRoute; -import org.matsim.pt.transitSchedule.api.TransitRouteStop; -import org.matsim.pt.transitSchedule.api.TransitSchedule; -import org.matsim.pt.transitSchedule.api.TransitStopFacility; - -import com.google.inject.Inject; -import com.google.inject.Singleton; - -@Singleton -public class DeterministicWaitTimeCalculator implements WaitTimeCalculator { - private final TransitSchedule schedule; - - @Inject - public DeterministicWaitTimeCalculator(TransitSchedule schedule) { - this.schedule = schedule; - } - - @Override - public double getRouteStopWaitTime(Id lineId, Id routeId, Id stopId, - double time) { - TransitRoute route = schedule.getTransitLines().get(lineId).getRoutes().get(routeId); - - // First collect all the offsets on the route for a specific transit stop id. - // Note that a single transit facility may be contained multiple times on a - // route! - List facilityOffsets = new LinkedList<>(); - - for (TransitRouteStop stop : route.getStops()) { - if (stop.getStopFacility().getId().equals(stopId)) { - facilityOffsets.add(stop.getDepartureOffset().seconds()); - } - } - - if (facilityOffsets.size() == 0) { - // The facility is not contained on this route - throw new IllegalStateException(); - } - - // Now loop through all the departures and routes and find the actual stop - // departure that is right after the given time. - - double minimumWaitTime = Double.POSITIVE_INFINITY; - - for (double offset : facilityOffsets) { - for (Departure departure : route.getDepartures().values()) { - double stopDepartureTime = departure.getDepartureTime() + offset; - - while (stopDepartureTime < time) { - // Consistent with TransitRouterNetworkTravelTimeAndDisutility.MIDNIGHT - stopDepartureTime += 24.0 * 3600; - } - - double waitTime = time - stopDepartureTime; - - if (waitTime < minimumWaitTime) { - minimumWaitTime = waitTime; - } - } - } - - return minimumWaitTime; - } - - @Override - public WaitTime get() { - return new WaitTime() { - @Override - public double getRouteStopWaitTime(Id lineId, Id routeId, - Id stopId, double time) { - return DeterministicWaitTimeCalculator.this.getRouteStopWaitTime(lineId, routeId, stopId, time); - } - }; - } -} diff --git a/contribs/pseudosimulation/src/test/java/org/matsim/contrib/pseudosimulation/RunPSimTest.java b/contribs/pseudosimulation/src/test/java/org/matsim/contrib/pseudosimulation/RunPSimTest.java index 994a35e162e..82224f40c4f 100644 --- a/contribs/pseudosimulation/src/test/java/org/matsim/contrib/pseudosimulation/RunPSimTest.java +++ b/contribs/pseudosimulation/src/test/java/org/matsim/contrib/pseudosimulation/RunPSimTest.java @@ -109,7 +109,7 @@ public void install() { Population popActual = PopulationUtils.createPopulation( config ); PopulationUtils.readPopulation( popActual, outDir + "/output_plans.xml.gz" ); new PopulationComparison().compare( popExpected, popActual ) ; - Assert.assertEquals("RunPsim score changed.", 138.90474624352407, psimScore, MatsimTestUtils.EPSILON); + Assert.assertEquals("RunPsim score changed.", 138.88379880881348, psimScore, MatsimTestUtils.EPSILON); // Assert.assertEquals("RunPsim score changed.", 134.54001491094124d, psimScore, MatsimTestUtils.EPSILON); // Assert.assertEquals("RunPsim score changed.", 134.52369453719413d, psimScore, MatsimTestUtils.EPSILON); // Assert.assertEquals("RunPsim score changed.", 132.73129073101293d, psimScore, MatsimTestUtils.EPSILON);