Profiles User Guide

Preference Profiles

In socialchoicekit, we express an ordinal profile as a Python numpy array. The socialchoicekit.profile_utils.Profile object is a subclass of numpy.ndarray. The following are subclasses of socialchoicekit.profile_utils.Profile:

We can use these to express preference profiles for any of the three Settings (voting, resource allocation, and stable matching). The following is an example of initializing a profile without ties and missing values.

Consider the following ordinal profile. For example, agent 1 prefers alternative 4 the most, then alternative 3, then alternative 1, and prefers alternative 2 the least. Then, agent 1 would assign a rank of 1 to alternative 4, a rank of 2 to alternative 3, a rank of 3 to alternative 1, and a rank of 4 to alternative 2. We express this in the numpy array.

Agents

Ballot

1

\(4 \succsim_1 3 \succsim_1 1 \succsim_1 2\)

2

\(1 \succsim_2 2 \succsim_2 3 \succsim_2 4\)

3

\(3 \succsim_3 2 \succsim_3 4 \succsim_3 1\)

from socialchoicekit.profile_utils import StrictCompleteProfile
StrictCompleteProfile.of(
  np.array([
    [3, 4, 2, 1], # agent 1
    [1, 2, 3, 4], # agent 2
    [4, 2, 1, 3], # agent 3
  ])
)

We also express cardinal profiles as numpy arrays. The socialchoicekit.profile_utils.ValuationProfile object is a subclass of numpy.ndarray. The following are subclasses of socialchoicekit.profile_utils.ValuationProfile:

Agents Alternatives

1

2

3

4

1

0.25

0.1

0.3

0.35

2

0.5

0.2

0.16

0.14

3

0.9

0.05

0.03

0.02

If in the above example the agents had the above cardinal profile, we can express it in socialchoicekit as follows:

from socialchoicekit.profile_utils import CompleteValuationProfile
CompleteValuationProfile.of(
  np.array([
    [0.25, 0.1, 0.3, 0.35], # agent 1
    [0.5, 0.2, 0.16, 0.14], # agent 2
    [0.9, 0.05, 0.03, 0.02], # agent 3
  ])
)

Preflib Integration

Instead of manually creating profiles, we support loading data directly from the Preflib.

from preflibtools.instances import OrdinalInstance
from socialchoicekit.preflib_utils import preflib_soc_to_profile

url = 'https://www.preflib.org/static/data/agh/00009-00000001.soc'
instance = OrdinalInstance()
instance.parse_url(url)
profile = preflib_soc_to_profile(instance)

Profile Generation

We have functions to (trivially) generate or convert profiles.

valuation_profile = UniformValuationProfileGenerator(high=1, low=0, seed=1).generate(profile)