Local Mate Competition (LMC).  Here we are interested in the question, how does the number of mates affect selection on the proportion of resources allocated by hermaphrodites (e.g. barnacles) to male and female function?  

Curt Lively (Indiana University) for L567.  

Note: the formulation used here is based on that given by Eric Charnov for LMC in barnacles (see page 246 in Charnov’s (1982) book, “The theory of sex allocation.”)

DEFINING THE VARIABLES...
ai = allocation to male function by the ith hermaphrodite in the population.  
ares = average allocation to male function in the resident population (this was ares in lecture).
astar= the equilibrium value and candidate for the ESS.  (this was a* in lecture)
R = Total resource base for reproduction
K = the number of mates
Wm = individual fitness through male function
Wf = individual fitness though female function (assuming Bateman's principle).
Wi = Fitness of the ith individual (Wf + Wm).  Our target individual.  
Ceggs = cost of each egg (including all associated costs/egg of female function)
Csperm = cost of sperm (including all associated costs of male function).

the imput below clears all the variables.  Put the cursor in the box and hit “shift-return”

ai=.
ares=.
astar=.
R=.
K=.
V=.
Wm=.
Wf=.
Wi=.
Ceggs=.
Csperm=.

FIRST WE DEFINE FITNESS THROUGH FEMALE FUNCTION, Wf.

(Put the cursor anywhere in the bracket below and press "SHIFT-RETURN."  This will store Wf in memory)

Wf = R*(1 - ai)/Ceggs

NEXT DEFINE FITNESS THROUGH MALE FUNCTION, Wm.  
Fitness through male function is estimated as the number of eggs available to the target individual
     ((K R (1 -ares))/Ceggs)
(as there are K mates that each make (1 - ares)/Ceggs) 
      times
the amount of sperm produced by the target individual divided by the total amount of sperm in local population. 
     (((R ai)/Csperm)/((((K-1)R ares)/Csperm) + ((R ai)/Csperm)))
(where K - 1 is the number of competitors for the k mates.  Remember that there is no self fertilization). 

Thus, we have

Wm =  ((K R (1 -ares))/Ceggs)(((R ai)/Csperm)/((((K-1)R ares)/Csperm) + ((R ai)/Csperm)))

(Put the cursor anywhere in the bracket below and press "SHIFT-RETURN.")

Wm = ((K R (1 -ares))/Ceggs)(((R ai)/Csperm)/((((K-1)R ares)/Csperm) + ((R ai)/Csperm)))

(Put the cursor anywhere in the bracket below and press "SHIFT-RETURN.")

FullSimplify[Wm]

Now we want to calcuate total fintess to the hermaphrodite which is the sum of the gains through male function and female function.
(Put the cursor anywhere in the bracket below and press "SHIFT-RETURN.")

Wi = Wf + Wm

FullSimplify[Wi]

NOW CALCULATE THE FIRST partial DERIVATIVE OF INDIVIDUAL FITNESS WITH RESPECT TO  ALLOCATION TO MALE FUNCTION.  (in mathematica D[y, x] gives the partial derivative of y with respect to x.)

(Put the cursor anywhere in the bracket below and press "SHIFT-RETURN.")

Firstder = D[Wi, ai]

Simplify[Firstder]

FirstderMale = D[Wm, ai]

Simplify[FirstderMale]

FirstderFemale = D[Wf, ai]

CALCULATE THE SECOND DERIVATIVE OF INDIVIDUAL FITNESS AS A FUNCTION OF ITS ALLOCATION TO MALE FUNCTION.  Remember, local stability requires a negative second derivative

(Put the cursor anywhere in the bracket below and press "SHIFT-RETURN.")

Secondder = D[Firstder, ai]

SIMPLIFY THE SECOND DERIVATIVE.

(Put the cursor anywhere in the bracket below and press "SHIFT-RETURN.")

Simplify [Secondder]

Now let CSS be the derivative of the first derivative with respect to ares.

CSS = D[Firstder, ares]

Simplify[CSS]

Now we want to solve for equilibrium to get our candidate for the ESS
(Put the cursor anywhere in the bracket below and press "SHIFT-RETURN.")

ai = ares;
ares = astar;

FullSimplify[Firstder]

SET THE FIRST DERIVATIVE EQUAL TO ZERO AND SOLVE FOR astar.

Solve [Firstder == 0, astar]

Advanced.  We should get the same result when solving for astar when FirstderMale + FirstderFemale is equal to zero.  In other words when the marginal gains through male function are equal to the marginal losses through female function, or vice versa.
(Put the cursor anywhere in the bracket below and press "SHIFT-RETURN.")

Reduce[FirstderMale +  FirstderFemale == 0, astar]

Now set the candidate for the ESS, astar, to (K - 1)/(2K - 1)

(Put the cursor anywhere in the bracket below and press "SHIFT-RETURN.")

astar = (K - 1)/(2 K - 1)

Simplify[Secondder]

Simplify[CSS]

So, the second derivative is negative at the equilibrium for all values of K > 1.  So the candidate for the ESS is in fact an ESS.  
The candidate is also convergence stable. 
Now let the individual allocation, ai, be a variable again.  So (ai) is no longer equal to (astar).  The purpose is to graph individual fitness as a function of ai when the population is at the ESS.  We would expect that Wi is maximized under this condition when ai converges on astar.

We are also going to set the Resources equal to 1 unit.  And the cost eggs to 0.01.

(Put the cursor anywhere in the bracket below and press "SHIFT-RETURN.")

ai = .
R=1;
Ceggs=0.01;

Now, for the crux of the bisquit.  Let there be two mates (k = 2).

(Put the cursor anywhere in the bracket below and press "SHIFT-RETURN.")

K = 2;

The ESS can be found for two mates by simplifying the population allocation, a.

(Put the cursor anywhere in the bracket below and press "SHIFT-RETURN.")

Simplify [astar]

Hence, the ESS is at 0.333.


Now, let's plot the relationship between fitness through male function and the allocation by the ith individual to male function.

(Put the cursor anywhere in the bracket below and press "SHIFT-RETURN.")

FullSimplify[Wm]

Plot [{Wm}, {ai, 0, 1}, 
AxesLabel->{"ai","Wm"}]

Right.  Diminishing returns, just as expected.
Now, let's plot the relationship between fitness through female function and the allocation by the ith individual to male function.

(Put the cursor anywhere in the bracket below and press "SHIFT-RETURN.")

Plot [{Wf}, {ai, 0, 1}, 
AxesLabel->{"ai","Wf"}]

Right.  Linear decrease in fitness gains through female function with increasing allocation to male function.  (This is a consequence of our assumtion that female function is limited only by resources.)  REMEMBER: allocation to female fitness increases from right to left; it's equal to 1 - ai.  
Now let's plot the relationship between total fitness and the allocation by the ith individual to male function.  It should be hump shaped.

(Put the cursor anywhere in the bracket below and press "SHIFT-RETURN.")

Plot [{Wi}, {ai, 0, 1}, 
AxesLabel->{"ai","Wi"}]

Note that individual fitness, Wi, is maximal when ai = a = 0.33.  That is when the individual allocation is at the ESS.

Now let the local mating population be a bit larger, say = 4 mates.

(Put the cursor anywhere in the bracket below and press "SHIFT-RETURN.")

K = 4;

The new ESS for 100 mates is found by simplifying the parameter, a.

(Put the cursor anywhere in the bracket below and press "SHIFT-RETURN.")

Simplify [astar]

Hence, the ESS is at 3/7 which is 0.43.
Now, as previously, let's first plot the relationship between fitness through male function and the allocation by the ith individual to male function.

(Put the cursor anywhere in the bracket below and press "SHIFT-RETURN.")

Plot [{Wm}, {ai, 0, 1}, 
AxesLabel->{"ai","Wm"}]

Note the gains still show dimishing returns, but not as dramatically as for K=2. 

Now, let's plot the relationship between fitness through female function and the allocation by the ith indiviudal to male function.

(Put the cursor anywhere in the bracket below and press "SHIFT-RETURN.")

Plot [{Wf}, {ai, 0, 1}, 
AxesLabel->{"ai","Wf"}]

Again we see a linear decrease in fitness gains through female function with increasing allocation to male function.  (This is a consequence of our assumtion that female function is limited only by resources.)  REMEMBER: allocation to female fitness increases from right to left; it's equal to 1 - ai.  


Finally, let's plot the relationship between total fitness and the allocation by the ith individual to male function.

(Put the cursor anywhere in the bracket below and press "SHIFT-RETURN.")

Plot [{Wi}, {ai, 0, 1}, 
AxesLabel->{"ai","Wi"}]

Note that individual fitness, Wi, is maximal when ai = astar = 0.43.  

Notice that the y axis shows a smaller range.  So the fitness curve has flattened out a bit.

Now, set K to a large value, say 100. Simply type in a number after the "K =" sign.

K =  100;

The new ESS for k mates is found by simplifying the parameter, astar.

Simplify [astar]

Hence the expected allocation a the ESS is very near 0.5.
Plot the relationship between fitness through male function and the allocation by the ith individual to male function.

Plot [{Wm}, {ai, 0, 1}, 
AxesLabel->{"ai","Wm"}]

Note that the gains curve looks very linear.
Now, plot the relationship between fitness through female function and the allocation by the ith indiviudal to male function.

Plot [{Wf}, {ai, 0, 1}, 
AxesLabel->{"ai","Wf"}]

Finally, plot the relationship between total fitness and the allocation by the ith individual to male function.

Plot [{Wi}, {ai, 0, 1}, 
AxesLabel->{"ai","Wi"}]

Is the maximum fitness at the ESS?
Note that the function is humped shaped, but the y axis has a very small range.  It is virtually flat as expected as the gains curve through male function becomes virtually linear.

Now, set K to whatever you want and run through the same steps. Simply type in a number after the "K =" sign.  You can then return to this point, change K to a new value and go again.  Have fun.

K =  10;

The new ESS for k mates is found by simplifying the parameter, astar.

Simplify [astar]

Plot the relationship between fitness through male function and the allocation by the ith individual to male function.

Plot [{Wm}, {ai, 0, 1}, 
AxesLabel->{"ai","Wm"}]

Now, plot the relationship between fitness through female function and the allocation by the ith indiviudal to male function.

Plot [{Wf}, {ai, 0, 1}, 
AxesLabel->{"ai","Wf"}]

Finally, plot the relationship between total fitness and the allocation by the ith individual to male function.

Plot [{Wi}, {ai, 0, 1}, 
AxesLabel->{"ai","Wi"}]

Is the maximum fitness at the ESS?

Note that as you increase K, the fitness function flatterns out.