Exemple #1
0
    def __init__(self, cycles=1, time_flow=True, **kwds):
        '''
        Instantiate a new ConsumerType with given data, and construct objects
        to be used during solution (income distribution, assets grid, etc).
        See ConsumerParameters.init_pref_shock for a dictionary of
        the keywords that should be passed to the constructor.

        Parameters
        ----------
        cycles : int
            Number of times the sequence of periods should be solved.
        time_flow : boolean
            Whether time is currently "flowing" forward for this instance.

        Returns
        -------
        None
        '''
        params = init_preference_shocks.copy()
        params.update(kwds)

        IndShockConsumerType.__init__(self,
                                      cycles=cycles,
                                      time_flow=time_flow,
                                      **params)
        self.solveOnePeriod = solveConsPrefShock  # Choose correct solver
Exemple #2
0
    def __init__(self, cycles=1, time_flow=True, **kwds):
        '''
        Instantiate a new ConsumerType with given data.
        See ConsumerParameters.init_idiosyncratic_shocks for a dictionary of
        the keywords that should be passed to the constructor.
        
        Parameters
        ----------
        cycles : int
            Number of times the sequence of periods should be solved.
        time_flow : boolean
            Whether time is currently "flowing" forward for this instance.
        
        Returns
        -------
        None
        '''
        # Initialize a basic AgentType
        IndShockConsumerType.__init__(self,
                                      cycles=cycles,
                                      time_flow=time_flow,
                                      **kwds)

        # Add consumer-type specific objects, copying to create independent versions
        self.solveOnePeriod = solvePrefLaborShock  # idiosyncratic shocks solver
        self.update()  # Make assets grid, income process, terminal solution
Exemple #3
0
    def __init__(self, cycles=1, time_flow=True, **kwds):
        '''
        Instantiate a new ConsumerType with given data, and construct objects
        to be used during solution (income distribution, assets grid, etc).
        See ConsumerParameters.init_kinky_pref for a dictionary of the keywords
        that should be passed to the constructor.

        Parameters
        ----------
        cycles : int
            Number of times the sequence of periods should be solved.
        time_flow : boolean
            Whether time is currently "flowing" forward for this instance.

        Returns
        -------
        None
        '''
        params = Params.init_kinky_pref.copy()
        params.update(kwds)
        kwds = params
        IndShockConsumerType.__init__(self, **kwds)
        self.solveOnePeriod = solveConsKinkyPref  # Choose correct solver
        self.addToTimeInv('Rboro', 'Rsave')
        self.delFromTimeInv('Rfree')
Exemple #4
0
    def __init__(self, cycles=1, time_flow=True, **kwds):
        '''
        Instantiate a new consumer type with given data.
        See ConsumerParameters.init_labor_intensive for a dictionary of
        the keywords that should be passed to the constructor.
        
        Parameters
        ----------
        cycles : int
            Number of times the sequence of periods should be solved.
        time_flow : boolean
            Whether time is currently "flowing" forward for this instance.
        
        Returns
        -------
        None
        '''
        params = Params.init_labor_intensive.copy()
        params.update(kwds)
        kwds = params

        IndShockConsumerType.__init__(self,
                                      cycles=cycles,
                                      time_flow=time_flow,
                                      **kwds)
        self.pseudo_terminal = False
        self.solveOnePeriod = solveConsLaborIntMarg
        self.update()
Exemple #5
0
    def __init__(self,
                 cycles=1,
                 **kwds):
        '''
        Instantiate a new ConsumerType with given data, and construct objects
        to be used during solution (income distribution, assets grid, etc).
        See ConsumerParameters.init_pref_shock for a dictionary of
        the keywords that should be passed to the constructor.

        Parameters
        ----------
        cycles : int
            Number of times the sequence of periods should be solved.

        Returns
        -------
        None
        '''
        params = init_preference_shocks.copy()
        params.update(kwds)

        IndShockConsumerType.__init__(self,
                                      cycles=cycles,
                                      **params)
        self.solveOnePeriod = makeOnePeriodOOSolver(ConsPrefShockSolver)
 def __init__(self, **kwds):
     params = init_kinky_pref.copy()
     params.update(kwds)
     kwds = params
     IndShockConsumerType.__init__(self, **kwds)
     self.solve_one_period = make_one_period_oo_solver(ConsKinkyPrefSolver)
     self.add_to_time_inv("Rboro", "Rsave")
     self.del_from_time_inv("Rfree")
    def __init__(self, **kwds):
        params = init_rep_agent.copy()
        params.update(kwds)

        IndShockConsumerType.__init__(self, cycles=0, **params)
        self.AgentCount = 1  # Hardcoded, because this is rep agent
        self.solve_one_period = solve_ConsRepAgent
        self.del_from_time_inv("Rfree", "BoroCnstArt", "vFuncBool", "CubicBool")
Exemple #8
0
    def __init__(self, **kwds):
        params = init_labor_intensive.copy()
        params.update(kwds)

        IndShockConsumerType.__init__(self, **params)

        self.pseudo_terminal = False
        self.solve_one_period = solve_ConsLaborIntMarg
        self.update()
Exemple #9
0
    def __init__(self, **kwargs):
        IndShockConsumerType.__init__(self, **kwargs)

        # Add consumer-type specific objects, copying to create independent versions
        if (not self.CubicBool) and (not self.vFuncBool):
            solver = ConsIndShockSolverBasicFast
        else:  # Use the "advanced" solver if either is requested
            solver = ConsIndShockSolverFast

        self.solve_one_period = make_one_period_oo_solver(solver)
Exemple #10
0
    def __init__(self, verbose=False, quiet=False, **kwds):
        params = init_risky_asset.copy()
        params.update(kwds)
        kwds = params

        # Initialize a basic consumer type
        IndShockConsumerType.__init__(self, verbose=verbose, quiet=quiet, **kwds)

        # These method must be overwritten by classes that inherit from
        # RiskyAssetConsumerType
        self.solve_one_period = NullFunc()
Exemple #11
0
    def __init__(self, cycles=1, verbose=False, quiet=False, **kwds):
        params = init_portfolio.copy()
        params.update(kwds)
        kwds = params

        # Initialize a basic consumer type
        IndShockConsumerType.__init__(
            self, cycles=cycles, verbose=verbose, quiet=quiet, **kwds
        )

        shock_vars = ["PermShkNow", "TranShkNow","AdjustNow","RiskyNow"]

        # Set the solver for the portfolio model, and update various constructed attributes
        self.solveOnePeriod = solveConsPortfolio
        self.update()
    def __init__(self, **kwds):

        IndShockConsumerType.__init__(self, **kwds)

        self.time_inv = ['aXtraGrid', 'mGrid', 'EGMVector', 'par', 'Util', 'UtilP',
                         'UtilP_inv', 'saveCommon']

        self.par = RetiringDeatonParameters(self.DiscFac, self.CRRA, self.DisUtil, self.Rfree, YRet, YWork, self.sigma)
       # d == 2 is working
        # - 10.0 moves curve down to improve linear interpolation
        self.Util = lambda c, d: utility(c, CRRA) - self.par.DisUtil*(d-1) - 10.0
        self.UtilP = lambda c, d: utilityP(c, CRRA) # we require CRRA 1.0 for now...
        self.UtilP_inv = lambda u, d: utilityP_inv(u, CRRA) # ... so ...

        self.preSolve = self.updateLast
        self.solveOnePeriod = solveRetiringDeaton
    def __init__(self, **kwds):
        params = init_explicit_perm_inc.copy()
        params.update(kwds)

        # Initialize a basic ConsumerType
        IndShockConsumerType.__init__(self, **params)
        self.solve_one_period = make_one_period_oo_solver(
            ConsGenIncProcessSolver)

        # a poststate?
        self.state_now['aLvl'] = None
        self.state_prev['aLvl'] = None

        # better way to do this...
        self.state_now["mLvl"] = None
        self.state_prev["mLvl"] = None
Exemple #14
0
    def __init__(self,time_flow=True,**kwds):
        '''
        Make a new instance of a representative agent.

        Parameters
        ----------
        time_flow : boolean
            Whether time is currently "flowing" forward for this instance.

        Returns
        -------
        None
        '''
        IndShockConsumerType.__init__(self,cycles=0,time_flow=time_flow,**kwds)
        self.AgentCount = 1 # Hardcoded, because this is rep agent
        self.solveOnePeriod = solveConsRepAgent
        self.delFromTimeInv('Rfree','BoroCnstArt','vFuncBool','CubicBool')
Exemple #15
0
    def __init__(self,**kwds):
        '''
        Make a new instance of a representative agent.

        Parameters
        ----------

        Returns
        -------
        None
        '''
        params = init_rep_agent.copy()
        params.update(kwds)
        
        IndShockConsumerType.__init__(self,cycles=0,**params)
        self.AgentCount = 1 # Hardcoded, because this is rep agent
        self.solveOnePeriod = solveConsRepAgent
        self.delFromTimeInv('Rfree','BoroCnstArt','vFuncBool','CubicBool')
Exemple #16
0
    def __init__(self, cycles=1, verbose=False, quiet=False, **kwds):
        params = init_portfolio.copy()
        params.update(kwds)
        kwds = params

        # Initialize a basic consumer type
        IndShockConsumerType.__init__(
            self,
            cycles=cycles,
            verbose=verbose,
            quiet=quiet,
            **kwds
        )
        
        # Set the solver for the portfolio model, and update various constructed attributes
        self.solveOnePeriod = solveConsPortfolio
        # solveConsPortfolio will be defined later
        # indent 的是這個consumer type可以執行的指令,指令的def不用indent在這個consumer type之下
        self.update()
 def __init__(self, cycles=1, time_flow=True, **kwds):
     '''
     Just calls on IndShockConsumperType
     
     Parameters
     ----------
     cycles : int
         Number of times the sequence of periods should be solved.
     time_flow : boolean
         Whether time is currently "flowing" forward for this instance.
     
     Returns
     -------
     None
     '''
     # Initialize an IndShockConsumerType
     IndShockConsumerType.__init__(self,
                                   cycles=cycles,
                                   time_flow=time_flow,
                                   **kwds)
Exemple #18
0
    def __init__(self,
                 cycles=1,
                 time_flow=True,
                 verbose=False,
                 quiet=False,
                 **kwds):
        params = init_portfolio.copy()
        params.update(kwds)
        kwds = params

        # Initialize a basic consumer type
        IndShockConsumerType.__init__(self,
                                      cycles=cycles,
                                      time_flow=time_flow,
                                      verbose=verbose,
                                      quiet=quiet,
                                      **kwds)

        # Set the solver for the portfolio model, and update various constructed attributes
        self.solveOnePeriod = solveConsPortfolio
        self.update()
Exemple #19
0
    def __init__(self, cycles=1, **kwds):
        """
        Instantiate a new consumer type with given data.
        See init_labor_intensive for a dictionary of
        the keywords that should be passed to the constructor.

        Parameters
        ----------
        cycles : int
            Number of times the sequence of periods should be solved.

        Returns
        -------
        None
        """
        params = init_labor_intensive.copy()
        params.update(kwds)

        IndShockConsumerType.__init__(self, cycles=cycles, **params)
        self.pseudo_terminal = False
        self.solveOnePeriod = solveConsLaborIntMarg
        self.update()
    def __init__(self, cycles=1, **kwds):
        """
        Instantiate a new ConsumerType with given data, and construct objects
        to be used during solution (income distribution, assets grid, etc).
        See init_kinky_pref for a dictionary of the keywords
        that should be passed to the constructor.

        Parameters
        ----------
        cycles : int
            Number of times the sequence of periods should be solved.

        Returns
        -------
        None
        """
        params = init_kinky_pref.copy()
        params.update(kwds)
        kwds = params
        IndShockConsumerType.__init__(self, **kwds)
        self.solveOnePeriod = makeOnePeriodOOSolver(ConsKinkyPrefSolver)
        self.addToTimeInv("Rboro", "Rsave")
        self.delFromTimeInv("Rfree")
Exemple #21
0
    def __init__(self, cycles=1, **kwds):
        IndShockConsumerType.__init__(self, cycles=1, **kwds)
        self.solve_one_period = _solve_ConsMarkov

        if not hasattr(self, "global_markov"):
            self.global_markov = False
Exemple #22
0
 def __init__(self,cycles=1,time_flow=True,**kwds):
     IndShockConsumerType.__init__(self,cycles=1,time_flow=True,**kwds)
     self.solveOnePeriod = _solveConsMarkov
     self.poststate_vars += ['MrkvNow']
     if not hasattr(self, 'global_markov'):
         self.global_markov = False
    def __init__(self, **kwds):
        params = init_preference_shocks.copy()
        params.update(kwds)

        IndShockConsumerType.__init__(self, **params)
        self.solve_one_period = make_one_period_oo_solver(ConsPrefShockSolver)
    def __init__(self, cycles=200, **kwds):

        IndShockConsumerType.__init__(self, cycles=200, **kwds)
Exemple #25
0
 def __init__(self, cycles=1, **kwds):
     IndShockConsumerType.__init__(self, cycles=1, **kwds)
     self.solveOnePeriod = _solveConsMarkov
     self.poststate_vars += ["MrkvNow"]
     if not hasattr(self, "global_markov"):
         self.global_markov = False