This repository has been archived by the owner on Nov 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #287 from matsim-vsp/kmt_2echelon4Diss
More forward using Roadpricing also for scoring
- Loading branch information
Showing
11 changed files
with
467 additions
and
35 deletions.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
src/main/java/org/matsim/freight/logistics/analysis/Driver2VehicleEventHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
*********************************************************************** * | ||
* project: org.matsim.* | ||
* * | ||
* *********************************************************************** * | ||
* * | ||
* copyright : (C) 2024 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.freight.logistics.analysis; | ||
|
||
import org.matsim.api.core.v01.Id; | ||
import org.matsim.api.core.v01.events.VehicleEntersTrafficEvent; | ||
import org.matsim.api.core.v01.events.VehicleLeavesTrafficEvent; | ||
import org.matsim.api.core.v01.events.handler.VehicleEntersTrafficEventHandler; | ||
import org.matsim.api.core.v01.events.handler.VehicleLeavesTrafficEventHandler; | ||
import org.matsim.api.core.v01.population.Person; | ||
import org.matsim.vehicles.Vehicle; | ||
|
||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
/** | ||
* Basic event handler that collects the relation between vehicles and drivers. | ||
* Necessary since link enter and leave events do not contain the driver anymore. | ||
* <p> | ||
* This is the vice-versa implementation of {@link org.matsim.core.events.algorithms.Vehicle2DriverEventHandler}. | ||
* <p> | ||
* In a first step only used internally. When needed more often, I have nothing against putting it more central. -> matsim-libs | ||
* | ||
* @author kturner | ||
*/ | ||
public class Driver2VehicleEventHandler implements VehicleEntersTrafficEventHandler, VehicleLeavesTrafficEventHandler { | ||
|
||
private final Map<Id<Person>, Id<Vehicle>> driversVehicles = new ConcurrentHashMap<>(); | ||
|
||
@Override | ||
public void reset(int iteration) { | ||
driversVehicles.clear(); | ||
} | ||
|
||
@Override | ||
public void handleEvent(VehicleEntersTrafficEvent event) { | ||
driversVehicles.put(event.getPersonId(), event.getVehicleId()); | ||
} | ||
|
||
@Override | ||
public void handleEvent(VehicleLeavesTrafficEvent event) { | ||
driversVehicles.remove(event.getPersonId()); | ||
} | ||
|
||
/** | ||
* @param personId the unique driver identifier. | ||
* @return vehicle id of the driver's vehicle | ||
*/ | ||
public Id<Vehicle> getVehicleOfDriver(Id<Person> personId) { | ||
return driversVehicles.get(personId); | ||
} | ||
|
||
} |
71 changes: 71 additions & 0 deletions
71
src/main/java/org/matsim/freight/logistics/analysis/Vehicle2CarrierEventHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
*********************************************************************** * | ||
* project: org.matsim.* | ||
* * | ||
* *********************************************************************** * | ||
* * | ||
* copyright : (C) 2024 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.freight.logistics.analysis; | ||
|
||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
import org.matsim.api.core.v01.Id; | ||
import org.matsim.freight.carriers.Carrier; | ||
import org.matsim.freight.carriers.events.CarrierTourEndEvent; | ||
import org.matsim.freight.carriers.events.CarrierTourStartEvent; | ||
import org.matsim.freight.carriers.events.eventhandler.CarrierTourEndEventHandler; | ||
import org.matsim.freight.carriers.events.eventhandler.CarrierTourStartEventHandler; | ||
import org.matsim.vehicles.Vehicle; | ||
|
||
/** | ||
* Basic event handler that collects the relation between vehicles and carrier. | ||
* Necessary since there is no event having all this information together. | ||
* <p> | ||
* This is a modified implementation of {@link org.matsim.core.events.algorithms.Vehicle2DriverEventHandler}. | ||
* <p> | ||
* In a first step only used internally. When needed more often, I have nothing against putting it more central. -> matsim-libs | ||
* | ||
* @author kturner | ||
*/ | ||
public class Vehicle2CarrierEventHandler implements CarrierTourStartEventHandler, CarrierTourEndEventHandler { | ||
|
||
private final Map<Id<Vehicle>, Id<Carrier>> vehicle2carrier = new ConcurrentHashMap<>(); | ||
|
||
@Override | ||
public void reset(int iteration) { | ||
vehicle2carrier.clear(); | ||
} | ||
|
||
@Override | ||
public void handleEvent(CarrierTourStartEvent event) { | ||
vehicle2carrier.put(event.getVehicleId(), event.getCarrierId()); | ||
} | ||
|
||
@Override | ||
public void handleEvent(CarrierTourEndEvent event) { | ||
vehicle2carrier.remove(event.getVehicleId()); | ||
} | ||
|
||
/** | ||
* @param vehicleId the unique vehicle Id | ||
* @return id of the vehicle's carrier | ||
*/ | ||
public Id<Carrier> getCarrierOfVehicle(Id<Vehicle> vehicleId) { | ||
return vehicle2carrier.get(vehicleId); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.