Skip to main content
`Ctrl`+`K`

# aequilibrae.distribution.GravityCalibration

class aequilibrae.distribution.GravityCalibration(project=None, **kwargs)

  Calibrate a traditional gravity model

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

      >>> from aequilibrae.distribution import GravityCalibration

      >>> project = create_example(project_path)

      # We load the demand matrix
      >>> demand = project.matrices.get_matrix("demand_omx")
      >>> demand.computational_view()

      # We load the skim matrix
      >>> skim = project.matrices.get_matrix("skims")
      >>> skim.computational_view(["time_final"])

      >>> args = {"matrix": demand,
      ...         "impedance": skim,
      ...         "row_field": "productions",
      ...         "function": 'expo',
      ...         "nan_as_zero": True}
      >>> gravity = GravityCalibration(**args)

      # Solve and save outputs
      >>> gravity.calibrate()
      >>> gravity.model.save(os.path.join(project_path, 'dist_expo_model.mod'))

  __init__(project=None, **kwargs)

    Instantiates the Gravity calibration problem

    Arguments:

      matrix (`AequilibraeMatrix`): Seed/base trip matrix

      impedance (`AequilibraeMatrix`): Impedance matrix to be used

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

      project (`Project`, Optional): The Project to connect to. By default, uses the currently active project

      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__`([project]) | Instantiates the Gravity calibration problem
  `calibrate`() | Calibrate the model

  calibrate()

    Calibrate the model

    Resulting model is in output class member