infill_cost_matrix#

caf.distribute.utils.infill_cost_matrix(cost_matrix, diag_factor=0.5, zeros_infill=0.5)#

Infill the cost matrix before starting the gravity model.

This function infills in two ways; firstly it infills the main diagonal (i.e. intrazonal costs) with the minimum value from each respective row multiplied by a factor, the logic being that an intrazonal trip is probably 50% (or whatever factor chosen) of the distance to the nearest zone. It also infills zeros in the matrix with a user defined value to avoid errors in the seed matrix.

Parameters:
  • cost_matrix (The cost matrix. This should be a square array)

  • diag_factor (The factor the rows' minimum values will be multiplied by to)

  • costs. (infill intrazonal)

  • zeros_infill (The infill value for other (non-diagonal) zeros in the matrix)

Returns:

np.ndarray

Return type:

The input matrix with values infilled.