1 RubyVote: Election Methods Library in Ruby
2 =============================================
6 This software is pre release software. The authors of this software
7 are neither expert Ruby programmers or elections in election
8 methods. We are hackers and enthusiasts in both. This software has
9 bugs and it's quite possible that is has bugs that may skew
10 results. If you understand Ruby or election methods, please audit
16 **Latest Version:** 0.1
18 **Download Latest Version:** `here
19 <http://rubyforge.org/projects/rubyvote>`__
21 `RubyVote` is an election methods library implemented in Ruby. It is
22 designed to make it very easy to implement a variety of different types
23 of elections in Ruby including relatively complex election methods like
24 Condorcet. It could be useful for any sort of election, poll, or
30 `RubyVote` is graciously hosted by `RubyForge
31 <http://rubyforge.org/>`__.
33 You can visit the `RubyVote` homepage (a version of this file) here:
35 http://rubyvote.rubyforge.org/
37 You can visit the RubyForge project page to download the latest
38 version of software, get access to the latest development version from
39 Subversion, to file or bug, to look through documentation, to
40 participate in the forums, or to contribute in other ways. That page
43 http://rubyforge.org/projects/rubyvote
49 `RubyVote` is a library -- not an application or a voting machine. It
50 simply takes the raw "tallies" of votes and computes the results.
51 Currently, it does not include any sample interfaces (although if
52 contributed, these may be included).
54 `RubyVote` current includes a set of classes to tally votes and compute
55 winners in elections or votes using a series of different methods.
56 Currently these include:
58 * `Plurality`__ or "winner-take-all"
61 * `Simple Condorcet`__
62 * `Condorcet with Cloneproof SSD`__
64 __ http://en.wikipedia.org/wiki/Plurality_electoral_system
65 __ http://en.wikipedia.org/wiki/Approval_voting
66 __ http://en.wikipedia.org/wiki/Borda_count
67 __ http://en.wikipedia.org/wiki/Condorcet_method
68 __ http://en.wikipedia.org/wiki/Shulze_method
70 Writing support for a currently unsupported voting method (e.g., instant
71 runoff voting) is a fantastic way to to contribute to this module.
73 How To Use This Library
74 -------------------------
76 Using this library is relatively simple but will differ per election
77 methods. In each case, you will need to ``require`` the appropriate
78 file for the type of election you will be running and then create a
79 new vote object. You should then either pass an array of votes to the
80 object upon creation or pass votes in one at at a time.
85 *You* are responsible for ensuring that the votes are in correct
86 form before you hand them to this module. This will not currently
87 check for most types of invalid votes and does not (currently)
88 accept a list of candidates at creation from which it checks all
89 votes. As such, new candidates will be created when seen. If you
90 think this is a meaningful addition to this library, please send a
91 patch. Otherwise, please check for the validity of votes BEFORE you
92 pass them to this election module.
94 Examples of each type of election currently supported can be seen in
95 the test.rb file distributed in this archive.
100 Each ElectionVote object has the following exposed attributions:
102 * ElectionVote#votes -- returns a list of votes that have been tallied
103 * ElectionVote#candidates -- returns a list of candidates
105 Additionally, each subclass will create a #results method which will
106 return an ElectionResult subclass of the appropriate type.
108 Currently, you use this module by creating any of the following types
114 This is the most simple "winner-take-all" system. The array passed to
115 the new vote object should be an array of strings. Each string is
116 counted as one vote for a candidate.
121 vote_array = [ "A", "B", "B", "A" ]
122 resultobject = PluralityVote.new(vote_array).result
127 Approval is similar to plurality voting except that users can vote for
128 more than one candidate at once naming all of the candidates that they
134 vote_array = [ ["A", "B"], ["B", "A"], ["B"] ]
135 resultobject = ApprovalVote.new(vote_array).result
140 Borda is a positional voting system and, as a result, takes a list of
141 ranked candidates and assigns points to each candidates based on their
142 order. In Borda, there are *n* candidate and the first candidates is
143 assigned *n* - 1 points and each subsequent candidate is assigned one
144 less point. The candidate is assigned no points.
146 Currently, all candidates should be ranked in each ballot.
151 vote_array = [ ["A", "B"], ["B", "A"], ["B", "A"] ]
152 resultobject = BordaVote.new(vote_array).result
157 Condorcet is a preferential system and, as such, each vote must list
158 of ranked preferences from most to least preferred. Currently, all
159 candidates must be listed. No ties are allowed on ballots with the
160 current implementation.
165 vote_array = [ ["A", "B"], ["B", "A"], ["B", "A"] ]
166 resultobject = PureCondorcetVote.new(vote_array).result
168 Cloneproof Schwartz Sequential Dropping
169 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
171 `Cloneproof SSD` is a Condorcet variant with the ability to create
172 winners in circular defeats (e.g., A beats B, B beats C, C beats A)
173 where this is no clear winner in Condorcet. It is used identically to
179 vote_array = [ ["A", "B"], ["B", "A"], ["B", "A"] ]
180 resultobject = CloneproofSSDVote.new(vote_array).result
182 ElectionResult Objects
183 ***********************
185 Each election result object will have the following methods:
187 * #winner? -- return Boolean as to the winner or winners of an election
188 * #winners -- an array of winners of the election
189 * #ranked_candidates -- (where available) a list of ranked candidates
195 This program is free software; you can redistribute it and/or modify
196 it under the terms of the GNU General Public License as published by
197 the Free Software Foundation; either version 2 of the License, or (at
198 your option) any later version.
200 This program is distributed in the hope that it will be useful, but
201 WITHOUT ANY WARRANTY; without even the implied warranty of
202 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
203 General Public License for more details.
205 You should have received a copy of the GNU General Public License
206 along with this program; if not, write to the Free Software
207 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
210 Look in the COPYING file for the text of the GNU GPL.
215 Currently, the only contributor to this program is Benjamin Mako Hill
216 working at the MIT Media Lab. Please feel free to contribute to this
217 module and get your name added here.
219 For more information about Mako and his programs, you can see his
224 For more information about the MIT Media Lab, you can see its homepage
227 http://www.media.mit.edu