Distances#

add_approval_distance(name: str, function: callable) None[source]#

Adds a new approval distance to the list of approval distances.

Parameters:
  • name – Name of the distance.

  • function – function that computes the distance.

Return type:

None.

add_ordinal_distance(name: str, function: callable) None[source]#

Adds a new ordinal distance to the list of ordinal distances.

Parameters:
  • name – Name of the distance.

  • function – function that computes the distance.

Return type:

None.

get_approval_distance(election_1: ~mapof.elections.objects.ApprovalElection.ApprovalElection, election_2: ~mapof.elections.objects.ApprovalElection.ApprovalElection, distance_id: str | None = None, **kwargs) -> (<class 'float'>, <class 'list'>)[source]#

Computes distance between approval elections, (if applicable) optimal matching.

Parameters:
  • election_1 – First election.

  • election_2 – Second election.

  • distance_id – Name of the distance.

get_distance(election_1, election_2, distance_id: str | None = None) float[source]#

Computes distance between elections, (if applicable) optimal matching.

Parameters:
  • election_1 – First election.

  • election_2 – Second election.

  • distance_id – Name of the distance.

get_ordinal_distance(election_1: OrdinalElection, election_2: OrdinalElection, distance_id: str | None = None, **kwargs) float[source]#

Computes distance between ordinal elections, (if applicable) optimal matching.

Parameters:
  • election_1 – First election.

  • election_2 – Second election.

  • distance_id – Name of the distance.

run_multiple_processes(experiment: Experiment, instances_ids: list, distances: dict, times: dict, matchings: dict, process_id: int) None[source]#

Single process for computing distances

run_single_process(exp: Experiment, instances_ids: list, distances: dict, times: dict, matchings: dict, safe_mode: bool = False) None[source]#

Single process for computing distances