9.3.3. aequilibrae.GravityCalibration

class aequilibrae.GravityCalibration(**kwargs)

Bases: object

Calibrate a traditional gravity model

Available deterrence function forms are: ‘EXPO’ or ‘POWER’. ‘GAMMA’

from aequilibrae.matrix import AequilibraeMatrix
from aequilibrae.distribution import GravityCalibration

# We load the impedance matrix
matrix = AequilibraeMatrix()
matrix.load('path/to/trip_matrix.aem')
matrix.computational_view(['total_trips'])

 # We load the impedance matrix
impedmatrix = AequilibraeMatrix()
impedmatrix.load('path/to/impedance_matrix.aem')
impedmatrix.computational_view(['traveltime'])

# Creates the problem
args = {"matrix": matrix,
        "impedance": impedmatrix,
        "row_field": "productions",
        "function": 'expo',
        "nan_as_zero":True
        }
gravity = GravityCalibration(**args)

# Solve and save outputs
gravity.calibrate()
gravity.model.save('path/to/dist_expo_model.mod')
with open('path.to/report.txt', 'w') as f:
    for line in gravity.report:
        f.write(f'{line}

‘)

__init__(**kwargs)

Instantiates the Gravity calibration problem

Args:

matrix (AequilibraeMatrix): Seed/base trip matrix

impedance (AequilibraeMatrix): Impedance matrix to be used

function (str): Function name to be calibrated. “EXPO” or “POWER”

parameters (str, optional): Convergence parameters. Defaults to those in the parameter file

nan_as_zero (bool, optional): If Nan values should be treated as zero. Defaults to True

Results:

model (SyntheticGravityModel): Calibrated model

report (list): Iteration and convergence report

error (str): Error description

Methods

__init__(**kwargs)

Instantiates the Gravity calibration problem

calibrate()

Calibrate the model

__init__(**kwargs)

Instantiates the Gravity calibration problem

Args:

matrix (AequilibraeMatrix): Seed/base trip matrix

impedance (AequilibraeMatrix): Impedance matrix to be used

function (str): Function name to be calibrated. “EXPO” or “POWER”

parameters (str, optional): Convergence parameters. Defaults to those in the parameter file

nan_as_zero (bool, optional): If Nan values should be treated as zero. Defaults to True

Results:

model (SyntheticGravityModel): Calibrated model

report (list): Iteration and convergence report

error (str): Error description