Ejemplo n.º 1
0
	def solveCliqueGames(self):
		cliqueCount = 0
		for pair in zip(self.cliques, self.cliquePayoffs):
			#should be a list of two sets of strategies
			cliques = pair[0]
			#is an array of payoffs
			payoffs = pair[1]

			sNumStrat = [len(cliques[0]), len(cliques[1])]
			strats = {}
			for i,stratSet in enumerate(cliques):
				strats[self.roleInd[i]] = {
					j: strat \
					for j, strat in enumerate(stratSet) 
				}
			cliqueCount += 1
			p = SolveGame.gameData(self.roles, sNumStrat, strats, payoffs)

			if self.debug:
				pprint.pprint(p.roles)
				pprint.pprint(p.numStrat)
				pprint.pprint(p.strat)
				pprint.pprint(p.payoff)
			# try:
			SolveGame.solveGame(p, "clique"+str(cliqueCount))
Ejemplo n.º 2
0
    def solveCliqueGames(self):
        cliqueCount = 0
        for pair in zip(self.cliques, self.cliquePayoffs):
            #should be a list of two sets of strategies
            cliques = pair[0]
            #is an array of payoffs
            payoffs = pair[1]

            sNumStrat = [len(cliques[0]), len(cliques[1])]
            strats = {}
            for i, stratSet in enumerate(cliques):
                strats[self.roleInd[i]] = {
                 j: strat \
                 for j, strat in enumerate(stratSet)
                }
            cliqueCount += 1
            p = SolveGame.gameData(self.roles, sNumStrat, strats, payoffs)

            if self.debug:
                pprint.pprint(p.roles)
                pprint.pprint(p.numStrat)
                pprint.pprint(p.strat)
                pprint.pprint(p.payoff)
            # try:
            SolveGame.solveGame(p, "clique" + str(cliqueCount))
Ejemplo n.º 3
0
	def solveGames(self):
		strat = {}

		for roles in self.roles:
			t = {}
			for k,v in self.stratInd[roles].iteritems():
				t[v] = k
			strat[roles] = t

		p = SolveGame.gameData(self.roles, self.numStrategies, strat, self.payoffMat)
		if self.debug:
			pprint.pprint(p.roles)
			pprint.pprint(p.numStrat)
			pprint.pprint(p.strat)
			pprint.pprint(p.payoff)

		SolveGame.solveGame(p, "Something")
Ejemplo n.º 4
0
    def solveGames(self):
        strat = {}

        for roles in self.roles:
            t = {}
            for k, v in self.stratInd[roles].iteritems():
                t[v] = k
            strat[roles] = t

        p = SolveGame.gameData(self.roles, self.numStrategies, strat,
                               self.payoffMat)
        if self.debug:
            pprint.pprint(p.roles)
            pprint.pprint(p.numStrat)
            pprint.pprint(p.strat)
            pprint.pprint(p.payoff)

        SolveGame.solveGame(p, "Something")
Ejemplo n.º 5
0
	def solveSubGames(self, num):
		t = [[(None, None) for i in range(self.numStrategies[1])] for j in range(int(num))]
		counter = 0
		hodor = snippets.getFileNames("subGames")
		for triples in itertools.combinations(self.strategies[self.roles[0]], num):
			print "Attacker strategies:- ",
			print triples
			name = '_'.join(list(triples))
			if name in hodor:
				# print "Skipping "+name
				continue
			p = []
			m = {}
			n = {}
			for i, atStr in enumerate(triples):
				m[i] = atStr
				for j, dStr in enumerate(self.strategies[self.roles[1]]):
					# p.append(self.payoffMat[self.stratInd[self.roles[0]][atStr]]\
					# 	[self.stratInd[self.roles[1]][dStr]])
					t[i][j] = self.payoffMat[self.stratInd[self.roles[0]][atStr]]\
					[self.stratInd[self.roles[1]][dStr]]
					if j not in n:
						n[j] = dStr
				# t.append(p)
			if self.debug:
				print p
			numStrats = [num, self.numStrategies[1]]
			
			strats = {
				self.roles[0]:m,
				self.roles[1]:n
			}

			p = SolveGame.gameData(self.roles, numStrats, strats, t)
			# if self.debug:
			print "Subgame-" + str(counter)			
			if self.debug:
				pprint.pprint(p.roles)
				pprint.pprint(p.numStrat)
				pprint.pprint(p.strat)
				pprint.pprint(p.payoff)
			SolveGame.solveGame(p, "subGame-" + name)
			print "Finished subGame " + str(counter)
			counter+=1
Ejemplo n.º 6
0
    def solveSubGames(self, num):
        t = [[(None, None) for i in range(self.numStrategies[1])]
             for j in range(int(num))]
        counter = 0
        hodor = snippets.getFileNames("subGames")
        for triples in itertools.combinations(self.strategies[self.roles[0]],
                                              num):
            # print "Attacker strategies:- ",
            # print triples
            name = '_'.join(list(triples))
            if name in hodor:
                # print "Skipping "+name
                continue
            p = []
            m = {}
            n = {}
            for i, atStr in enumerate(triples):
                m[i] = atStr
                for j, dStr in enumerate(self.strategies[self.roles[1]]):
                    # p.append(self.payoffMat[self.stratInd[self.roles[0]][atStr]]\
                    # 	[self.stratInd[self.roles[1]][dStr]])
                    t[i][j] = self.payoffMat[self.stratInd[self.roles[0]][atStr]]\
                    [self.stratInd[self.roles[1]][dStr]]
                    if j not in n:
                        n[j] = dStr
                # t.append(p)
            if self.debug:
                print p
            numStrats = [num, self.numStrategies[1]]

            strats = {self.roles[0]: m, self.roles[1]: n}

            p = SolveGame.gameData(self.roles, numStrats, strats, t)
            # if self.debug:
            print "Subgame-" + str(counter)
            if self.debug:
                pprint.pprint(p.roles)
                pprint.pprint(p.numStrat)
                pprint.pprint(p.strat)
                pprint.pprint(p.payoff)
            SolveGame.solveGame(p, "subGame-" + name)
            print "Finished subGame " + str(counter)
            counter += 1