Skip to content

Commit

Permalink
loading default params into initialization, last cases. see econ-ark#446
Browse files Browse the repository at this point in the history
  • Loading branch information
sbenthall committed Jan 4, 2020
1 parent ed017fa commit ecd50e8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions HARK/ConsumptionSaving/ConsGenIncProcessModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
getPercentiles
from HARK.simulation import drawLognormal, drawDiscrete, drawUniform
from HARK.ConsumptionSaving.ConsIndShockModel import ConsIndShockSetup, ConsumerSolution, IndShockConsumerType
import HARK.ConsumptionSaving.ConsumerParameters as Params

utility = CRRAutility
utilityP = CRRAutilityP
Expand Down Expand Up @@ -982,6 +983,10 @@ def __init__(self, cycles=1, time_flow=True, **kwds):
-------
None
'''
params = Params.init_explicit_perm_inc.copy()
params.update(kwds)
kwds = params

# Initialize a basic ConsumerType
IndShockConsumerType.__init__(self, cycles=cycles, time_flow=time_flow, **kwds)
self.solveOnePeriod = solveConsGenIncProcess # idiosyncratic shocks solver with explicit persistent income
Expand Down Expand Up @@ -1310,7 +1315,6 @@ def updatepLvlNextFunc(self):
###############################################################################

def main():
import HARK.ConsumptionSaving.ConsumerParameters as Params
from HARK.utilities import plotFuncs
from time import clock
import matplotlib.pyplot as plt
Expand All @@ -1326,7 +1330,7 @@ def mystr(number): return "{:.4f}".format(number)
print('percentile is ' + str(Params.init_explicit_perm_inc['pLvlPctiles'][-1]*100) + '.\n')

# Make and solve an example "explicit permanent income" consumer with idiosyncratic shocks
ExplicitExample = IndShockExplicitPermIncConsumerType(**Params.init_explicit_perm_inc)
ExplicitExample = IndShockExplicitPermIncConsumerType()
t_start = clock()
ExplicitExample.solve()
t_end = clock()
Expand Down
8 changes: 6 additions & 2 deletions HARK/ConsumptionSaving/ConsMedModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from HARK.ConsumptionSaving.ConsGenIncProcessModel import ConsGenIncProcessSolver,\
PersistentShockConsumerType, ValueFunc2D, MargValueFunc2D,\
MargMargValueFunc2D, VariableLowerBoundFunc2D
import HARK.ConsumptionSaving.ConsumerParameters as Params
from copy import deepcopy

utility_inv = CRRAutility_inv
Expand Down Expand Up @@ -527,6 +528,10 @@ def __init__(self,cycles=1,time_flow=True,**kwds):
-------
None
'''
params = Params.init_medical_shocks.copy()
params.update(kwds)
kwds = params

PersistentShockConsumerType.__init__(self,cycles=cycles,**kwds)
self.solveOnePeriod = solveConsMedShock # Choose correct solver
self.addToTimeInv('CRRAmed')
Expand Down Expand Up @@ -1361,7 +1366,6 @@ def solveConsMedShock(solution_next,IncomeDstn,MedShkDstn,LivPrb,DiscFac,CRRA,CR
###############################################################################

def main():
import HARK.ConsumptionSaving.ConsumerParameters as Params
from HARK.utilities import CRRAutility_inv
from time import clock
import matplotlib.pyplot as plt
Expand All @@ -1370,7 +1374,7 @@ def main():
do_simulation = True

# Make and solve an example medical shocks consumer type
MedicalExample = MedShockConsumerType(**Params.init_medical_shocks)
MedicalExample = MedShockConsumerType()
t_start = clock()
MedicalExample.solve()
t_end = clock()
Expand Down

0 comments on commit ecd50e8

Please sign in to comment.