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)
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
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
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)
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)
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)
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)
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)
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
def __init__(self, b): MeekSTV.__init__(self, b) self.LERoption = "LERa" self.completion = "Schwartz Sequential Dropping" self.createUIoptions(["completionMethod", "LERoption"])
def __init__(self, b): MeekSTV.__init__(self, b) self.LERoption = "LERa" self.completion = "Schwartz Sequential Dropping" self.createUIoptions(["completionMethod","LERoption"])