preflibtools.properties.subdomains.dichotomous

Module for testing whether dichotomous instances are part of some subdomains.

Partition Subdomains

is_2_part(instance)

Tests whether the given categorical instance is 2 partitions.

Parameters:

instance (CategoricalInstance) – the instance

Returns:

A tuple consisting of a boolean indicating if the instance is 2 partitions and a partition of the candidates into two sets (or None if the instance is not 2 partitions).

Return type:

tuple[bool, list[set] | None]

is_part(instance)

Tests whether the given categorical instance is part of the partition subdomain.

Parameters:

instance (CategoricalInstance) – the instance

Returns:

A tuple consisting of a boolean indicating if the instance is partition and a partition of the candidates into sets (or None if the instance is not partition).

Return type:

tuple[bool, list[set] | None]

Interval Subdomains

instance_to_ci_matrix(instance)

Builds a matrix so that the instance is candidate interval if and only if the matrix has the consecutive ones property.

Parameters:

instance (CategoricalInstance) – the instance, only the first class is used

is_candidate_extremal_interval(instance)

Tests whether the given categorical instance is candidate extremal interval.

Parameters:

instance (CategoricalInstance) – the instance

Returns:

A tuple consisting of a boolean indicating if the instance is candidate extremal interval and the ordering of the candidates (or None if the instance is not candidate extremal interval).

Return type:

tuple[bool, list | None]

is_candidate_interval(instance)

Tests whether the given categorical instance is candidate interval.

Parameters:

instance (CategoricalInstance) – the instance

Returns:

A tuple consisting of a boolean indicating if the instance is candidate interval and the ordering of the candidates (or None if the instance is not candidate interval).

Return type:

tuple[bool, list | None]

is_voter_extremal_interval(instance)

Tests whether the given categorical instance is voter extremal interval.

Parameters:

instance (CategoricalInstance) – the instance

Returns:

A tuple consisting of a boolean indicating if the instance is voter extremal interval and the ordering of the voters (or None if the instance is not voter extremal interval).

Return type:

tuple[bool, list | None]

is_voter_interval(instance)

Tests whether the given categorical instance is voter interval.

Parameters:

instance (CategoricalInstance) – the instance

Returns:

A tuple consisting of a boolean indicating if the instance is voter interval and the ordering of the voters (or None if the instance is not voter interval).

Return type:

tuple[bool, list | None]

Euclidean Subdomains

is_dichotomous_euclidean(instance)

Tests whether the given categorical instance representing dichotomous preferences is Euclidean.

Parameters:

instance (CategoricalInstance) – the instance

Returns:

A tuple consisting of a boolean indicating if the instance is Euclidean, a dictionary mapping voters to their position and radius, and a dictionnary mapping alternatives to their position (or None if the instance is not Euclidean).

Return type:

tuple[bool, list | None, list | None]

Single-Crossing Subdomains

is_weakly_single_crossing(instance)

Tests whether the given categorical instance is weakly single crossing. Transforms a categorical instance into a matrix as defined in the proof of Theorem 13 in https://martin.lackner.xyz/publications/incompletesc-full.pdf and checks whether the matrix has the consecutive ones property.

Parameters:

instance (CategoricalInstance) – the instance

Returns:

A tuple consisting of a boolean indicating if the instance is weakly single crossing and an ordering of the ballots (or None if the instance is not weakly single crossing).

Return type:

tuple[bool, list[set] | None]