Esempio n. 1
0
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())
Esempio n. 2
0
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())
Esempio n. 3
0
def solveVotePSR(vote, solverSettings):
    '''
    @type vote: vote.society.Vote
    @type solverSettings: vote.solver.SolverSettings
    @rtype vote.society.Lottery
    '''

    state = SRState(vote, solverSettings)

    agentChoiceClasses = state.getCurrentAgentChoiceClasses()
    for agent, choiceClass in agentChoiceClasses.items():
        speed = 0
        for otherChoiceClass in agentChoiceClasses.values():
            if otherChoiceClass.isSubsetOf(choiceClass):
                speed += 1
        state.setAgentSpeed(agent, speed)
    # As shown, no freeze happens between 0 and 1/n, thus one can simply
    # advance 1/n
    state.advance(1.0 / vote.getAgentCount(), [])
    for agent in state.getAgents():
        state.setAgentSpeed(agent, 1)
    while not state.isFinished():
        (climbTime, bouncingAgents) = computeLambda(state)
        state.advance(climbTime, bouncingAgents)
    return findLottery(vote, state.getCurrentClassHeights(),
                       state.getSettings())
Esempio n. 4
0
def solveVotePSR(vote, solverSettings):
    '''
    @type vote: vote.society.Vote
    @type solverSettings: vote.solver.SolverSettings
    @rtype vote.society.Lottery
    '''

    state = SRState(vote, solverSettings)

    agentChoiceClasses = state.getCurrentAgentChoiceClasses()
    for agent, choiceClass in agentChoiceClasses.items():
        speed = 0
        for otherChoiceClass in agentChoiceClasses.values():
            if otherChoiceClass.isSubsetOf(choiceClass):
                speed += 1
        state.setAgentSpeed(agent, speed)
    # As shown, no freeze happens between 0 and 1/n, thus one can simply
    # advance 1/n
    state.advance(1.0 / vote.getAgentCount(), [])
    for agent in state.getAgents():
        state.setAgentSpeed(agent, 1)
    while not state.isFinished():
        (climbTime, bouncingAgents) = computeLambda(state)
        state.advance(climbTime, bouncingAgents)
    return findLottery(vote, state.getCurrentClassHeights(), state.getSettings())
def solveVoteESR(vote, solverSettings):
    '''
    @type vote: vote.society.Vote
    @type solverSettings: vote.solver.SolverSettings
    @rtype vote.society.Lottery
    '''

    state = SRState(vote, solverSettings)

    while not state.isFinished():
        (climbTime, bouncingAgents) = computeLambda(state)
        state.advance(climbTime, bouncingAgents)
    return findLottery(vote, state.getCurrentClassHeights(), state.getSettings())
Esempio n. 6
0
def solveVoteESR(vote, solverSettings):
    '''
    @type vote: vote.society.Vote
    @type solverSettings: vote.solver.SolverSettings
    @rtype vote.society.Lottery
    '''

    state = SRState(vote, solverSettings)

    while not state.isFinished():
        (climbTime, bouncingAgents) = computeLambda(state)
        state.advance(climbTime, bouncingAgents)
	#TODO 'set( ..., ...)' loswerden
	print "Non-Zero Classes: " + str(state.strNonZero()) + "\n"
    return findLottery(vote, state.getCurrentClassHeights(), state.getSettings()).getSupport()
Esempio n. 7
0
def solveVoteSSR(vote, solverSettings):
    '''
    @type vote: vote.society.Vote
    @type solverSettings: vote.solver.SolverSettings
    @rtype vote.society.Lottery
    '''

    state = SSRState(vote, solverSettings)
    state.adjustTowerSpeeds()
    while not state.isFinished():
        (climbingTime, freezingTowers) = computeLambda(state)
        state.advance(climbingTime, freezingTowers)
    currentClassHeights = {tower.getChoiceClass(): tower.getHeight()
                           for tower in state.getTowers()}
    return findLottery(vote, currentClassHeights, state.getSettings())
Esempio n. 8
0
def solveVoteESR(vote, solverSettings):
    '''
    @type vote: vote.society.Vote
    @type solverSettings: vote.solver.SolverSettings
    @rtype vote.society.Lottery
    '''

    state = SRState(vote, solverSettings)

    while not state.isFinished():
        (climbTime, bouncingAgents) = computeLambda(state)
        state.advance(climbTime, bouncingAgents)
        #TODO 'set( ..., ...)' loswerden
        print "Non-Zero Classes: " + str(state.strNonZero()) + "\n"
    return findLottery(vote, state.getCurrentClassHeights(),
                       state.getSettings()).getSupport()
def solveVoteSSR(vote, solverSettings):
    '''
    @type vote: vote.society.Vote
    @type solverSettings: vote.solver.SolverSettings
    @rtype vote.society.Lottery
    '''

    state = SSRState(vote, solverSettings)
    state.adjustTowerSpeeds()
    while not state.isFinished():
        (climbingTime, freezingTowers) = computeLambda(state)
        state.advance(climbingTime, freezingTowers)
    currentClassHeights = {
        tower.getChoiceClass(): tower.getHeight()
        for tower in state.getTowers()
    }
    return findLottery(vote, currentClassHeights, state.getSettings())