Matchings — Map of Objects

Skip to main content
`Ctrl`+`K`

# Matchings

solve_matching_matrices(matrix_1: list[list], matrix_2: list[list], length: int, inner_distance: callable) → float

  Computes the minimal distance between two matrices.

  We assume that both matrices are square matrices of the same size with zeros on the diagonal.

  We allow reordering of the rows and columns of the second matrix, however, whenever we reorder

    a row we have to reorder the corresponding column as well, and vice versa.

  We use the Gurobi optimization library to solve the assignment problem.

  Parameters:

    - matrix_1 (list[list]) – First square matrix.

    - matrix_2 (list[list]) – Second square matrix.

    - length (int) – Length of the matrix.

    - inner_distance (callable) – The inner distance (like L1 or L2).

  Returns:

    Objective value.

  Return type:

    float

solve_matching_vectors(cost_table: list[list]) -> (<class 'float'>, <class 'list'>)

  Computes linear sum assignment.

  Parameters:

    cost_table (list[list]) – Cost table.

  Returns:

    Objective value, Optimal matching

  Return type:

    (float, list)