A-Lounsbury / pysimultaneous

A class for handling simultaneous games with any number of players
0 stars 0 forks source link

Compute expected utilities for the k-rationalizability model #18

Closed A-Lounsbury closed 3 months ago

A-Lounsbury commented 3 months ago

Written in computeKMatrix function. Needs to be tested, but first need some way of printing them out. Maybe we need EU as a SimGame attribute?

A-Lounsbury commented 3 months ago

Received

EU[x] += curList.getListNode(x).payoff * self.outcomeProbabilities[num]
IndexError: list index out of range

Need to compute outcomeProbabilities somewhere; although, it appears we did that in probabilizeKChoices.

A-Lounsbury commented 3 months ago

Still resulting in [0.0, 0.0].

A-Lounsbury commented 3 months ago

This test

krmodel = [
    [
        [[2, 12], [5, 6], [9, 0]],
        [[0, 24], [19, 5], [10, 10]],
        [[1, 3], [7, 5], [5, 25]],
    ]
]

G = SimGame(2)
G.enterData(2, [3, 3], krmodel)
G.print()
print()
G.printKMatrix(probabilities=[0.1, 0.4, 0.4, 0.1])

results in

P(1, 2) = 0.10000000000000002
P(1, 0) = 0.9000000000000002
P(0, 2) = 0.10000000000000003
P(0, 0) = 0.9000000000000004
EU_0 = 1.8500000000000005
EU_1 = 16.700000000000003
(1, 2) (1, 0) (1, 0) (1, 0)
(1, 2) (1, 0) (1, 0) (1, 0)
(0, 2) (0, 0) (0, 0) (0, 0)
(0, 2) (0, 0) (0, 0) (0, 0)

which has the correct expected utilities.