コード例 #1
0
if __name__ == '__main__':
    import ConsumerParameters as Params
    from ConsIndShockModel import IndShockConsumerType
    import matplotlib.pyplot as plt
    from copy import deepcopy
    from time import clock
    from HARK.parallel import multiThreadCommands, multiThreadCommandsFake

    # Set up a baseline IndShockConsumerType, which will be replicated.
    # In this case, we use a completely arbitrary 10 period lifecycle.
    TestType = IndShockConsumerType(**Params.init_lifecycle)
    TestType.TestVar = np.empty(
        TestType.AgentCount
    )  # This is for making an empty buffer for diagnostics
    TestType.CubicBool = True  # Cubic interpolation must be on, because that's what's used in OpenCL version
    T_sim = 10  # Choose simulation length
    AgentCount = 100  # Chose number of agents in each type
    TestType.T_sim = T_sim  # Choose number of periods to simulate
    TestType.AgentCount = AgentCount
    TestType.initializeSim()  # Set up some objects for simulation

    # Make a list with many copies of the baseline agent type, each with a different CRRA.
    TypeCount = 100
    CRRAmin = 1.0
    CRRAmax = 5.0
    CRRAset = np.linspace(CRRAmin, CRRAmax, TypeCount)
    TypeList = []
    for j in range(TypeCount):
        NewType = deepcopy(TestType)
        NewType(CRRA=CRRAset[j])