# run the code in Best_SDP_Sim_Parallel_FlexFit.R before running this code # #### Simulations For Figure A3 #### # First, the case where females use the strategy that is optimal for the density they experience.# # To do this, solve the SDP for each density and, for each, simulate mating interactions at that density. # Save the summary statistics of selection in a .csv for each density. # Then, in the analysis script, combine these dfs into one and look at how the summary stats change with density. for (s in 1:length(simulated.densities)){ Best.SDP.Sim(500, # the number of time steps used in the SDPs and simulations simulated.densities[s], # the density to which the population is adapted 1, # the ratio of females to males Fit.type = 1, # 1 = linear B(x), 2 = logistic B(x), 3 = guassian B(x) 25, # minimum benefit from mating for logistic and guassian 50, # maximum increase in benefit of mating for logistic, guassian (c+L is max. benefit) 1.4, # slope of relationship between male trait and female benefit for logisitc, gauss 2, # male trait value used for centering benefit function B(x) for logisitc, gauss 25, # the intercept of the function relating sexual traits to chooser fitness 2, # the slope the of the function relating sexual traits to fitness rep(0.01, 500), # function describing probability that the breeding season ends simulated.densities[s], # densities at which mating interactions are simulated 100, # number of replicate simulations at each simulated density Simulate = TRUE) file.name = paste("AdaptConstantMu_Best.", simulated.densities[s], ".csv", sep = "") write.csv(Best.Sim.Dat, file = file.name) } # for the case where u(t) increases over time, can just solve the SDP for a single density and apply the resulting # behavior across all simulations at different densities. This isolates the effect of the temporal change in strategy # from a change in response to density per se. Best.SDP.Sim(500, # the number of time steps used in the SDPs and simulations 1, # the density to which the population is adapted 1, # the ratio of females to males Fit.type = 1, # 1 = linear B(x), 2 = logistic B(x), 3 = guassian B(x) 25, # minimum benefit from mating for logistic and guassian 50, # maximum increase in benefit of mating for logistic, guassian (c+L is max. benefit) 1.4, # slope of relationship between male trait and female benefit for logisitc, gauss 2, # male trait value used for centering benefit function B(x) for logisitc, gauss 25, # the intercept of the function relating sexual traits to chooser fitness 2, # the slope the of the function relating sexual traits to fitness pmin(0.0001 + (0.0023 * exp(0.02 *c(0:500))), 1), # probability that the breeding season ends simulated.densities, # simulated.densities, # densities at which mating interactions are simulated 100, # number of replicate simulations at each simulated density Simulate = TRUE) write.csv(Best.Sim.Dat, file = "ChangingMu_Best.1.csv")