示例#1
0
s = Simulator(
    [
        Stock(
            name="Hares",
            flows=[("HareBirths", "IN"),
                   ("HareDeaths", "OUT")],
            quantity=50000,
            qunit="Hares"
            ),
        Stock(
            name="Lynx",
            flows=[("LynxBirths", "IN"),
                   ("LynxDeaths", "OUT")],
            quantity=1250,
            qunit="Lynx"
            ),
        Flow(
            name="HareBirths",
            qunit="Hares",
            tunit="Month",
            func=lambda h, r: h * r,
            argmap=[
                "Hares",
                1.25
                ]
            ),
        Flow(
            name="HareDeaths",
            qunit="Hares",
            tunit="Month",
            func=hare_kills,
            argmap=[
                AREA,
                "Hares",
                "Lynx"
                ]
            ),
        Flow(
            name="LynxBirths",
            qunit="Lynx",
            tunit="Month",
            func=lambda h, r: h * r,
            argmap=[
                "Lynx",
                .25
                ]
            ),
        Flow(
            name="LynxDeaths",
            qunit="Lynx",
            tunit="Month",
            func=lynx_starvation,
            argmap=[
                AREA,
                "Hares",
                "Lynx"
                ]
            )
        ],
    # log=True
    log=False
    )
示例#2
0
s = Simulator(
    [                         # let's make a simulator
        Stock(                          # it has a stock!
            flows=[("Faucet", "IN"),    # list of flows in and out
                   ("Overflow", "OUT"),
                   ],
            quantity=2,                 # initial quantity
            qunit="Ounce",              # unit
            name="Cup"                  # name
            ),
        Stock(
            name="Floor",
            flows=[("Overflow", "IN")],
            qunit="Ounce"
            ),
        Flow(                           # make a flow!
            name="Faucet",              # name
            func=faucetflow,            # the function that calculates the rate
            argmap=[                    # the inputs to the function.
                2.0,                    # these could be constants
                "Cup"   # or looked up from the environment
                ],
            qunit="Ounce",              # unit of quantity
            tunit="Second"              # per unit time
            ),
        Flow(                           # another flow!
            name="Overflow",            # you know the drill!
            func=overflowflow,
            argmap=[
                "Cup",
                5
                ],
            qunit="Ounce",
            tunit="Second"
            )
        ],
    log=False
    )