pam.vehicles
CapacityType(seats=4, standingRoomInPersons=0)
dataclass
#
Vehicle capacity dataclass with read/write methods.
ATTRIBUTE | DESCRIPTION |
---|---|
seats |
Seats in/on vehicle.
TYPE:
|
standingRoomInPersons |
Standing room in/on vehicle.
TYPE:
|
ElectricVehicle(vid, type_id, battery_capacity=60, initial_soc=battery_capacity, charger_types='default')
dataclass
#
Bases: Vehicle
Electric vehicle data representation. Required for MATSim EV extension.
ATTRIBUTE | DESCRIPTION |
---|---|
vid |
Unique vehicle identifier.
TYPE:
|
type_id |
Type of vehicle, eg "default_car".
TYPE:
|
battery_capacity |
Charge capacity.
TYPE:
|
initial_soc |
Initial state of charge.
TYPE:
|
charger_types |
Types of chargers vehicle may use.
TYPE:
|
battery_capacity: float = 60
class-attribute
instance-attribute
#
charger_types: str = 'default'
class-attribute
instance-attribute
#
initial_soc: float = battery_capacity
class-attribute
instance-attribute
#
type_id: str
instance-attribute
#
vid: str
instance-attribute
#
to_ev_xml(xf)
#
Write vehicle to MATSim formatted xml.
PARAMETER | DESCRIPTION |
---|---|
xf
|
Parent xml element.
TYPE:
|
Source code in src/pam/vehicles.py
to_xml(xf)
#
Write vehicle to MATSim formatted xml.
PARAMETER | DESCRIPTION |
---|---|
xf
|
Parent xml element.
TYPE:
|
Vehicle(vid, type_id)
dataclass
#
Vehicle parent data class, holds required vehicle data (id and type) and read/write methods.
ATTRIBUTE | DESCRIPTION |
---|---|
vid |
Unique vehicle identifier.
TYPE:
|
type_id |
Type of vehicle, eg "default_car".
TYPE:
|
VehicleManager()
#
Vehicles and vehicle types representation, responsible for read/write from MATSim vehicles files.
ATTRIBUTE | DESCRIPTION |
---|---|
_veh_types |
Mapping of type ids to vehicle types data.
TYPE:
|
_vehicles |
Mapping of vehicle ids to vehicle data. |
Source code in src/pam/vehicles.py
evs: dict[str, ElectricVehicle]
property
#
Return dictionary of electric vehicles in manager.
RETURNS | DESCRIPTION |
---|---|
dict[str, ElectricVehicle]
|
dict[str, ElectricVehicle]: Dictionary of electric vehicles. |
add_type(vehicle_type)
#
Add vehicle type to manager.
PARAMETER | DESCRIPTION |
---|---|
vehicle_type
|
Vehicle type dataclass.
TYPE:
|
Source code in src/pam/vehicles.py
add_veh(v)
#
Add vehicle to manager.
PARAMETER | DESCRIPTION |
---|---|
v
|
Vehicle dataclass.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
PAMVehicleIdError
|
Unknown vehicle type. |
Source code in src/pam/vehicles.py
charger_types()
#
clear_types()
#
clear_vehs()
#
evs_from_xml(path)
#
Reads vehicles from MATSim vehicles file (https://www.matsim.org/files/dtd/vehicleDefinitions_v2.0.xsd).
PARAMETER | DESCRIPTION |
---|---|
path
|
path to matsim all_vehicles xml file
TYPE:
|
Source code in src/pam/vehicles.py
from_xml(vehs_path, evs_path=None)
#
Reads MATSim vehicles from https://www.matsim.org/files/dtd/vehicleDefinitions_v2.0.xsd and reads electric_vehicles from https://www.matsim.org/files/dtd/electric_vehicles_v1.dtd. Requires a vehicles file to load an evs file because the electric vehicle type is expected to be defined in the vehicles input.
PARAMETER | DESCRIPTION |
---|---|
vehs_path
|
path to matsim all_vehicles xml file
TYPE:
|
evs_path
|
optional path to matsim electric_vehicles xml file. Defaults to None. |
RAISES | DESCRIPTION |
---|---|
UserWarning
|
Cannot load evs without a vehs file. |
UserWarning
|
Fails consistency check. |
Source code in src/pam/vehicles.py
get(k, default=None)
#
is_consistent()
#
Check that manager vehicle population and types are consistent.
RAISES | DESCRIPTION |
---|---|
PAMVehicleIdError
|
Unknown vehicle type. |
RETURNS | DESCRIPTION |
---|---|
bool
|
Manager is consistent. Note that this doesn't check for unused types.
TYPE:
|
Source code in src/pam/vehicles.py
len()
#
pop(vid)
#
redundant_types()
#
Check for ununsed vehicle types.
RETURNS | DESCRIPTION |
---|---|
dict
|
unused types.
TYPE:
|
Source code in src/pam/vehicles.py
remove_type(tid)
#
Remove vehicle type.
PARAMETER | DESCRIPTION |
---|---|
tid
|
Vehicle type id.
TYPE:
|
Source code in src/pam/vehicles.py
to_ev_xml(path)
#
Writes MATSim electric vehciles file as per https://www.matsim.org/files/dtd/electric_vehicles_v1.dtd.
PARAMETER | DESCRIPTION |
---|---|
path
|
name of output file
TYPE:
|
Source code in src/pam/vehicles.py
to_veh_xml(path)
#
Writes MATSim vehicles file as per https://www.matsim.org/files/dtd/vehicleDefinitions_v2.0.xsd.
PARAMETER | DESCRIPTION |
---|---|
path
|
name of output file.
TYPE:
|
Source code in src/pam/vehicles.py
to_xml(vehs_path, evs_path=None)
#
Write manager to MATSim formatted xml.
PARAMETER | DESCRIPTION |
---|---|
vehs_path
|
Write path for MATSim vehicles file.
TYPE:
|
evs_path
|
Write path for MATSim electric vehicles file. Defaults to None. |
Source code in src/pam/vehicles.py
types_from_xml(path)
#
Reads vehicle types from MATSim vehicles file (https://www.matsim.org/files/dtd/vehicleDefinitions_v2.0.xsd).
PARAMETER | DESCRIPTION |
---|---|
path
|
path to matsim all_vehicles xml file
TYPE:
|
Source code in src/pam/vehicles.py
vehs_from_xml(path)
#
Reads vehicles from MATSim vehicles file (https://www.matsim.org/files/dtd/vehicleDefinitions_v2.0.xsd).
PARAMETER | DESCRIPTION |
---|---|
path
|
path to matsim all_vehicles xml file
TYPE:
|
Source code in src/pam/vehicles.py
VehicleType(id, length=7.5, width=1.0, networkMode='car', capacity=CapacityType(), description='personal_vehicle', passengerCarEquivalents=1.0, flowEfficiencyFactor=1.0)
dataclass
#
Vehicle type data with read/write methods.
ATTRIBUTE | DESCRIPTION |
---|---|
id |
type id.
TYPE:
|
length |
Vehicle length in m.
TYPE:
|
width |
Vehicle width in m.
TYPE:
|
networkMode |
MATSim network mode (used for routing).
TYPE:
|
capacity |
Vehicle seating and standing capacity.
TYPE:
|
description |
Vehicle description.
TYPE:
|
passengerCarEquivalents |
Vehicle size as passenger car equivalents (PCUs).
TYPE:
|
flowEfficiencyFactor |
Vehicle flow efficiency factor.
TYPE:
|
capacity: CapacityType = field(default_factory=CapacityType)
class-attribute
instance-attribute
#
description: str = 'personal_vehicle'
class-attribute
instance-attribute
#
flowEfficiencyFactor: float = 1.0
class-attribute
instance-attribute
#
id: str
instance-attribute
#
length: float = 7.5
class-attribute
instance-attribute
#
networkMode: str = 'car'
class-attribute
instance-attribute
#
passengerCarEquivalents: float = 1.0
class-attribute
instance-attribute
#
width: float = 1.0
class-attribute
instance-attribute
#
from_xml_elem(elem)
classmethod
#
Construct VehicleType from MATSim xml element.
PARAMETER | DESCRIPTION |
---|---|
elem
|
MATSim formatted vehicle type xml element.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
VehicleType
|
Vehicle type dataclass.
TYPE:
|
Source code in src/pam/vehicles.py
to_xml(xf)
#
Write vehicle type to MATSim formatted xml.
PARAMETER | DESCRIPTION |
---|---|
xf
|
Parent xml element.
TYPE:
|