class testAggShockConsumerType(unittest.TestCase): def setUp(self): self.agent = AggShockConsumerType() self.agent.cycles = 0 self.economy = EconomyExample = CobbDouglasEconomy( agents=[self.agent]) def test_economy(self): # Make a Cobb-Douglas economy for the agents self.economy.makeAggShkHist() # Simulate a history of aggregate shocks # Have the consumers inherit relevant objects from the economy self.agent.getEconomyData(self.economy) self.agent.solve()
# Solve a CobbDouglasEconomy with many states, potentially utilizing the "state jumper" solve_poly_state = False # ### Example implementation of AggShockConsumerType if solve_agg_shocks_micro or solve_agg_shocks_market: # Make an aggregate shocks consumer type AggShockExample = AggShockConsumerType() AggShockExample.cycles = 0 # Make a Cobb-Douglas economy for the agents EconomyExample = CobbDouglasEconomy(agents=[AggShockExample]) EconomyExample.makeAggShkHist() # Simulate a history of aggregate shocks # Have the consumers inherit relevant objects from the economy AggShockExample.getEconomyData(EconomyExample) if solve_agg_shocks_micro: # Solve the microeconomic model for the aggregate shocks example type (and display results) t_start = process_time() AggShockExample.solve() t_end = process_time() print("Solving an aggregate shocks consumer took " + mystr(t_end - t_start) + " seconds.") print( "Consumption function at each aggregate market resources-to-labor ratio gridpoint:" ) m_grid = np.linspace(0, 10, 200) AggShockExample.unpack('cFunc') for M in AggShockExample.Mgrid.tolist(): mMin = AggShockExample.solution[0].mNrmMin(M)