diff --git a/contribs/discrete_mode_choice/src/main/java/org/matsim/contribs/discrete_mode_choice/components/utils/PTWaitingTimeEstimator.java b/contribs/discrete_mode_choice/src/main/java/org/matsim/contribs/discrete_mode_choice/components/utils/PTWaitingTimeEstimator.java index 2b4da256f0b..a253763488a 100644 --- a/contribs/discrete_mode_choice/src/main/java/org/matsim/contribs/discrete_mode_choice/components/utils/PTWaitingTimeEstimator.java +++ b/contribs/discrete_mode_choice/src/main/java/org/matsim/contribs/discrete_mode_choice/components/utils/PTWaitingTimeEstimator.java @@ -1,5 +1,10 @@ package org.matsim.contribs.discrete_mode_choice.components.utils; +import java.util.List; + +import org.matsim.api.core.v01.TransportMode; +import org.matsim.api.core.v01.population.Leg; +import org.matsim.api.core.v01.population.PlanElement; import org.matsim.pt.routes.TransitPassengerRoute; /** @@ -11,5 +16,19 @@ * @author sebhoerl */ public interface PTWaitingTimeEstimator { + double estimateWaitingTime(double departureTime, TransitPassengerRoute route); + + default double estimateWaitingTime(List elements) { + double totalWaitingTime = 0.0; + + for (PlanElement element : elements) { + if (element instanceof Leg leg && leg.getMode().equals(TransportMode.pt)) { + TransitPassengerRoute route = (TransitPassengerRoute) leg.getRoute(); + totalWaitingTime += this.estimateWaitingTime(leg.getDepartureTime().seconds(), route); + } + } + + return totalWaitingTime; + } } diff --git a/contribs/discrete_mode_choice/src/main/java/org/matsim/contribs/discrete_mode_choice/components/utils/ScheduleWaitingTimeEstimator.java b/contribs/discrete_mode_choice/src/main/java/org/matsim/contribs/discrete_mode_choice/components/utils/ScheduleWaitingTimeEstimator.java index 2ab5bfe10ca..78e9d45ee97 100644 --- a/contribs/discrete_mode_choice/src/main/java/org/matsim/contribs/discrete_mode_choice/components/utils/ScheduleWaitingTimeEstimator.java +++ b/contribs/discrete_mode_choice/src/main/java/org/matsim/contribs/discrete_mode_choice/components/utils/ScheduleWaitingTimeEstimator.java @@ -8,8 +8,6 @@ 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.population.Leg; -import org.matsim.api.core.v01.population.PlanElement; import org.matsim.core.utils.collections.Tuple; import org.matsim.core.utils.misc.OptionalTime; import org.matsim.core.utils.misc.Time; @@ -54,23 +52,6 @@ private Tuple, Id> createId(TransitLine transitLin return new Tuple<>(transitLine.getId(), transitRoute.getId()); } - public double estimateWaitingTime(List elements) { - double totalWaitingTime = 0.0; - - for (PlanElement element : elements) { - if (element instanceof Leg) { - Leg leg = (Leg) element; - - if (leg.getMode().equals("pt")) { - TransitPassengerRoute route = (TransitPassengerRoute) leg.getRoute(); - totalWaitingTime += estimateWaitingTime(leg.getDepartureTime().seconds(), route); - } - } - } - - return totalWaitingTime; - } - @Override public double estimateWaitingTime(double agentDepartureTime, TransitPassengerRoute route) { TransitLine transitLine = transitSchedule.getTransitLines().get(route.getLineId());