Sexual_Continuous_Replicator.py
def main():
    """
    Simulate the continuous replicator dymnamics in sexual model
    from the three different initial conditions
    """
    T=1000#end the simulation at T
    
    init=np.array([10,1,1,10,1,1])#iniital condition 1
    init=init/sum(init)
    t=np.linspace(0,T,100*T+1)
    sol=odeint(func, init, t, args=(a2,b2,theta))
    triplot(sol,"c")
    
    init=np.array([1,10,1,1,10,1])#initial condition 2
    init=init/sum(init)
    t=np.linspace(0,T,100*T+1)
    sol=odeint(func, init, t, args=(a2,b2,theta))
    triplot(sol,"m")

    init=np.array([1,1,10,1,1,10]) # initial condition 3
    #init=np.array([1,1,10.1,1,1,10]) # initial condition 4
    #initial condition 4: sex ratio is NOT 1:1
    init=init/sum(init)
    t=np.linspace(0,T,500*T+1)
    sol=odeint(func, init, t, args=(a2,b2,theta)) 
    triplot(sol,"y")
    
    """
    #plot the interior point G if the inital sex ratio is 1:1
    GX=(sol[-1,0]+sol[-1,3])*0.5+(sol[-1,1]+sol[-1,4])*0+(sol[-1,2]+sol[-1,5])*1
    GY=(sol[-1,0]+sol[-1,3])*np.sqrt(3)/2
    #plt.plot(GX,GY,'k*',markersize=15)
    #plt.text(GX+0.05,GY,'G',fontsize=20)
    print(GX,GY)
    """
    #plot the phase space
    plt.savefig("Cont_rep_sexual.pdf")
    plt.show()
    #plot the evolutionary dynamics of last simulation
    plt.plot(t,sol[:,0],linewidth=3,color="c",linestyle="-",label='$C_1$')
    plt.plot(t,sol[:,2],linewidth=3,color="y",linestyle="-",label='$D_1^F$')
    plt.plot(t,sol[:,1],linewidth=3,color="m",linestyle="-",label='$D_1^M$')
    plt.plot(t,sol[:,3],linewidth=3,color="c",linestyle="--",label='$C_2$')
    plt.plot(t,sol[:,5],linewidth=3,color="y",linestyle="--",label='$D_2^F$')
    plt.plot(t,sol[:,4],linewidth=3,color="m",linestyle="--",label='$D_2^M$')
    plt.xlim(0,  T* 1.1)
    plt.ylim(0., 1.1)
    plt.xlabel("time", fontsize=15)
    plt.ylabel("frequency",fontsize=15)
    plt.legend(loc="upper left",fontsize=14)
    plt.savefig("Cont_rep_sexual_dynamics.pdf")
    plt.show()

    Simulate the continuous replicator dymnamics in sexual model
    from the three different initial conditions
    
Simulate the continuous replicator dymnamics in sexual model
from the three different initial conditions
Simulate the continuous replicator dymnamics in sexual model from the three different initial conditions
def main():
    T=1000
    init=np.array([10,1,1,10,1,1])
    init=init/sum(init)
    t=np.linspace(0,T,100*T+1)
    sol=odeint(func, init, t, args=(a2,b2,theta))
    triplot(sol,"c")
    init=np.array([1,10,1,1,10,1])
    init=init/sum(init)
    t=np.linspace(0,T,100*T+1)
    sol=odeint(func, init, t, args=(a2,b2,theta))
    triplot(sol,"m")
    init=np.array([1,1,10,1,1,10]) 
    init=init/sum(init)
    t=np.linspace(0,T,500*T+1)
    sol=odeint(func, init, t, args=(a2,b2,theta)) 
    triplot(sol,"y")
    plt.savefig("Cont_rep_sexual.pdf")
    plt.show()
    plt.plot(t,sol[:,0],linewidth=3,color="c",linestyle="-",label='$C_1$')
    plt.plot(t,sol[:,2],linewidth=3,color="y",linestyle="-",label='$D_1^F$')
    plt.plot(t,sol[:,1],linewidth=3,color="m",linestyle="-",label='$D_1^M$')
    plt.plot(t,sol[:,3],linewidth=3,color="c",linestyle="--",label='$C_2$')
    plt.plot(t,sol[:,5],linewidth=3,color="y",linestyle="--",label='$D_2^F$')
    plt.plot(t,sol[:,4],linewidth=3,color="m",linestyle="--",label='$D_2^M$')
    plt.xlim(0,  T* 1.1)
    plt.ylim(0., 1.1)
    plt.xlabel("time", fontsize=15)
    plt.ylabel("frequency",fontsize=15)
    plt.legend(loc="upper left",fontsize=14)
    plt.savefig("Cont_rep_sexual_dynamics.pdf")
    plt.show()
def main ( ) : T = 1000 init = np . array ( [ 10 , 1 , 1 , 10 , 1 , 1 ] ) init = init / sum ( init ) t = np . linspace ( 0 , T , 100 * T + 1 ) sol = odeint ( func , init , t , args = ( a2 , b2 , theta ) ) triplot ( sol , "c" ) init = np . array ( [ 1 , 10 , 1 , 1 , 10 , 1 ] ) init = init / sum ( init ) t = np . linspace ( 0 , T , 100 * T + 1 ) sol = odeint ( func , init , t , args = ( a2 , b2 , theta ) ) triplot ( sol , "m" ) init = np . array ( [ 1 , 1 , 10 , 1 , 1 , 10 ] ) init = init / sum ( init ) t = np . linspace ( 0 , T , 500 * T + 1 ) sol = odeint ( func , init , t , args = ( a2 , b2 , theta ) ) triplot ( sol , "y" ) """
    #plot the interior point G if the inital sex ratio is 1:1
    GX=(sol[-1,0]+sol[-1,3])*0.5+(sol[-1,1]+sol[-1,4])*0+(sol[-1,2]+sol[-1,5])*1
    GY=(sol[-1,0]+sol[-1,3])*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 ( "Cont_rep_sexual.pdf" ) plt . show ( ) plt . plot ( t , sol [ : , 0 ] , linewidth = 3 , color = "c" , linestyle = "-" , label = '$C_1$' ) plt . plot ( t , sol [ : , 2 ] , linewidth = 3 , color = "y" , linestyle = "-" , label = '$D_1^F$' ) plt . plot ( t , sol [ : , 1 ] , linewidth = 3 , color = "m" , linestyle = "-" , label = '$D_1^M$' ) plt . plot ( t , sol [ : , 3 ] , linewidth = 3 , color = "c" , linestyle = "--" , label = '$C_2$' ) plt . plot ( t , sol [ : , 5 ] , linewidth = 3 , color = "y" , linestyle = "--" , label = '$D_2^F$' ) plt . plot ( t , sol [ : , 4 ] , linewidth = 3 , color = "m" , linestyle = "--" , label = '$D_2^M$' ) plt . xlim ( 0 , T * 1.1 ) plt . ylim ( 0. , 1.1 ) plt . xlabel ( "time" , fontsize = 15 ) plt . ylabel ( "frequency" , fontsize = 15 ) plt . legend ( loc = "upper left" , fontsize = 14 ) plt . savefig ( "Cont_rep_sexual_dynamics.pdf" ) plt . show ( )
Simulate the continuous replicator dymnamics in sexual model
from the three different initial conditions
Simulate the continuous replicator dymnamics in sexual model from the three different initial conditions
"""
    Simulate the continuous replicator dymnamics in sexual model
    from the three different initial conditions
    """ #end the simulation at T #iniital condition 1 #initial condition 2 # initial condition 3 #init=np.array([1,1,10.1,1,1,10]) # initial condition 4 #initial condition 4: sex ratio is NOT 1:1 """
    #plot the interior point G if the inital sex ratio is 1:1
    GX=(sol[-1,0]+sol[-1,3])*0.5+(sol[-1,1]+sol[-1,4])*0+(sol[-1,2]+sol[-1,5])*1
    GY=(sol[-1,0]+sol[-1,3])*np.sqrt(3)/2
    #plt.plot(GX,GY,'k*',markersize=15)
    #plt.text(GX+0.05,GY,'G',fontsize=20)
    print(GX,GY)
    """ #plot the phase space #plot the evolutionary dynamics of last simulation