Dynamic_Environment_Sexual_Discrete.py
def func(x, t, a2,b2,theta,w):
    """
    Continuous replicator dynamics
    x: array of the frequency of the three strategy
    t: time
    a2, b2, theta: defined in function Matrix
    w: fruiting body formation is prevented or not
    w=0 -> unable to form fruiting bodies, only MC formation occurs
    w=1 -> able to form fruiting bodies
    """
    #x is array and A is matrix
    #if w=0 there is no effect of fruiting body formation
    Aa=w*Matrix(a2,b2,0)#asexual
    As=Matrix(a2,b2,theta)#sexual
    A1=np.c_[Aa,As]#extend colum
    A2=np.c_[As,Aa]
    A=np.r_[A1,A2]#complete payoff
    phi=np.dot(x,A)
    phi=np.dot(phi,x.T)#mean fitness in the population
    #calculate replicator dynamics
    f0=np.dot(A[0,:],x.T)/phi#C1
    f1=np.dot(A[1,:],x.T)/phi#DM1
    f2=np.dot(A[2,:],x.T)/phi#DF1 
    f3=np.dot(A[3,:],x.T)/phi#C2
    f4=np.dot(A[4,:],x.T)/phi#DM2
    f5=np.dot(A[5,:],x.T)/phi#DF2 
    f=np.array([x[0]*f0,x[1]*f1,x[2]*f2,x[3]*f3,x[4]*f4,x[5]*f5])
    
    return(f)

    Continuous replicator dynamics
    x: array of the frequency of the three strategy
    t: time
    a2, b2, theta: defined in function Matrix
    w: fruiting body formation is prevented or not
    w=0 -> unable to form fruiting bodies, only MC formation occurs
    w=1 -> able to form fruiting bodies
    
Continuous replicator dynamics
x: array of the frequency of the three strategy
t: time
a2, b2, theta: defined in function Matrix
w: fruiting body formation is prevented or not
w=0 -> unable to form fruiting bodies, only MC formation occurs
w=1 -> able to form fruiting bodies
Continuous replicator dynamics x : array of the frequency of the three strategy t : time a2 b2 theta : defined in function Matrix w : fruiting body formation is prevented or not w = 0 - > unable to form fruiting bodies only MC formation occurs w = 1 - > able to form fruiting bodies
def func(x, t, a2,b2,theta,w):
    Aa=w*Matrix(a2,b2,0)
    As=Matrix(a2,b2,theta)
    A1=np.c_[Aa,As]
    A2=np.c_[As,Aa]
    A=np.r_[A1,A2]
    phi=np.dot(x,A)
    phi=np.dot(phi,x.T)
    f0=np.dot(A[0,:],x.T)/phi
    f1=np.dot(A[1,:],x.T)/phi
    f2=np.dot(A[2,:],x.T)/phi
    f3=np.dot(A[3,:],x.T)/phi
    f4=np.dot(A[4,:],x.T)/phi
    f5=np.dot(A[5,:],x.T)/phi
    f=np.array([x[0]*f0,x[1]*f1,x[2]*f2,x[3]*f3,x[4]*f4,x[5]*f5])
    return(f)
def func ( x , t , a2 , b2 , theta , w ) : Aa = w * Matrix ( a2 , b2 , 0 ) As = Matrix ( a2 , b2 , theta ) A1 = np . c_ [ Aa , As ] A2 = np . c_ [ As , Aa ] A = np . r_ [ A1 , A2 ] phi = np . dot ( x , A ) phi = np . dot ( phi , x . T ) f0 = np . dot ( A [ 0 , : ] , x . T ) / phi f1 = np . dot ( A [ 1 , : ] , x . T ) / phi f2 = np . dot ( A [ 2 , : ] , x . T ) / phi f3 = np . dot ( A [ 3 , : ] , x . T ) / phi f4 = np . dot ( A [ 4 , : ] , x . T ) / phi f5 = np . dot ( A [ 5 , : ] , x . T ) / phi f = np . array ( [ x [ 0 ] * f0 , x [ 1 ] * f1 , x [ 2 ] * f2 , x [ 3 ] * f3 , x [ 4 ] * f4 , x [ 5 ] * f5 ] ) return ( f )
Continuous replicator dynamics
x: array of the frequency of the three strategy
t: time
a2, b2, theta: defined in function Matrix
w: fruiting body formation is prevented or not
w=0 -> unable to form fruiting bodies, only MC formation occurs
w=1 -> able to form fruiting bodies
Continuous replicator dynamics x : array of the frequency of the three strategy t : time a2 b2 theta : defined in function Matrix w : fruiting body formation is prevented or not w = 0 - > unable to form fruiting bodies only MC formation occurs w = 1 - > able to form fruiting bodies
"""
    Continuous replicator dynamics
    x: array of the frequency of the three strategy
    t: time
    a2, b2, theta: defined in function Matrix
    w: fruiting body formation is prevented or not
    w=0 -> unable to form fruiting bodies, only MC formation occurs
    w=1 -> able to form fruiting bodies
    """ #x is array and A is matrix #if w=0 there is no effect of fruiting body formation #asexual #sexual #extend colum #complete payoff #mean fitness in the population #calculate replicator dynamics #C1 #DM1 #DF1  #C2 #DM2 #DF2 
x
t
a2
b2
theta
w