Exemple #1
0
 def testPolyChangeFtnDecreasing2(self):
     pc = util.PolyChangeFtn(-0.2, 10)
     self.assertTrue(fequal(pc(0), 0))
     self.assertTrue(fequal(pc(1), -0.0181818))
     self.assertTrue(fequal(pc(10), -0.1))
     self.assertTrue(fequal(pc(50), -0.1666666))
     self.assertTrue(fequal(pc(100), -0.1818181))
     self.assertTrue(fequal(pc(500), -0.1960784))
     self.assertTrue(fequal(pc(1000), -0.1980198))
     self.assertTrue(pc(5000) >= -0.2)
     self.assertTrue(pc(10000) >= -0.2)
Exemple #2
0
 def testPolyChangeFtnDecreasing(self):
     pc = util.PolyChangeFtn(-1, 1)
     self.assertTrue(fequal(pc(0), 0))
     self.assertTrue(fequal(pc(1), -0.5))
     self.assertTrue(fequal(pc(2), -0.6666666))
     self.assertTrue(fequal(pc(3), -0.75))
     self.assertTrue(fequal(pc(4), -0.80))
     self.assertTrue(fequal(pc(5), -0.8333333))
     self.assertTrue(pc(10) >= -1.0)
     self.assertTrue(pc(50) >= -1.0)
     self.assertTrue(pc(100) >= -1.0)
     self.assertTrue(pc(500) >= -1.0)
     self.assertTrue(pc(1000) >= -1.0)
def runContinuousChange(animate):
    space = population.Dimension(
        'space', [util.PolyChangeFtn(0.2, 100),
                  util.PolyChangeFtn(-0.35, 10)])

    water = population.Dimension(
        'water', [util.PolyChangeFtn(0.2, 50),
                  util.PolyChangeFtn(-0.25, 20)])

    food = population.Dimension(
        'food', [util.PolyChangeFtn(0.10, 100),
                 util.PolyChangeFtn(-0.15, 20)])

    capacity = population.CarryingCapacity(10000000, [space, water, food])
    model = population.LogisticModel(0.02, 4500000, capacity)

    t, p = population.solve(model, maxTime=250)
    if animate:
        population.animate(model, t, p, legend='lower right')
    else:
        population.plot(model, t, p)