def setUp(self): """Set up code for test fixtures.""" params = {'c': 1.0, 'e_G': 0.5, 'e_g': 0.5, 'd_A': 0.5, 'd_a': 0.5, 'PiaA': 7.0, 'PiAA': 5.0, 'Piaa': 3.0, 'PiAa': 2.0} self.family = families.OneMaleTwoFemales(params=params, SGA=pugh_schaffer_seabright.SGA, Sga=pugh_schaffer_seabright.Sga)
def setUp(self): """Set up code for Wright-Bergstrom test case.""" # females send precise signals, but males screen almost randomly eps = 0.5 params = {'c': 5.0, 'e': eps, 'PiaA': 9.0, 'PiAA': 5.0, 'Piaa': 3.0, 'PiAa': 2.0} self.family = families.OneMaleTwoFemales(params=params, SGA=wright_bergstrom.SGA, Sga=wright_bergstrom.Sga)
e = sym.var('e') # Female population by phenotype. altruistic_girls = girls[0] + girls[2] selfish_girls = girls[1] + girls[3] # conditional phenotype matching probabilities (a la Wright/Bergstrom) SGA = e + (1 - e) * altruistic_girls / (altruistic_girls + selfish_girls) SGa = 1 - SGA Sga = e + (1 - e) * selfish_girls / (altruistic_girls + selfish_girls) SgA = 1 - Sga # females send precise signals, but males screen almost randomly eps = 0.5 params = { 'c': 5.0, 'e': eps, 'PiaA': 9.0, 'PiAA': 5.0, 'Piaa': 3.0, 'PiAa': 2.0 } # define an array of initial conditions S_A = mGA = fGA N_initial = 5 eps = 1e-3 mGA0 = np.linspace(eps, 1 - eps, N_initial) # create an instance of the model example = families.OneMaleTwoFemales(params=params, SGA=SGA, Sga=Sga)
# Payoff parameters (from a Prisoner's dilemma) prisoners_dilemma_payoffs = sym.var('PiaA, PiAA, Piaa, PiAa') PiaA, PiAA, Piaa, PiAa = prisoners_dilemma_payoffs # Female fecundity scaling factor fecundity_factor = sym.var('c') # Female population by phenotype. altruistic_girls = girls[0] + girls[2] selfish_girls = girls[1] + girls[3] # Conditional phenotype matching probabilities true_altruistic_girls = d_A * altruistic_girls false_altruistic_girls = (1 - d_a) * selfish_girls mistaken_for_altruistic_girls = (1 - e_G) * false_altruistic_girls altruist_adoption_pool = true_altruistic_girls + mistaken_for_altruistic_girls true_selfish_girls = d_a * selfish_girls false_selfish_girls = (1 - d_A) * altruistic_girls mistaken_for_selfish_girls = (1 - e_g) * false_selfish_girls selfish_adoption_pool = true_selfish_girls + mistaken_for_selfish_girls SGA = true_altruistic_girls / altruist_adoption_pool Sga = true_selfish_girls / selfish_adoption_pool # define some parameters hierarchy_params = {'c': 2.0, 'eG': 0.5, 'eg': 0.5, 'dA': 0.5, 'da': 0.5, 'PiaA': 9.0, 'PiAA': 5.0, 'Piaa': 3.0, 'PiAa': 2.0} family = families.OneMaleTwoFemales(params=hierarchy_params, SGA=SGA, Sga=Sga)
import families import simulators import wright_bergstrom # create an instance of the Family class params = { 'c': 5.0, 'e': 0.5, 'PiaA': 7.0, 'PiAA': 5.0, 'Piaa': 3.0, 'PiAa': 2.0 } family = families.OneMaleTwoFemales(params, SGA=wright_bergstrom.SGA, Sga=wright_bergstrom.Sga) simulator = simulators.Simulator(family) def test_simulate(): """test the simulate method of the Simulator class.""" # one of either rtol or T must be specified! simulator.initial_condition = 0.5 with nose.tools.assert_raises(ValueError): simulator.simulate() def test_plot_isolated_subpopulations_simulation(): """Test return type for isolated subpopulations simulation plot.""" valid_kinds = ['genotypes', 'alpha_allele', 'gamma_allele']