# to Debian Constitution A.6.
#
# usage: .../compute [<input files>...]
+# (uses stdin if none supplied)
#
-#
+# input files can be in any order and should contain lines like:
+#
+# <votername> :: <PREF>, (<PREF>=<PREF>), <PREF>, ....
+# V: <tallyprefs> <votername>
+# <ABBREV> = <description...>
+# <ABBREV> = <description...> [<rat>:<io>]
+# <ABBREV> = <description...> [default]
+# nodefault
+# quorum = <quorum>
+#
+# where
+#
+# <votername> is any non-whitespace characters
+#
+# <ABBREV> and <PREF> are abbreviations for choices on the ballot.
+# They must be ASCII alphanumeric. Numeric preferences are
+# not recommended as they are confusing (particularly when
+# tally sheets are in use).
+#
+# It is best to avoid FD, SQ and NOTA except for the default
+# option; if no default option is specified, it will default
+# to one of these unless a "nodefault" line is found.
+#
+# In the "::" form, the commas are optional. Either ( ) or = may
+# be used to indicate a set of equal preferences.
+#
+# <tallyprefs> is a tally sheet preference order: that is,
+# a single uppercase base36 digit for each ballot choice,
+# (in the order they were specified by "=" lines), giving
+# the voter's preference rank for that option. The numbers
+# need not be distinct or contiguous. "-" may be used for
+# unranked preferences.
+#
+# <rat>:<io> is the majority ratio for the option
+#
+# <quorum> is the quorum
+#
+# and also allowed are
+#
+# #-comments } all
+# blank lines } ignored
+# lines starting with whitespace }
use strict;
use utf8;
next if m/^\s*\#/;
next unless m/\S/;
next if m/^\s/;
- if (m/^([A-Z]+)\s*\=\s*(\S.*)$/) {
+ if (m/^([A-Z0-9]+)\s*\=\s*(\S.*)$/) {
my ($choname, $desc) = ($1,$2);
my $cho = addchoice($choname, Desc => $desc);
if ($desc =~ m/\[(\d+):(\d+)\]/) {
# Go through the voters and construct V(A,B)
-print "\nParsing \`simple' style ballots\n";
+print "\nParsing \`simple' style ballots\n# devotee-tally-begin\n"
+ if @invotes_cc;
# actually, we pre-parse them into @invotes_v
# since we want to show them as a tally sheet anyway
push @invotes_v, [ $vstr, $voter ];
}
+print "# devotee-tally-end\n"
+ if @invotes_cc;
+
print "\nDetermining default option\n";
if ($defcho && $defcho->{Index} > -1) {
last if $defcho;
}
if ($defcho) {
- print "guessed default option was: $choices[$defcho->{Index}]\n";
+ print "guessed default option: $choices[$defcho->{Index}]\n";
} else {
print "could not guess default option, assuming there is none\n";
}
my $defi = $defcho->{Index};
die "FD has smaj?!" if $defcho->{Smaj};
-print "\nParsing devotee tally sheet ballots\n";
+print "\nParsing devotee tally sheet ballots\n"
+ if @invotes_v > @invotes_cc;
foreach my $iv (@invotes_v) {
my ($votestr,$voter) = @$iv;
my $vad = scalar @{ $vab[$i][$defi] };
my $vda = scalar @{ $vab[$defi][$i] };
next if $vad * $majr->[1] > $vda * $majr->[0];
- drop $i, "majority ratio ($vad * $majr->[1] <= $vda * $majr->[0])";
+ drop $i, "majority ratio ($vad:$vda <= $majr->[1]:$majr->[0])";
}
}
my $tdefeats = $defeats->transitive_closure();
+ # this makes the debugging output prettier
+ foreach my $ch (@choices) {
+ $tdefeats->delete_edge($ch,$ch);
+ }
print "closure graph: $tdefeats\n";
print "\nSchwartz set A.6(6)\n";