Skip to content

Commit

Permalink
Merge branch 'mggg:main' into random-elections
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-q2 authored Aug 2, 2024
2 parents b9778a4 + 95d2d14 commit 092224e
Show file tree
Hide file tree
Showing 43 changed files with 664 additions and 467 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ dist/
extra_data/
.venv
.docs_venv
docs/_build
docs/_build
.dev
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Added
- Created a read the docs page.
- Add `scale` parameter to `ballot_graph.draw()` to allow for easier reading of text labels.
- Allow users to choose which bloc is W/C in historical Cambridge data for CambridgeSampler.

## Changed
- Updated tutorial notebooks; larger focus on slate models, updated notebooks to match current codebase.
- Removed the seq-RCV transfer rule since it is a dummy function, replaced with lambda function.
- Update plot MDS to have aspect ratio 1, remove axes labels since they are meaningless in MDS.
- Update all BLT files in scot-elex repo to be true CSV files, updated `load_scottish` accordingly.

## Fixed
- Fixed bug by which slate-PlackettLuce could not generate ballots when some candidate had 0 support.
Expand Down
1 change: 1 addition & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Jinja2==3.1.4
joblib==1.4.2
jsonschema==4.22.0
jsonschema-specifications==2023.12.1
jupyter==1.0.0
kiwisolver==1.4.5
MarkupSafe==2.1.5
matplotlib==3.9.0
Expand Down
6 changes: 3 additions & 3 deletions docs/social_choice_docs/scr.rst
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ candidates go in the slots.

- You can give the CS model other historical election data to use.

Distance Models
Spatial Models
---------------

1-D Spatial
Expand Down Expand Up @@ -492,7 +492,7 @@ Plurality scores. Equivalent to Limited with :math:`k=1` and SNTV.
HighestScore
------------
Conducts an election based on points from a score vector.
A score vector is a vector whose :math:`i`th entry denotes the number of points given
A score vector is a vector whose :math:`i` th entry denotes the number of points given
to a candidate in position :math:`i`. Normally a score vector is non-negative and
decreasing. A HighestScore election chooses the :math:`m` candidates with highest scores.
Ties are broken by randomly permuting the tied candidates.
Expand All @@ -503,7 +503,7 @@ Cumulative
Voting system where voters are allowed to vote for candidates with multiplicity.
Each ranking position should have one candidate, and every candidate ranked will receive
one point, i.e., the score vector is :math:`(1,\dots,1)`. Recall a score vector is a
vector whose :math:`i`th entry denotes the number of points given to a candidate in
vector whose :math:`i` th entry denotes the number of points given to a candidate in
position :math:`i`. Normally a score vector is non-negative and decreasing.

Distances between PreferenceProfiles
Expand Down
90 changes: 45 additions & 45 deletions docs/user/tutorial/1_intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ candidate will appear at the bottom of the ballot.
.. figure:: ../../_static/assets/preference_interval.png
:alt: png


png

One of the generative models is called the **slate-Plackett-Luce
model**, or s-PL. In s-PL, voters fill in their ballot from the top
Expand All @@ -396,7 +396,7 @@ but bear with us.
# the preference interval (80,15,5)
pref_intervals_by_bloc = {"all_voters":
{"all_voters": PreferenceInterval({"A": .80, "B":.15, "C":.05})}
{"all_voters": PreferenceInterval({"A": .80, "B": .15, "C": .05})}
}
# the sPL model needs an estimate of cohesion between blocs,
Expand All @@ -415,11 +415,11 @@ but bear with us.
.. parsed-literal::
Ballots Weight
(A, B, C) 61
(A, C, B) 17
(B, A, C) 17
(C, A, B) 4
(B, C, A) 1
(A, B, C) 56
(A, C, B) 23
(B, A, C) 12
(C, A, B) 7
(C, B, A) 2
Re-run the above block several times to see that the elections will come
Expand Down Expand Up @@ -461,11 +461,11 @@ their bloc.
# note that we include candidates with 0 support,
# and that our preference intervals will automatically rescale to sum to 1
pref_intervals_by_bloc = {"Alpha": {"Alpha": PreferenceInterval({"A": .8, "B":.15}),
"Xenon": PreferenceInterval({"X":0, "Y": .05})},
pref_intervals_by_bloc = {"Alpha": {"Alpha": PreferenceInterval({"A": .8, "B": .2}),
"Xenon": PreferenceInterval({"X": 0, "Y": 1})},
"Xenon": {"Alpha": PreferenceInterval({"A": .05, "B":.05}),
"Xenon": PreferenceInterval({"X":.45, "Y": .45})}}
"Xenon": {"Alpha": PreferenceInterval({"A": .5, "B": .5}),
"Xenon": PreferenceInterval({"X": .5, "Y": .5})}}
bloc_voter_prop = {"Alpha": .8, "Xenon": .2}
Expand Down Expand Up @@ -493,48 +493,48 @@ their bloc.
The ballots from Alpha voters
Ballots Weight
(A, B, Y, X) 5527
(B, A, Y, X) 967
(Y, A, B, X) 673
(A, Y, B, X) 605
(Y, B, A, X) 123
(B, Y, A, X) 105
(A, B, Y, X) 5184
(B, A, Y, X) 1283
(Y, A, B, X) 659
(A, Y, B, X) 580
(Y, B, A, X) 154
(B, Y, A, X) 140
The ballots from Xenon voters
PreferenceProfile too long, only showing 15 out of 24 rows.
Ballots Weight
(Y, X, A, B) 415
(X, Y, B, A) 405
(Y, X, B, A) 401
(X, Y, A, B) 397
(Y, X, A, B) 420
(X, Y, A, B) 412
(X, Y, B, A) 397
(Y, X, B, A) 378
(B, Y, X, A) 50
(A, X, Y, B) 45
(B, X, Y, A) 44
(Y, B, X, A) 41
(X, A, Y, B) 40
(Y, A, X, B) 36
(X, B, Y, A) 35
(A, Y, X, B) 33
(A, B, X, Y) 9
(B, Y, A, X) 9
(A, X, B, Y) 7
(X, A, Y, B) 48
(B, X, Y, A) 47
(A, X, Y, B) 44
(A, Y, X, B) 41
(Y, B, X, A) 37
(Y, A, X, B) 37
(X, B, Y, A) 34
(A, B, X, Y) 8
(B, A, Y, X) 7
(X, B, A, Y) 6
Aggregated ballots
PreferenceProfile too long, only showing 15 out of 30 rows.
Ballots Weight
(A, B, Y, X) 5527
(B, A, Y, X) 967
(Y, A, B, X) 673
(A, Y, B, X) 605
(Y, X, A, B) 415
(X, Y, B, A) 405
(Y, X, B, A) 401
(X, Y, A, B) 397
(Y, B, A, X) 123
(B, Y, A, X) 105
(A, B, Y, X) 5184
(B, A, Y, X) 1283
(Y, A, B, X) 659
(A, Y, B, X) 580
(Y, X, A, B) 420
(X, Y, A, B) 412
(X, Y, B, A) 397
(Y, X, B, A) 378
(Y, B, A, X) 154
(B, Y, A, X) 140
(B, Y, X, A) 50
(A, X, Y, B) 45
(B, X, Y, A) 44
(Y, B, X, A) 41
(X, A, Y, B) 40
(X, A, Y, B) 48
(B, X, Y, A) 47
(A, X, Y, B) 44
(A, Y, X, B) 41
Scan this to be sure it is reasonable, recalling that our intervals say
Expand Down
Loading

0 comments on commit 092224e

Please sign in to comment.