示例#1
0
 def initializeTreeAndKeepValues(self):
     # This is just to get a message into the first round.
     if self.LERbWinner != None:
         self.msg[self.R] += "LERb winner is " + self.b.names[self.LERbWinner] + ". "
     if self.LERaWinner != None:
         self.msg[self.R] += "LERa winner is " + self.b.names[self.LERaWinner] + ". "
     MeekSTV.initializeTreeAndKeepValues(self)
示例#2
0
 def preCount(self):
     self.LERa = self.LERoption == "LERa" or self.LERoption == "LERab"
     self.LERb = self.LERoption == "LERb" or self.LERoption == "LERab"
     self.optionsMsg = "LER option: %s. \n" % self.LERoption
     self.optionsMsg += "Using %s for the completion method." % self.completion
     condorcetElection = Condorcet(self.dirtyBallots)
     condorcetElection.completion = self.completion
     condorcetElection.withdrawn = self.withdrawn[:]
     condorcetElection.runElection()
     self.LERaWinner = None
     self.LERbWinner = None
     if self.LERb:
         self.LERbWinner = condorcetElection.b.names[condorcetElection.winner]
         if self.LERa and self.dirtyBallots.numSeats > 1:
             condorcetElection2 = Condorcet(self.dirtyBallots)
             condorcetElection2.completion = self.completion
             condorcetElection2.withdrawn = self.withdrawn[:]
             condorcetElection2.withdrawn.append(self.dirtyBallots.names.index(self.LERbWinner))
             condorcetElection2.runElection()
             self.LERaWinner = condorcetElection2.b.names[condorcetElection2.winner]
     else:
         self.LERaWinner = condorcetElection.b.names[condorcetElection.winner]
     MeekSTV.preCount(self)
     # adapt names to indices, now that withdrawals are finalized
     if self.LERaWinner != None:
         self.LERaWinner = self.b.names.index(self.LERaWinner)
     if self.LERbWinner != None:
         print "evil %s in %s" % (self.LERbWinner , self.b.names)
         self.LERbWinner = self.b.names.index(self.LERbWinner)
         # temporarily mark LERbWinner as a loser.
         self.purgatory.remove(self.LERbWinner)
         self.losers.append(self.LERbWinner)
         self.lostAtRound[self.LERbWinner] = 0
         self.numSeats -= 1
示例#3
0
 def runElection(self):
     MeekSTV.runElection(self)
     if self.LERbWinner != None:
         self.numSeats += 1
         self.losers.remove(self.LERbWinner)
         self.winners.append(self.LERbWinner)
         self.lostAtRound[self.LERbWinner] = None
         self.wonAtRound[self.LERbWinner] = 0
示例#4
0
 def runElection(self):
     MeekSTV.runElection(self)
     if self.LERbWinner != None:
         self.numSeats += 1
         self.losers.remove(self.LERbWinner)
         self.winners.append(self.LERbWinner)
         self.lostAtRound[self.LERbWinner] = None
         self.wonAtRound[self.LERbWinner] = 0
示例#5
0
 def initializeTreeAndKeepValues(self):
     # This is just to get a message into the first round.
     if self.LERbWinner != None:
         self.msg[self.R] += "LERb winner is " + self.b.names[
             self.LERbWinner] + ". "
     if self.LERaWinner != None:
         self.msg[self.R] += "LERa winner is " + self.b.names[
             self.LERaWinner] + ". "
     MeekSTV.initializeTreeAndKeepValues(self)
示例#6
0
 def getLosers(self, ppp=None):
     if ppp == None: ppp = self.purgatory
     ppp = ppp[:]
     try:
         ppp.remove(self.LERaWinner)
     except ValueError:
         pass
     return MeekSTV.getLosers(self, ppp)
示例#7
0
 def breakWeakTie(self, R, cList, mostfewest, what=""):
     newCList = cList[:]
     if what == "candidates to eliminate":
         try:
             newCList.remove(self.LERaWinner)
         except ValueError:
             pass
     return MeekSTV.breakWeakTie(self, R, newCList, mostfewest, what)
示例#8
0
 def breakWeakTie(self, R, cList, mostfewest, what=""):
     newCList = cList[:]
     if what == "candidates to eliminate":
         try:
             newCList.remove(self.LERaWinner)
         except ValueError:
             pass
     return MeekSTV.breakWeakTie(self,R,newCList,mostfewest,what)
示例#9
0
 def getLosers(self, ppp = None):
     if ppp == None: ppp = self.purgatory
     ppp = ppp[:]
     try:
         ppp.remove(self.LERaWinner)
     except ValueError:
         pass
     return MeekSTV.getLosers(self,ppp)
示例#10
0
 def preCount(self):
     self.LERa = self.LERoption == "LERa" or self.LERoption == "LERab"
     self.LERb = self.LERoption == "LERb" or self.LERoption == "LERab"
     self.optionsMsg = "LER option: %s. \n" % self.LERoption
     self.optionsMsg += "Using %s for the completion method." % self.completion
     condorcetElection = Condorcet(self.dirtyBallots)
     condorcetElection.completion = self.completion
     condorcetElection.withdrawn = self.withdrawn[:]
     condorcetElection.runElection()
     self.LERaWinner = None
     self.LERbWinner = None
     if self.LERb:
         self.LERbWinner = condorcetElection.b.names[
             condorcetElection.winner]
         if self.LERa and self.dirtyBallots.numSeats > 1:
             condorcetElection2 = Condorcet(self.dirtyBallots)
             condorcetElection2.completion = self.completion
             condorcetElection2.withdrawn = self.withdrawn[:]
             condorcetElection2.withdrawn.append(
                 self.dirtyBallots.names.index(self.LERbWinner))
             condorcetElection2.runElection()
             self.LERaWinner = condorcetElection2.b.names[
                 condorcetElection2.winner]
     else:
         self.LERaWinner = condorcetElection.b.names[
             condorcetElection.winner]
     MeekSTV.preCount(self)
     # adapt names to indices, now that withdrawals are finalized
     if self.LERaWinner != None:
         self.LERaWinner = self.b.names.index(self.LERaWinner)
     if self.LERbWinner != None:
         print "evil %s in %s" % (self.LERbWinner, self.b.names)
         self.LERbWinner = self.b.names.index(self.LERbWinner)
         # temporarily mark LERbWinner as a loser.
         self.purgatory.remove(self.LERbWinner)
         self.losers.append(self.LERbWinner)
         self.lostAtRound[self.LERbWinner] = 0
         self.numSeats -= 1
示例#11
0
 def __init__(self, b):
     MeekSTV.__init__(self, b)
     self.LERoption = "LERa"
     self.completion = "Schwartz Sequential Dropping"
     self.createUIoptions(["completionMethod", "LERoption"])
示例#12
0
 def __init__(self, b):
     MeekSTV.__init__(self, b)
     self.LERoption = "LERa"
     self.completion = "Schwartz Sequential Dropping"
     self.createUIoptions(["completionMethod","LERoption"])