Asexual_Discrete_Replicator.py
def main():
    """
    Simulate the continuous replicator dymnamics in asexual model
    from the three different initial conditions
    """
    A=Matrix(a2,b2,theta) #define payoff matrix
    T=500# end the simulation at T
    init=np.array([10,1,1])#initial condition 1
    init=init/sum(init)
    p=np.empty((0,3))
    p=np.append(p, [init], axis=0)
    #Note that this code is for Discrete replicator dynamics
    for t in range(T):
        q=p[t]
        pnext=func(q,t,a2,b2,theta)
        p=np.append(p, [pnext], axis=0)
    triplot(p,"c")
    
    init=np.array([1,10,1])#initial condition 2
    init=init/sum(init)
    p=np.empty((0,3))
    p=np.append(p, [init], axis=0)
    for t in range(T):
        q=p[t]
        pnext=func(q,t,a2,b2,theta)
        p=np.append(p, [pnext], axis=0)
    triplot(p,"m")
    
    init=np.array([1,1,12])#initial condition 3
    init=init/sum(init)
    p=np.empty((0,3))
    p=np.append(p, [init], axis=0)
    for t in range(T):
        q=p[t]
        pnext=func(q,t,a2,b2,theta)
        p=np.append(p, [pnext], axis=0)
    triplot(p,"y")
    """
    Check the inteirior equilibrium G
    """
    GX=p[-1,0]*0.5+p[-1,1]*0+p[-1,2]*1
    GY=p[-1,0]*np.sqrt(3)/2
    plt.plot(GX,GY,'k*',markersize=15)
    plt.text(GX+0.05,GY,'G',fontsize=20)
    print(GX,GY)
    plt.savefig("Dic_rep_asexual.pdf")
    plt.show()
    #check the stability of the interior equilibrium G
    [stability,eig]=Stability(A,p[-1,:])
    print(stability)
    meig=abs(eig)
    #check the maximum absolute value of eigenvalue is smaller than 1
    if max(meig)<1:
        print("true")
    else:
        print(max(meig))

    Simulate the continuous replicator dymnamics in asexual model
    from the three different initial conditions
    
Simulate the continuous replicator dymnamics in asexual model
from the three different initial conditions
Simulate the continuous replicator dymnamics in asexual model from the three different initial conditions
def main():
    A=Matrix(a2,b2,theta) 
    T=500
    init=np.array([10,1,1])
    init=init/sum(init)
    p=np.empty((0,3))
    p=np.append(p, [init], axis=0)
    for t in range(T):
        q=p[t]
        pnext=func(q,t,a2,b2,theta)
        p=np.append(p, [pnext], axis=0)
    triplot(p,"c")
    init=np.array([1,10,1])
    init=init/sum(init)
    p=np.empty((0,3))
    p=np.append(p, [init], axis=0)
    for t in range(T):
        q=p[t]
        pnext=func(q,t,a2,b2,theta)
        p=np.append(p, [pnext], axis=0)
    triplot(p,"m")
    init=np.array([1,1,12])
    init=init/sum(init)
    p=np.empty((0,3))
    p=np.append(p, [init], axis=0)
    for t in range(T):
        q=p[t]
        pnext=func(q,t,a2,b2,theta)
        p=np.append(p, [pnext], axis=0)
    triplot(p,"y")
    GX=p[-1,0]*0.5+p[-1,1]*0+p[-1,2]*1
    GY=p[-1,0]*np.sqrt(3)/2
    plt.plot(GX,GY,'k*',markersize=15)
    plt.text(GX+0.05,GY,'G',fontsize=20)
    print(GX,GY)
    plt.savefig("Dic_rep_asexual.pdf")
    plt.show()
    [stability,eig]=Stability(A,p[-1,:])
    print(stability)
    meig=abs(eig)
    if max(meig)<1:
        print("true")
    else:
        print(max(meig))
def main ( ) : A = Matrix ( a2 , b2 , theta ) T = 500 init = np . array ( [ 10 , 1 , 1 ] ) init = init / sum ( init ) p = np . empty ( ( 0 , 3 ) ) p = np . append ( p , [ init ] , axis = 0 ) for t in range ( T ) : q = p [ t ] pnext = func ( q , t , a2 , b2 , theta ) p = np . append ( p , [ pnext ] , axis = 0 ) triplot ( p , "c" ) init = np . array ( [ 1 , 10 , 1 ] ) init = init / sum ( init ) p = np . empty ( ( 0 , 3 ) ) p = np . append ( p , [ init ] , axis = 0 ) for t in range ( T ) : q = p [ t ] pnext = func ( q , t , a2 , b2 , theta ) p = np . append ( p , [ pnext ] , axis = 0 ) triplot ( p , "m" ) init = np . array ( [ 1 , 1 , 12 ] ) init = init / sum ( init ) p = np . empty ( ( 0 , 3 ) ) p = np . append ( p , [ init ] , axis = 0 ) for t in range ( T ) : q = p [ t ] pnext = func ( q , t , a2 , b2 , theta ) p = np . append ( p , [ pnext ] , axis = 0 ) triplot ( p , "y" ) """
    Check the inteirior equilibrium G
    """ GX = p [ - 1 , 0 ] * 0.5 + p [ - 1 , 1 ] * 0 + p [ - 1 , 2 ] * 1 GY = p [ - 1 , 0 ] * np . sqrt ( 3 ) / 2 plt . plot ( GX , GY , 'k*' , markersize = 15 ) plt . text ( GX + 0.05 , GY , 'G' , fontsize = 20 ) print ( GX , GY ) plt . savefig ( "Dic_rep_asexual.pdf" ) plt . show ( ) [ stability , eig ] = Stability ( A , p [ - 1 , : ] ) print ( stability ) meig = abs ( eig ) if max ( meig ) < 1 : print ( "true" ) else : print ( max ( meig ) )
Simulate the continuous replicator dymnamics in asexual model
from the three different initial conditions
Simulate the continuous replicator dymnamics in asexual model from the three different initial conditions
"""
    Simulate the continuous replicator dymnamics in asexual model
    from the three different initial conditions
    """ #define payoff matrix # end the simulation at T #initial condition 1 #Note that this code is for Discrete replicator dynamics #initial condition 2 #initial condition 3 """
    Check the inteirior equilibrium G
    """ #check the stability of the interior equilibrium G #check the maximum absolute value of eigenvalue is smaller than 1