Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass person and vehicle to travel time query in FISS #3164

Merged
merged 3 commits into from
Mar 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.matsim.api.core.v01.network.Link;
import org.matsim.api.core.v01.network.Network;
import org.matsim.api.core.v01.population.Leg;
import org.matsim.api.core.v01.population.Person;
import org.matsim.contrib.dynagent.DynAgent;
import org.matsim.core.api.experimental.events.EventsManager;
import org.matsim.core.controler.MatsimServices;
Expand Down Expand Up @@ -94,22 +95,25 @@ public boolean handleDeparture(double now, MobsimAgent agent, Id<Link> linkId) {
Leg currentLeg = (Leg) planAgent.getCurrentPlanElement();
Gbl.assertIf(this.fissConfigGroup.sampledModes.contains(currentLeg.getMode()));
NetworkRoute networkRoute = (NetworkRoute) currentLeg.getRoute();
Person person = planAgent.getCurrentPlan().getPerson();
Vehicle vehicle = this.matsimServices.getScenario().getVehicles().getVehicles()
.get(networkRoute.getVehicleId());

// update travel time with travel times of last iteration
double newTravelTime = 0.0;
// start and end link are not consideres in NetworkRoutingModule for travel time
// start and end link are not considered in NetworkRoutingModule for travel time
for (Id<Link> routeLinkId : networkRoute.getLinkIds()) {
newTravelTime += this.travelTime.getLinkTravelTime(network.getLinks().get(routeLinkId),
now + newTravelTime, null, null);
now + newTravelTime, person, vehicle);
}
LOG.debug("New travelTime: {}, was {}", newTravelTime,
networkRoute.getTravelTime().orElseGet(() -> Double.NaN));
networkRoute.setTravelTime(newTravelTime);
}
// remove vehicle of teleported agent from parking spot
QVehicle removedVehicle = null;
if (agent instanceof MobsimDriverAgent) {
Id<Vehicle> vehicleId = ((MobsimDriverAgent) agent).getPlannedVehicleId();
if (agent instanceof MobsimDriverAgent driverAgent) {
Id<Vehicle> vehicleId = driverAgent.getPlannedVehicleId();
QVehicle vehicle = qNetsimEngine.getVehicles().get(vehicleId);
QLinkI qLinkI = (QLinkI) this.qNetsimEngine.getNetsimNetwork().getNetsimLink(linkId);
removedVehicle = qLinkI.removeParkedVehicle(vehicleId);
Expand Down
Loading