A-Lounsbury / pysimultaneous

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

Fix solve_system function #6

Open A-Lounsbury opened 3 months ago

A-Lounsbury commented 3 months ago

Test it on games that have verifiable mixed strategy equilibria.

It currently seems to always return empty sets for some reason, even though I’ve printed the polynomials to verify that they’re correct.

Maybe implement this?

A-Lounsbury commented 2 months ago

We can get it to solve for some variables (how it decides which ones to solve for, I do not know). This is the output for the following game

game1 = [
    [
        [[-3, -3, 2], [0, 5, 4]],
        [[-5, 0, 1], [-1, -1, 1]]
    ],
    [
        [[0, 0, 1], [5, 1, 3]],
        [[1, 5, 0], [6, 6, 2]]
    ]
]
[{b_0: 3/2 - 1/c_0}]
[{c_0: 2}]
[{a_0: 3*(b_0 - 1)/(3*b_0 - 4)}]

I just don't know how to tell sympy to do the whole computation, plugging in $c = 2$ into the first equation, and then $b = 1$ into the third equation to give $a = 0$, or if that's even possible.

A-Lounsbury commented 2 months ago

This issue is misnamed now that we're working on the solve_system function. Renaming.

A-Lounsbury commented 2 months ago

Where is {c_0:2} coming from? These are supposed to be probabilities...

A-Lounsbury commented 2 months ago

These are our polynomials for game2:

1, 2, 1   7, 4, 2 
5, 6, 3   3, 8, 1     

2, 4, 0   6, 8, 1     
10, 12, 3   14, 16, 4 
b_0*c_0 + 2*b_0*(1 - c_0) + c_0*(7 - 7*b_0) + (1 - c_0)*(6 - 6*b_0)
5*b_0*c_0 + 10*b_0*(1 - c_0) + c_0*(3 - 3*b_0) + (1 - c_0)*(14 - 14*b_0)

2*a_0*c_0 + 4*a_0*(1 - c_0) + c_0*(6 - 6*a_0) + (1 - c_0)*(12 - 12*a_0) 
4*a_0*c_0 + 8*a_0*(1 - c_0) + c_0*(8 - 8*a_0) + (1 - c_0)*(16 - 16*a_0) 

a_0*b_0 + 2*a_0*(1 - b_0) + b_0*(3 - 3*a_0) + (1 - a_0)*(1 - b_0)       
a_0*(1 - b_0) + b_0*(3 - 3*a_0) + (1 - b_0)*(4 - 4*a_0)

They appear to be correct.

A-Lounsbury commented 2 months ago

Unsimplified differences:

-4*b_0*c_0 - 8*b_0*(1 - c_0) - c_0*(3 - 3*b_0) + c_0*(7 - 7*b_0) + (1 - c_0)*(6 - 6*b_0) - (1 - c_0)*(14 - 14*b_0)
-2*a_0*c_0 - 4*a_0*(1 - c_0) + c_0*(6 - 6*a_0) - c_0*(8 - 8*a_0) + (1 - c_0)*(12 - 12*a_0) - (1 - c_0)*(16 - 16*a_0)
a_0*b_0 + a_0*(1 - b_0) + (1 - a_0)*(1 - b_0) - (1 - b_0)*(4 - 4*a_0)

Simplified differences:

-8*b_0*c_0 + 12*c_0 - 8
2*c_0 - 4
-3*a_0*b_0 + 4*a_0 + 3*b_0 - 3

I really have no idea.

A-Lounsbury commented 2 months ago

That's game2. Here are the differences for game1:

-3, -3, 2   0, 5, 4 
-5, 0, 1   -1, -1, 1 

0, 0, 1   5, 1, 3    
1, 5, 0   6, 6, 2 

b_0*c_0 + 2*c_0 - 1
-9*a_0*c_0 + 2*c_0 - 1
-2*a_0*b_0 + 2*a_0 + 2*b_0 - 1
A-Lounsbury commented 2 months ago

The coefficients for the first two polynomials for players 1 and 2 in game1 happen to be the same

-3, -3, 2   0, 5, 4 
-5, 0, 1   -1, -1, 1 

0, 0, 1   5, 1, 3    
1, 5, 0   6, 6, 2    
PLAYER 1:
                        COEF: -3
                        COEF: 0 
                        COEF: 0 
                        COEF: 5 

                        COEF: -5
                        COEF: -1
                        COEF: 1 
                        COEF: 6 

PLAYER 2:
                        COEF: -3
                        COEF: 0 
                        COEF: 0 
                        COEF: 5 

                        COEF: 5
                        COEF: -1
                        COEF: 1
                        COEF: 6

POLYNOMIALS:
-3*b_0*c_0 + (1 - c_0)*(5 - 5*b_0)
-5*b_0*c_0 + b_0*(1 - c_0) + c_0*(b_0 - 1) + (1 - c_0)*(6 - 6*b_0)

-3*a_0*c_0 + (1 - c_0)*(5 - 5*a_0)
5*a_0*c_0 + a_0*(1 - c_0) + c_0*(a_0 - 1) + (1 - c_0)*(6 - 6*a_0)

2*a_0*b_0 + 4*a_0*(1 - b_0) + b_0*(1 - a_0) + (1 - a_0)*(1 - b_0)
a_0*b_0 + 3*a_0*(1 - b_0) + (1 - b_0)*(2 - 2*a_0)