TMgen API

Generators

tmgen.models.modulated_gravity_tm()

Generate a modulated gravity traffic matrix with the given parameters

Parameters:
  • num_nodes – number of Points-of-Presence (i.e., origin-destination pairs)
  • num_tms – total number of traffic matrices to generate (i.e., time epochs)
  • mean_traffic – the average total volume of traffic
  • pm_ratio – peak-to-mean ratio. Peak traffic will be larger by this much (must be bigger than 1). Default is 1.5
  • t_ratio – trough-to-mean ratio. Default is 0.75
  • diurnal_freq – Frequency of modulation. Default is 1/24 (i.e., hourly) if you are generating multi-day TMs
  • spatial_variance – Variance on the volume of traffic between origin-destination pairs. Pick something reasonable with respect to your mean_traffic. Default is 100
  • temporal_variance – Variance on the volume in time
Returns:

tmgen.models.random_gravity_tm()

Random gravity model, parametrized by the mean traffic per ingress-egress pair. See http://dl.acm.org/citation.cfm?id=1096551 for full description

Parameters:
  • num_nodes – number of nodes in the network
  • mean_traffic – average traffic volume between a pair of nodes
Returns:

a new TrafficMatrix

tmgen.models.gravity_tm()

Compute the gravity traffic matrix, based on node populations (sizes). The TM will have no randomness and only contains one epoch.

..note::
A possible way of generating populations is to sample from a log-normal distribution
Parameters:
  • populations – array/list with populations (weights) for each node
  • total_traffic – total volume of traffic in the network (will be divided among all ingres-egress pairs)
Returns:

a new TrafficMatrix

tmgen.models.uniform_tm()

Return a uniform traffic matrix. Entries are chosen independently from each other, uniformly at random, between given values of low and high.

Parameters:
  • num_nodes – number of points-of-presence
  • low – lowest allowed value
  • high – highest allowed value
  • num_epochs – number of
Returns:

TrafficMatrix object

tmgen.models.exp_tm()

Exponential traffic matrix. Values are drawn from an exponential distribution, with a mean value of mean_traffic.

Parameters:
  • num_nodes – number of nodes in the network
  • mean_traffic – mean value of the distribution
  • num_epochs – number of epochs in the traffic matrix
Returns:

TrafficMatrix object

tmgen.models.spike_tm()

Generate a traffic matrix using the spike model.

Parameters:
  • num_nodes – number of nodes in the network
  • num_spikes – number of ingress-egress spikes. Must be fewer than \(numpops^2\)
  • mean_spike – average volume of a single spike
  • num_epochs – number of time epochs
Returns:

TrafficMatrix object

tmgen.models.exact_tm()

Create a traffic matrix where each value has exact value val.

Mostly used for unit tests when exact values are needed to check the solution, unlikely to be needed in practice.

Parameters:
  • num_nodes – number of nodes in the network
  • val – the value to use for each entry
  • num_epochs – number of epochs
Returns:

a new TrafficMatrix object

TrafficMatrix instance

class tmgen.TrafficMatrix

Represents a traffic matrix.

at_time()

Return a numpy array reprenseting a single TM at epoch t.

Parameters:t – the number of the epoch (0-indexed).
Return type:numpy array
between()

Return the traffic matrix between the given ingress and egress nodes. This method supports multiple temporal modes: ‘all’, ‘min’, ‘max’, and ‘mean’

Parameters:
  • o – source node (origin)
  • d – destination node
  • modestr – temporal mode
Returns:

Numpy array if modestr==’all’, double otherwise

static from_pickle()

Load a TrafficMatrix object from a file

Parameters:fname – the file name on disk
Returns:new TrafficMatrix
mean()

Returns a new traffic matrix that is the average across all epochs.

num_epochs()
Returns:The number of epochs in this traffic matrix
num_nodes()
Returns:The number of nodes in this traffic matrix
to_csv()

Save the matrix to a CSV file.

to_pickle()

Save the matrix to a python pickle file

Parameters:fname – the file name
worst_case()

Return a new, single-epoch traffic matrix that chooses maximum volume per OD pair (in time)

Returns:a new TrafficMatrix

Plotting