rubyvote
9 years agoa number of improvements master
Benjamin Mako Hill [Sun, 24 Oct 2010 22:34:15 +0000 (22:34 +0000)]
a number of improvements
- switched IRV's add_vote to tally_vote to make it consistent
- added description and documentation to each method/time
- fixed typo in README
- added a new IRV test (which i'm not sure is wrong) but which was
  causing big problems on selectricity

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@49 1440c7f4-e209-0410-9a04-881b5eb134a8

13 years agoSlimmed down and perfected victories_and_ties function in condorcet.rb to match the...
Justin Sharps [Tue, 21 Aug 2007 18:02:07 +0000 (18:02 +0000)]
Slimmed down and perfected victories_and_ties function in condorcet.rb to match the one in Selectricity.

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@48 1440c7f4-e209-0410-9a04-881b5eb134a8

13 years agoRemoved debug code.
Benjamin Mako Hill [Sat, 18 Aug 2007 00:07:49 +0000 (00:07 +0000)]
Removed debug code.

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@47 1440c7f4-e209-0410-9a04-881b5eb134a8

13 years ago>>>>>>>>>>>>>> This breaks the API. <<<<<<<<<<<<<<<<<<<<<<<<<<
Benjamin Mako Hill [Sat, 18 Aug 2007 00:00:04 +0000 (00:00 +0000)]
>>>>>>>>>>>>>> This breaks the API. <<<<<<<<<<<<<<<<<<<<<<<<<<

Refactored the commits added by Joe Slag to return the full lists of
candidates.

In Joe's code, the full list of candidates were associated with the vote
objects which didn't make sense since they are really part of results.
I've gone ahead and reimplented this. It does mean that the API has
changed. In the old version, you would get a ranked list of candidates
by using:

  vote_object.results

You now get it by doing:

  result_object.ranked_candidates
  vote_object.result.ranked_candidates

>>>>>>>>>>>>>> This breaks the API. <<<<<<<<<<<<<<<<<<<<<<<<<<

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@46 1440c7f4-e209-0410-9a04-881b5eb134a8

13 years agoCleaned up after Justin's last commit.
Benjamin Mako Hill [Fri, 17 Aug 2007 21:46:39 +0000 (21:46 +0000)]
Cleaned up after Justin's last commit.

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@45 1440c7f4-e209-0410-9a04-881b5eb134a8

13 years agoCreated victories_and_ties method for table use.
Justin Sharps [Fri, 17 Aug 2007 21:42:48 +0000 (21:42 +0000)]
Created victories_and_ties method for table use.

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@44 1440c7f4-e209-0410-9a04-881b5eb134a8

13 years agochanged name of defeats_list to victories_and_ties
Benjamin Mako Hill [Fri, 17 Aug 2007 00:11:09 +0000 (00:11 +0000)]
changed name of defeats_list to victories_and_ties

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@43 1440c7f4-e209-0410-9a04-881b5eb134a8

13 years agoHelped fix the bug in def defeats that was causing cpssd() to return
Benjamin Mako Hill [Thu, 16 Aug 2007 23:54:08 +0000 (23:54 +0000)]
Helped fix the bug in def defeats that was causing cpssd() to return
[nil] as a winner list for empty elections.

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@42 1440c7f4-e209-0410-9a04-881b5eb134a8

13 years agoformatting fixes
Benjamin Mako Hill [Thu, 16 Aug 2007 22:34:17 +0000 (22:34 +0000)]
formatting fixes

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@41 1440c7f4-e209-0410-9a04-881b5eb134a8

13 years agoCreated the list_defeats method in the CondorcetResult Class, so it hsould apply...
Justin Sharps [Thu, 16 Aug 2007 19:55:53 +0000 (19:55 +0000)]
Created the list_defeats method in the CondorcetResult Class, so it hsould apply both to PureCondorcet and SSD votes. It helps in outputting a list of who beat whom, and by how much. It also stores ties.

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@40 1440c7f4-e209-0410-9a04-881b5eb134a8

13 years agoRemove whitespace from election.rb that was generating a warning
John Dong [Thu, 16 Aug 2007 16:15:57 +0000 (16:15 +0000)]
Remove whitespace from election.rb that was generating a warning

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@39 1440c7f4-e209-0410-9a04-881b5eb134a8

13 years agoAdded matrix to condorcet to draw a table of winners vs losers. Also added "points...
Justin Sharps [Wed, 15 Aug 2007 22:12:45 +0000 (22:12 +0000)]
Added matrix to condorcet to draw a table of winners vs losers. Also added "points" attr_readers and instance variables to BordaResults and PluralityResults so that they will be availabel directly from the result objects.

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@38 1440c7f4-e209-0410-9a04-881b5eb134a8

13 years agoWork around CloneProofSSD returning [nil] rather than [] for empty vote
John Dong [Wed, 15 Aug 2007 20:27:12 +0000 (20:27 +0000)]
Work around CloneProofSSD returning [nil] rather than [] for empty vote

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@37 1440c7f4-e209-0410-9a04-881b5eb134a8

13 years agoFix problem with a [nil] result being taken as having a winner; add testcases
John Dong [Wed, 15 Aug 2007 20:17:05 +0000 (20:17 +0000)]
Fix problem with a [nil] result being taken as having a winner; add testcases

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@36 1440c7f4-e209-0410-9a04-881b5eb134a8

13 years agoAdd similar hackish "fix" for IRVL deadlocking on empty vote
John Dong [Wed, 15 Aug 2007 19:53:05 +0000 (19:53 +0000)]
Add similar hackish "fix" for IRVL deadlocking on empty vote

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@35 1440c7f4-e209-0410-9a04-881b5eb134a8

13 years agoAdd testcases for calling results to empty votes.
John Dong [Wed, 15 Aug 2007 19:50:14 +0000 (19:50 +0000)]
Add testcases for calling results to empty votes.

TODO: IRV Logic has same bug

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@34 1440c7f4-e209-0410-9a04-881b5eb134a8

13 years agoAdd somewhat hackish fix for PureCondorcetVote.new([]).result deadlocking
John Dong [Wed, 15 Aug 2007 19:38:02 +0000 (19:38 +0000)]
Add somewhat hackish fix for PureCondorcetVote.new([]).result deadlocking

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@33 1440c7f4-e209-0410-9a04-881b5eb134a8

13 years agoFixed positional test-case to test for correct winner, not most recent winner.
Justin Sharps [Tue, 14 Aug 2007 23:53:38 +0000 (23:53 +0000)]
Fixed positional test-case to test for correct winner, not most recent winner.

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@32 1440c7f4-e209-0410-9a04-881b5eb134a8

13 years ago * Entire election aborts with InvalidVoteError when an invalid vote object is passed in.
John Dong [Tue, 14 Aug 2007 23:49:20 +0000 (23:49 +0000)]
 * Entire election aborts with InvalidVoteError when an invalid vote object is passed in.
 * Add testcase for checking InvalidVoteError is properly raised

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@31 1440c7f4-e209-0410-9a04-881b5eb134a8

13 years agoAdd testcase for non-string plurality vote candidates
John Dong [Tue, 14 Aug 2007 23:31:48 +0000 (23:31 +0000)]
Add testcase for non-string plurality vote candidates

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@30 1440c7f4-e209-0410-9a04-881b5eb134a8

13 years agoAllow PluralityVote to accept non-string arguments. (I couldn't find any reason why...
John Dong [Tue, 14 Aug 2007 23:29:48 +0000 (23:29 +0000)]
Allow PluralityVote to accept non-string arguments. (I couldn't find any reason why that wasn't the case to begin with)

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@29 1440c7f4-e209-0410-9a04-881b5eb134a8

13 years agoFixed bug in Borda that was counting the votes incorrect very
Benjamin Mako Hill [Tue, 14 Aug 2007 18:40:58 +0000 (18:40 +0000)]
Fixed bug in Borda that was counting the votes incorrect very
frequently.  Thanks Justin Sharps!

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@28 1440c7f4-e209-0410-9a04-881b5eb134a8

13 years agoCondorcet votes can now properly handle votes expressing equivalency
Joe Slag [Fri, 4 May 2007 20:44:48 +0000 (20:44 +0000)]
Condorcet votes can now properly handle votes expressing equivalency
between candidates. Viz. [1, [2, 3], 4] indicates that options 2 and 3
are equally preferred, both coming after 1 and before 4.

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@27 1440c7f4-e209-0410-9a04-881b5eb134a8

13 years agonew file
Joe Slag [Wed, 25 Apr 2007 01:15:06 +0000 (01:15 +0000)]
new file

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@26 1440c7f4-e209-0410-9a04-881b5eb134a8

13 years agoo Fix PureCondorcetVote to return all results, not just the winner
Joe Slag [Sun, 22 Apr 2007 15:45:48 +0000 (15:45 +0000)]
o Fix PureCondorcetVote to return all results, not just the winner
o Allow PureCondorcetVote to return ties, rather than loop infinitely

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@25 1440c7f4-e209-0410-9a04-881b5eb134a8

13 years agobig speed up
Joe Slag [Mon, 9 Apr 2007 22:14:59 +0000 (22:14 +0000)]
big speed up

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@24 1440c7f4-e209-0410-9a04-881b5eb134a8

13 years agominor optimization
Joe Slag [Mon, 9 Apr 2007 18:36:35 +0000 (18:36 +0000)]
minor optimization

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@23 1440c7f4-e209-0410-9a04-881b5eb134a8

13 years agosimplify access to full results - now available as voteobject.results,
Joe Slag [Mon, 9 Apr 2007 18:33:54 +0000 (18:33 +0000)]
simplify access to full results - now available as voteobject.results,
instead of voteobject.result.get_full_results.

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@22 1440c7f4-e209-0410-9a04-881b5eb134a8

13 years ago#filter_out and PureCondorcet weren't getting along well for sparse elections
Joe Slag [Tue, 20 Mar 2007 17:14:51 +0000 (17:14 +0000)]
#filter_out and PureCondorcet weren't getting along well for sparse elections

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@21 1440c7f4-e209-0410-9a04-881b5eb134a8

13 years agoo Test that elections with a single vote return the expected result.
Joe Slag [Tue, 20 Mar 2007 15:39:48 +0000 (15:39 +0000)]
o Test that elections with a single vote return the expected result.
o Caught a bug for elections whose votes aren't strings of length 1.

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@20 1440c7f4-e209-0410-9a04-881b5eb134a8

13 years agoMissed a now unnecessary assignment to @candidates in #tally_votes
Joe Slag [Mon, 19 Mar 2007 17:52:37 +0000 (17:52 +0000)]
Missed a now unnecessary assignment to @candidates in #tally_votes

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@19 1440c7f4-e209-0410-9a04-881b5eb134a8

13 years agoCondorcet methods determine all candidates before tallying, in case of
Joe Slag [Mon, 19 Mar 2007 17:38:50 +0000 (17:38 +0000)]
Condorcet methods determine all candidates before tallying, in case of
incomplete votes

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@18 1440c7f4-e209-0410-9a04-881b5eb134a8

13 years agoIf a vote doesn't contain all possible candidates, assign all
Joe Slag [Mon, 19 Mar 2007 17:09:56 +0000 (17:09 +0000)]
If a vote doesn't contain all possible candidates, assign all
unspecified candidates the same position below ranked candidates

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@17 1440c7f4-e209-0410-9a04-881b5eb134a8

13 years agoAdded get_full_results method that returns a ranked list of candidates.
Joe Slag [Tue, 13 Mar 2007 16:11:03 +0000 (16:11 +0000)]
Added get_full_results method that returns a ranked list of candidates.
At this time, only Condorcet votes collect the appropriate information.

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@16 1440c7f4-e209-0410-9a04-881b5eb134a8

13 years agoo Verify that all tests in test.rb are present in test/*_test.rb files,
Joe Slag [Tue, 13 Mar 2007 13:35:38 +0000 (13:35 +0000)]
o Verify that all tests in test.rb are present in test/*_test.rb files,
  remove test.rb

o Convert tests to run silent when successful, remove
  test/election_test_helper.rb

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@15 1440c7f4-e209-0410-9a04-881b5eb134a8

13 years agoMerged in changes that added unit test support by Joe Slag. Thanks!
Benjamin Mako Hill [Mon, 12 Mar 2007 20:17:25 +0000 (20:17 +0000)]
Merged in changes that added unit test support by Joe Slag. Thanks!

We now have two unit test setups in here. We should deal with this one
way or another. I'd like to keep around *a* test.rb file but the
rakefile is a good method as well.

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@14 1440c7f4-e209-0410-9a04-881b5eb134a8

14 years agoRemoved space to avoid warning
Alexis Darrasse [Wed, 5 Apr 2006 20:40:42 +0000 (20:40 +0000)]
Removed space to avoid warning

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@13 1440c7f4-e209-0410-9a04-881b5eb134a8

14 years agoAdded tie-breaking rules and multicandidate elimination of weak candidates
Alexis Darrasse [Sat, 11 Mar 2006 21:30:36 +0000 (21:30 +0000)]
Added tie-breaking rules and multicandidate elimination of weak candidates
before the first round in IRV.
Renamed runoff to irv.

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@12 1440c7f4-e209-0410-9a04-881b5eb134a8

14 years agoAdded list of changes submitted by Jeff Rose <jeff@rosejn.net>.
Benjamin Mako Hill [Fri, 10 Mar 2006 17:04:19 +0000 (17:04 +0000)]
Added list of changes submitted by Jeff Rose <jeff@rosejn.net>.

This includes:

 * Rake based testing and gemmification.
 * Range based voting (untested).
 * A new TODO file.
 * Moving files around to have them RV work better as a library.

Thanks Jeff!

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@11 1440c7f4-e209-0410-9a04-881b5eb134a8

14 years agoUpdated the changelog and the README version for a new version.
Benjamin Mako Hill [Fri, 3 Mar 2006 02:46:59 +0000 (02:46 +0000)]
Updated the changelog and the README version for a new version.

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@7 1440c7f4-e209-0410-9a04-881b5eb134a8

14 years agoAdded support for instant run-off voting with a patch from
Benjamin Mako Hill [Fri, 3 Mar 2006 01:44:54 +0000 (01:44 +0000)]
Added support for instant run-off voting with a patch from
Alexis Darrasse <alexis@ortsa.com>.

Thanks Alexis!

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@6 1440c7f4-e209-0410-9a04-881b5eb134a8

14 years agoRenamed readme file so that it reflects the type (reStructured Text).
Benjamin Mako Hill [Sun, 29 Jan 2006 17:41:41 +0000 (17:41 +0000)]
Renamed readme file so that it reflects the type (reStructured Text).

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@5 1440c7f4-e209-0410-9a04-881b5eb134a8

14 years agoFixed broken link.
Benjamin Mako Hill [Sun, 29 Jan 2006 17:41:07 +0000 (17:41 +0000)]
Fixed broken link.

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@4 1440c7f4-e209-0410-9a04-881b5eb134a8

14 years agoAdded a changelog.
Benjamin Mako Hill [Fri, 27 Jan 2006 19:09:49 +0000 (19:09 +0000)]
Added a changelog.

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@3 1440c7f4-e209-0410-9a04-881b5eb134a8

14 years agoUpdated README file so that it can work as a homepage.
Benjamin Mako Hill [Fri, 27 Jan 2006 19:04:45 +0000 (19:04 +0000)]
Updated README file so that it can work as a homepage.

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@2 1440c7f4-e209-0410-9a04-881b5eb134a8

14 years agoInitial import into SVN of rubyvote library
Benjamin Mako Hill [Fri, 27 Jan 2006 18:21:52 +0000 (18:21 +0000)]
Initial import into SVN of rubyvote library

git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@1 1440c7f4-e209-0410-9a04-881b5eb134a8

Benjamin Mako Hill || Want to submit a patch?