jodeln.od package

jodeln.od.od_estimation module

jodeln.od.od_estimation.estimate_od(net: Network, od_mat, weight_total_geh=None, weight_odsse=None, weight_route_ratio=None)

Estimate an OD matrix based on a seed matrix and target volumes within the network links/turns.

Uses a cma-es optimization algorithm to iteratively manipulate the seed matrix until the target volumes are met.

Parameters
  • weight_total_geh (float, optional) – Objective function weight of the sum of all GEH values in the network.

  • weight_odsse (float, optional) – Objective function weight for the influence of the seed matrix. Higher weight means the estimated matrix should have values close to the seed matrix, even if that means sacrificing link and turn GEH.

  • weight_route_ratio (float, optional) – Objective function weight of the OD route ratios.

Returns

Result from cma-es objective function variables.

Return type

List[float]

jodeln.od.od_estimation.objective_fn_prep_net_geh(net: Network)

Prepare optimization objective function by estimating maximum network GEH.

Warning: this function mutates net by directly assigning link and turn volumes. TODO: after calling this function, reset net to its state before calling this funciton.

Parameters

net (Network) – Network containing OD link and turn target volumes.

Returns

Estimated maximum sum of all differences between the seed and estimated OD.

Return type

float

jodeln.od.od_estimation.objective_fn_prep_odsse(net: Network)

Estimate maximum sum of sq error between seed and final od.

Parameters

net (Network) – Network containing OD seed volumes.

Returns

Estimated maximum sum of all differences between the seed and estimated OD.

Return type

float

jodeln.od.od_estimation.objective_fn_prep_route_ratios(net: Network)

Estimate maximum sum of route ratio differences.

Parameters

net (Network) – Network containing multiple routes per OD. (Also works with one route per OD, but technically the route ratios do not need to be involved if all ODs have a single route.)

Returns

Estimated maximum sum of all differences between assigned and target route ratios.

Return type

float

jodeln.od.od_read module

Import OD volumes.

jodeln.od.od_read.od_from_csv(od_csv, net: Network)

Creates an OD object from a csv OD matrix.

csv is a square OD matrix (n rows = n columns), zones are ordered the same in the rows and columns. First column contains zone name.

Example csv for four zones A, B, C, D. D is not a destination, C is not an origin:

A,0,100,250,0 B,99,0,98,0 C,0,0,0,0 D,10,12,12,0

Parameters
  • od_csv (str) – File path to OD csv file.

  • net (Network) – Network to assign the OD to.

Returns

Keyed by a tuple of (origin name, destination name) with a value of the OD volume.

Return type

Dict

jodeln.od.od_write module

Export OD volumes.

jodeln.od.od_write.export_od_as_list(net: Network, output_folder=None) None

Save the estimated OD to a csv file with one row per OD pair.

csv columns are:

  1. origin name

  2. destination name

  3. estimated volume.

Sample csv output – 100,101,32.2 100,102,67.6 105,109,21.0 –

Parameters
  • net (Network) – Network containing OD to export.

  • output_folder (str, optional) – Folder to export OD file, by default None indicates the current working directory as returned by os.getcwd().

jodeln.od.od_write.export_od_by_route(net: Network, output_folder=None) None

Save the estimated OD to a csv file. One row per route.

This export format allows showing the volume assigned to each route, if multiple routes between the origin and destination exist.

csv columns are:

  1. origin

  2. destination

  3. route name

  4. estimated route volume

Sample csv output. First two rows of the sample output are the same origin-destination, but have different routes.

– 100,105,101_106,30.0 100,105,102_107,15.0 105,109,105_110,21.0 –

Parameters
  • net (Network) – Network containing OD to export.

  • output_folder (str, optional) – Folder to export OD file, by default None indicates the current working directory as returned by os.getcwd().