PyANGKernel.GKTrafficDemand

class GKTrafficDemand

The traffic demand for a network.

Details

A traffic demand is used by the Aimsun Next simulators to generate traffic in a network. It can be based either in OD matrices ( GKODMatrix ) or traffic states ( GKTrafficState ) but not on a mixture of both.

The traffic is in the OD matrix or the state, the demand is just a container for this information organized by - time - user class (vehicle type and purpose) An entry (by time and user class) is stored in a GKTrafficDemandItem object.

Inheritance diagram of PyANGKernel.GKTrafficDemand

Synopsis

Methods

Static functions

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

class GKTrafficDemandType

The Traffic Demand can be based in OD matrices or States.

__init__()
__init__(src)
Parameters:

srcGKTrafficDemand

Copy constructor which creates a ‘copy’ of the current demand.

Warning

Referenced objects are not duplicated. The new GKTrafficDemand object will instead share the referenced objects with this one.

addToSchedule(item)
Parameters:

itemGKScheduleDemandItem

Adds a new schedule item (the item is copied). It’s highly recommended that before adding new items the user calls setEnableColumnUpdate(false) to disable the total trips update.

clearExternalMatrixData()

clear external matrices

compressMatrices()

Compress all the matrices in this demand.

decompressMatrices()
Return type:

bool

Decompress all the matrices in this demand. Returns true if any matrix was compressed and then decompressed by this call.

duration()
Return type:

GKTimeDuration

Returns the duration for this traffic demand.

ensureMatrixData()

ensure matrix data of demand

getCentroidConfigurations()
Return type:

.list of GKCentroidConfiguration

If using OD matrices, it returns all centroid configurations. It is possible to have OD matrices from different centroid configurations within the same traffic demand.

getCentroids()
Return type:

.std.vectorGKCentroid

Get all the centroids in the different centroid configuration

getDemandType()
Return type:

GKTrafficDemandType

Returns the type of this demand, either OD Matrix based or Traffic State-based.

getFactor()
Return type:

str

Returns the percentage of the traffic demand to be used. 100 means all the traffic, 50 half the traffic, 200 two times the traffic found in each demand item. Note that it is possible also to set a factor by demand item.

getFactorValue([exp=None])
Parameters:

expGKGenericExperiment

Return type:

float

Returns the ‘factor’ value as a number. If the factor is defined through a variable, then the given experiment will be used to get the value. If the factor is not defined in the experiment, 100.0 will be returned.

getProblemNet()
Return type:

GKProblemNet

Returns the Subnetwork for this demand (if any).

getSchedule()
Return type:

.list of GKScheduleDemandItem

Returns all the schedule.

getSchedule(veh)
Parameters:

vehGKMobileAgent

Return type:

.list of GKScheduleDemandItem

Returns all the items for the vehicle “veh” sorted by time.

getSchedule(item)
Parameters:

itemGKTrafficDemandItem

Return type:

.list of GKScheduleDemandItem

Returns all the schedule in where the GKTrafficDemandItem “item” is used

getSchedule(userClass)
Parameters:

userClassGKUserClass

Return type:

.list of GKScheduleDemandItem

Returns all the items for the user class “userClass” sorted by time.

getTotalMatrix(cenConfiguration[, userClass=None[, experiment=None]])
Parameters:
Return type:

GKODMatrix

getTotalTrips([veh=None[, exp=None]])
Parameters:
Return type:

float

Returns the total number of trips in this matrix for a vehicle (if veh is NULL, then the trips for all the vehicles in the demand will be returned). Applies factors from GKGenericExperiment and GKScheduleDemandItem .

getTrafficArrivals()
Return type:

GKTrafficArrivals

Returns the traffic arrivals object that will be used.

getTrafficArrivalsFolder()
Return type:

GKFolder

helper function: list all the available traffic arrivals items, either from the project or from the subnetwork

getTrips(from, to[, userClass=None[, exp=None]])
Parameters:
Return type:

float

Returns the number of trips from an origin to a destination centroid for a vehicle (if veh is NULL, then the trips for all the vehicles in the demand will be returned). Applies factors from GKGenericExperiment and GKScheduleDemandItem . Note that if from is not a valid origin or to a valid destination then 0 is returned (no trips)

getTrips(from, to, start, duration[, userClass=None[, iExperiment=None]])
Parameters:
Return type:

float

Returns the number of trips from an origin to a destination centroid for a user class between start time and end time. Applies factors from GKGenericExperiment and GKScheduleDemandItem .

getTripsByDestination(to[, user=None[, exp=None]])
Parameters:
Return type:

float

Returns the number of trips to a destination from all the origin centroids for a vehicle (if veh is NULL, then the trips for all the vehicles in the demand will be returned). Applies factors from GKGenericExperiment and GKScheduleDemandItem . Note that if to is not a valid destination then 0 is returned (no trips).

getTripsByDestination(to, veh, exp)
Parameters:
Return type:

float

Returns the number of trips to a destination from all the origin centroids for a user class(if user is NULL, then the trips for all the user classes in the demand will be returned). Applies factors from GKGenericExperiment and GKScheduleDemandItem . Note that if to is not a valid destination then 0 is returned (no trips).

getTripsByOrigin(from[, user=None[, exp=None]])
Parameters:
Return type:

float

Returns the number of trips from an origin to all the destination centroids for a user class (if user is NULL, then the trips for all the vehicles in the demand will be returned). Applies factors from GKGenericExperiment and GKScheduleDemandItem . Note that if from is not a valid origin then 0 is returned (no trips).

getTripsByOrigin(from, veh, exp)
Parameters:
Return type:

float

Returns the number of trips from an origin to all the destination centroids for a vehicle (if veh is NULL, then the trips for all the vehicles in the demand will be returned). Applies factors from GKGenericExperiment and GKScheduleDemandItem . Note that if from is not a valid origin then 0 is returned (no trips).

getUsedUserClasses()
Return type:

.std.vectorGKUserClass

Returns a list of the user classes used in this traffic demand.

getUsedVehicles()
Return type:

.list of const GKMobileAgent

Returns a list of the mobile agents (either vehicle types or pedestrian types) used in this traffic demand.

hasPedestrians()
Return type:

bool

Returns true if any of the mobile agents in this traffic demand is a pedestrian type

hasTripsByDestination(to[, user=None[, exp=None]])
Parameters:
Return type:

bool

Returns if the centroid has any trips by destination for a user class (if user is nullptr, then the trips for all the vehicles in the demand will be returned). Applies factors from GKGenericExperiment and GKScheduleDemandItem . Note that if from is not a valid origin then 0 is returned (no trips).

hasTripsByDestination(to, veh, exp)
Parameters:
Return type:

bool

Returns if the centroid has any trips by destination for a vehicle (if veh is nullptr, then the trips for all the vehicles in the demand will be returned). Applies factors from GKGenericExperiment and GKScheduleDemandItem . Note that if from is not a valid origin then 0 is returned (no trips).

hasTripsByOrigin(from[, user=None[, exp=None]])
Parameters:
Return type:

bool

Returns if the centroid has any trips by origin for a user class (if user is nullptr, then the trips for all * the vehicles in the demand will be returned). Applies factors from GKGenericExperiment and GKScheduleDemandItem . * Note that if from is not a valid origin then 0 is returned (no trips).

hasTripsByOrigin(from, veh, exp)
Parameters:
Return type:

bool

Returns if the centroid has any trips by origin for a vehicle (if veh is nullptr, then the trips for all * the vehicles in the demand will be returned). Applies factors from GKGenericExperiment and GKScheduleDemandItem . * Note that if from is not a valid origin then 0 is returned (no trips).

initialTime()
Return type:

QTime

Returns the initial time for this traffic demand.

isEmpty()
Return type:

bool

Returns true if no item is in the demand.

isItIncludedInPlan(plan)
Parameters:

planGKMasterControlPlan

Return type:

bool

Checks if all the times in this demand have control plan information in the master control plan

isValid([reportErrors=true[, checkHoles=true]])
Parameters:
  • reportErrors – bool

  • checkHoles – bool

Return type:

bool

Returns true if the demand is valid: - No holes between demand items. - All the vehicles demands start and end at the same time. - There is no overlap between items.

That is, the temporal line is complete and the same for all the vehicles.

A empty demand ( isEmpty )returns true.

If <b>reportErrors</b> is true, the error will be shown in the Log window.

overlappedItems()
Return type:

bool

Returns true if any item overlaps with another. Called by isValid .

removeFromSchedule(item)
Parameters:

itemGKScheduleDemandItem

Removes a schedule item that is equal to “item” from the schedule. The item itself is not deleted.

removeSchedule()

Removes all the schedule information.

setFactor(afactor)
Parameters:

afactor – str

Sets the percentage of the traffic demand to be used. 100 means all the traffic, 50 half the traffic, 200 two times the traffic found in each demand item. Note that it is also possible to set a factor by demand item.

setInitialTimeAndTranslateItems(newInitialTime)
Parameters:

newInitialTimeQTime

Moves all the schedule from its original initial time to the new initial time given.

setProblemNet(pn)
Parameters:

pnGKProblemNet

Sets the Subnetwork for this demand (if any).

setTrafficArrivals(aTrafficArrivals)
Parameters:

aTrafficArrivalsGKTrafficArrivals

Sets the traffic arrivals object that will be used.

trafficDemandItemHasChanged(i)
Parameters:

iGKTrafficDemandItem

Notifies the GKTrafficDemand that the specified GKTrafficDemandItem has changed.

static translateFactor(factor[, exp=None])
Parameters:
Return type:

float

Helper function used by

See also

getFactorValue

validUserClassesForDynamicSimulations()
Return type:

bool

Returns true if there are as maximum one purpose per vehicle type. Dynamic simulations do not allow right now traffic demands with different purposes for the same vehicle type