Quick Start

Here is short guide to start and run your first elections.

Instalation

Pmp can be obtained by pip.

pip install python-multiwinner-package

Note: Don’t worry, it’s the only time you need to use this long name. In code use convenient abberiviation pmp

Just in case, you can also install it directly from github source.

pip install git+https://github.com/Koozco/pmp.git

Development instalation guide can be found here.

Basics - classes, methods, parameters.

Here are all entities necessary for running simple election.

  1. Parameters naming
    Usually we characterize an election with:

    • n - number of voters

    • m - number of candidates

    • k - size of committee

      n = 5
      m = 3
      k = 2
      
  2. Preferences Profile Depending on given rule, preferences are defined in an ordinal or approval model. Single preference always represents single voter.

    • Ordinal preferences

      from pmp.preferences import Ordinal
      orders = [
        [1, 2, 0],
        [2, 1, 0],
        [2, 0, 1],
        [1, 2, 0],
        [1, 0, 2]
      ]
      
      preferences = [Ordinal(o) for o in orders]
      
    • Approval preferences

      from pmp.preferences import Approval
      approves = [
        [0, 1, 2],
        [0, 1],
        [1],
        [1, 2],
        [0, 2]
      ]
      
      preferences = [Approval(a) for a in approves]
      
    • Profile
      With defined preferences next step is to create preferences profile. It consists of candidates and preferences lists.

      from pmp.preferences import Profile
      candidates = [0, 1, 2]
      
      profile = Profile(candidates, preferences)
      
  3. Finding committee
    You always compute winning committee with an instance of a rule. It has method find_committee with two obligatory parameters - k and profile, both which we have defined earlier. With one instance you can compute results for different values of k or for different profiles.

from pmp.rules import SNTV

sntv = SNTV()
committee = sntv.find_committee(k, profile)

For more detailed information we encourage to further reading next sections or go straight to Examples.