## Details of the proportional-representation algorithm

**Setup** The "quota" *q* of each party is calculated, being
the integral part of *v*c/V*, where *v* is the number of votes
received by the party, *c* is the number of constituencies and
*V* is the total number of votes cast over all constituencies in the
election.

**Phase 1** The first phase of the algorithm identifies "eligible"
as those who are either front-runners or have received 20% of the votes cast in their constituencies. In any constituency with only one eligible candidate,
that candidate is elected.

**Phase 2** In the main part of the algorithm, parties and MPs are
selected as follows.

For each party, that party's "priority" *p* is calculated from
the number *m* of MPs it has already got, its quota *q*, its
vote *v* and the number *c* of constituencies by the rule:
0 if *m*=*q*, that is, the party has already reached its quota;

(1+*c*)**v* if *m*=0 , that is, the party has not
yet got an MP, but *q* is greater than 0;

*v*/*m* if *m* is greater than 0 but less than
*q*.

The party with the highest quota is assigned to get another MP.

We now look for possible candidates, being candidates of the selected
party, in constituencies which do not yet have MPs, who are "eligible"
according to the rule in Phase 1. If there are none, then the party can
receive no more MPs and its quota is reduced to the number of MPs so far
elected from that party, before returning to the beginning of the Phase
2 algorithm.
Among the remaining eligible candidates from the selected party,
if there is a front-runner, we pick the one with the greatest lead over the
next candidate in that constituency;

if there is no front-runner, we pick the one with the smallest gap between
him and the front-runner in that constituency.

Now we have another MP and return to the beginning of Phase 2.

This phase ends when every party has *either* reached its quota
*or* has no eligible candidates remaining in constituencies without
MPs.
**Phase 3** At the end of Phase 2, there are normally constituencies
still without MPs; in these constituencies the front-runners are elected.

You can see my program (I apologize for the
language).

Return to general description of the scheme.

*24 May 2005*