def __init__(self,agents=[],tolerance=0.0001,act_T=1000,**kwds): ''' Make a new instance of CobbDouglasEconomy by filling in attributes specific to this kind of market. Parameters ---------- agents : [ConsumerType] List of types of consumers that live in this economy. tolerance: float Minimum acceptable distance between "dynamic rules" to consider the solution process converged. Distance depends on intercept and slope of the log-linear "next capital ratio" function. act_T : int Number of periods to simulate when making a history of of the market. Returns ------- None ''' Market.__init__(self,agents=agents, sow_vars=['KtoLnow','RfreeNow','wRteNow','PermShkAggNow','TranShkAggNow'], reap_vars=['pNow','aNow'], track_vars=['KtoLnow'], dyn_vars=['kNextFunc'], tolerance=tolerance, act_T=act_T) self.assignParameters(**kwds) self.update()
def __init__(self, agents=[], tolerance=0.0001, act_T=1000, **kwds): ''' Make a new instance of CobbDouglasEconomy by filling in attributes specific to this kind of market. Parameters ---------- agents : [ConsumerType] List of types of consumers that live in this economy. tolerance: float Minimum acceptable distance between "dynamic rules" to consider the solution process converged. Distance depends on intercept and slope of the log-linear "next capital ratio" function. act_T : int Number of periods to simulate when making a history of of the market. Returns ------- None ''' Market.__init__(self, agents=agents, sow_vars=[ 'KtoLnow', 'RfreeNow', 'wRteNow', 'PermShkAggNow', 'TranShkAggNow' ], reap_vars=['pNow', 'aNow'], track_vars=['KtoLnow'], dyn_vars=['kNextFunc'], tolerance=tolerance, act_T=act_T) self.assignParameters(**kwds) self.update()
def __init__(self, FluctuationsOneAssetIOU, agents=[], act_T=1000): ''' Make a new instance of LuettickeEconomy by filling in attributes specific to this kind of market. Parameters ---------- FluctuationsOneAssetIOU : FluctuationsOneAssetIOUs Class from Luetticke_code that solves the model agents : [ConsumerType] List of types of consumers that live in this economy. act_T : int Number of periods to simulate when making a history of of the market. Returns ------- None ''' Market.__init__(self, agents=agents, sow_vars=['XNow'], reap_vars=[], track_vars=[], dyn_vars=[], tolerance=1e-10, act_T=act_T) self.FluctuationsOneAssetIOU = deepcopy(FluctuationsOneAssetIOU)
def solve(self): ''' Solves the cstwMPCmarket. ''' if self.AggShockBool: for agent in self.agents: agent.getEconomyData(self) Market.solve(self) else: self.solveAgents() self.makeHistory()
def reset(self): ''' Reset the economy to prepare for a new simulation. Sets the time index of aggregate shocks to zero and runs Market.reset(). Parameters ---------- none Returns ------- none ''' self.Shk_idx = 0 Market.reset(self)
def reset(self): ''' Reset the economy to prepare for a new simulation. Sets the time index of aggregate shocks to zero and runs Market.reset(). This replicates the reset method for CobbDouglasEconomy; future version should create parent class of that class and this one. Parameters ---------- None Returns ------- None ''' self.Shk_idx = 0 Market.reset(self)
ThisType.solve() type_list.append(ThisType) ThisType = deepcopy(AltType) ThisType(punk_utility=u_vec[j]) ThisType.solve() type_list.append(ThisType) for j in range(u_vec.size): ThisType = deepcopy(TestType) ThisType(jock_utility=u_vec[j]) ThisType.solve() type_list.append(ThisType) ThisType = deepcopy(AltType) ThisType(jock_utility=u_vec[j]) ThisType.solve() type_list.append(ThisType) # Now run the simulation inside a Market TestMarket = Market(agents = type_list, sow_vars = ['pNow'], reap_vars = ['sNow'], track_vars = ['pNow'], dyn_vars = ['pNextIntercept','pNextSlope','pNextWidth'], millRule = calcPunkProp, calcDynamics = calcFashionEvoFunc, act_T = 1000, tolerance = 0.01) TestMarket.pNow_init = 0.5 TestMarket.solve() plt.plot(TestMarket.pNow_hist) plt.show()
ThisType = deepcopy(AltType) ThisType(punk_utility=u_vec[j]) ThisType.solve() type_list.append(ThisType) for j in range(u_vec.size): ThisType = deepcopy(TestType) ThisType(jock_utility=u_vec[j]) ThisType.solve() type_list.append(ThisType) ThisType = deepcopy(AltType) ThisType(jock_utility=u_vec[j]) ThisType.solve() type_list.append(ThisType) # Now run the simulation inside a Market TestMarket = Market(agents = type_list, <<<<<<< HEAD sow_vars = ['pPop'], reap_vars = ['pNow','pop_size'], track_vars = ['pPop'], ======= sow_vars = ['pNow'], reap_vars = ['sNow'], track_vars = ['pNow'], >>>>>>> eeb37f24755d0c683c9d9efbe5e7447425c98b86 dyn_vars = ['pNextIntercept','pNextSlope','pNextWidth'], millRule = calcPunkProp, calcDynamics = calcFashionEvoFunc, act_T = 1000, tolerance = 0.01) <<<<<<< HEAD