def solveVoteSPSR(vote, solverSettings): ''' @type vote: vote.society.Vote @type solverSettings: vote.solver.SolverSettings @rtype vote.society.Lottery ''' state = SRState(vote, solverSettings) for choiceClass in map(lambda choices: ChoiceClass(choices), getAllSubsets(vote.getChoices())): height = 0.0 agents = [] for agent, agentChoiceClass in state.getCurrentAgentChoiceClasses().items(): if agentChoiceClass.isSubsetOf(choiceClass): height += 1 if agentChoiceClass == choiceClass: agents.append(agent) height /= vote.getAgentCount() state.setClassHeight(choiceClass, height) for agent in agents: state.setAgentHeight(agent, height) while not state.isFinished(): (climbTime, bouncingAgents) = computeLambda(state) state.advance(climbTime, bouncingAgents) return findLottery(vote, state.getCurrentClassHeights(), state.getSettings())
def solveVoteSPSR(vote, solverSettings): ''' @type vote: vote.society.Vote @type solverSettings: vote.solver.SolverSettings @rtype vote.society.Lottery ''' state = SRState(vote, solverSettings) for choiceClass in map(lambda choices: ChoiceClass(choices), getAllSubsets(vote.getChoices())): height = 0.0 agents = [] for agent, agentChoiceClass in state.getCurrentAgentChoiceClasses( ).items(): if agentChoiceClass.isSubsetOf(choiceClass): height += 1 if agentChoiceClass == choiceClass: agents.append(agent) height /= vote.getAgentCount() state.setClassHeight(choiceClass, height) for agent in agents: state.setAgentHeight(agent, height) while not state.isFinished(): (climbTime, bouncingAgents) = computeLambda(state) state.advance(climbTime, bouncingAgents) return findLottery(vote, state.getCurrentClassHeights(), state.getSettings())
def adjustTowerSpeeds(self): for tower in self.getTowers(): tower.setSpeed(0) for agentData in self._getActiveAgentData(): currentChoiceClass = agentData.getCurrentChoiceClass() self.getTower(currentChoiceClass).addSpeed(1) for subset in getAllSubsets(self.vote.getChoices(), len(currentChoiceClass) + 1): if currentChoiceClass.isSubsetOf(subset): tower = self.getTower(subset) if not tower.isFrozen(): tower.addSpeed(1)