예제 #1
0
def test_death_cycle(plain_sim):
    """ Tests that the death cycle works as intended. """
    Herbivore.new_parameters({'omega': 0.99})
    Carnivore.new_parameters({'omega': 0.99})
    plain_sim.add_population([{
        "loc": (1, 1),
        "pop": [
            {
                "species": "Herbivore",
                "age": 100,
                "weight": 0.1
            },
            {
                "species": "Herbivore",
                "age": 7,
                "weight": 100.0
            },
            {
                "species": "Herbivore",
                "age": 100,
                "weight": 0.1
            },
        ]
    }, {
        "loc": (1, 2),
        "pop": [
            {
                "species": "Carnivore",
                "age": 7,
                "weight": 100.0
            },
            {
                "species": "Carnivore",
                "age": 100,
                "weight": 1.0
            },
            {
                "species": "Carnivore",
                "age": 7,
                "weight": 100.0
            },
        ]
    }])
    plain_sim.death_cycle()

    assert len(plain_sim.map.array_map[1, 2].present_carnivores) == 2
    assert len(plain_sim.map.array_map[1, 1].present_herbivores) == 1
    Herbivore.new_parameters({'omega': 0.40})
    Carnivore.new_parameters({'omega': 0.90})
예제 #2
0
def test_set_param_animals(species, extra):
    """Parameters can be set on animal classes"""

    params = {
        "w_birth": 8.0,
        "sigma_birth": 1.5,
        "beta": 0.9,
        "eta": 0.05,
        "a_half": 40.0,
        "phi_age": 0.2,
        "w_half": 10.0,
        "phi_weight": 0.1,
        "mu": 0.25,
        "gamma": 0.2,
        "zeta": 3.5,
        "xi": 1.2,
        "omega": 0.4,
        "F": 10.0,
    }
    params.update(extra)

    BioSim(island_map="O", ini_pop=[],
           seed=1).set_animal_parameters(species, params)

    Carnivore.new_parameters({
        'w_birth': 6.0,
        'sigma_birth': 1.0,
        'beta': 0.75,
        'eta': 0.125,
        'a_half': 60,
        'phi_age': 0.4,
        'w_half': 4.0,
        'phi_weight': 0.4,
        'mu': 0.4,
        'lambda_animal': 1,
        'gamma': 0.8,
        'zeta': 3.5,
        'xi': 1.1,
        'omega': 0.9,
        'F': 50,
        'DeltaPhiMax': 10
    })