예제 #1
0
    def get_domain(self):

        calibration = self.get_calibration()
        states = self.symbols['states']

        sdomain = self.data.get("domain", {})
        for k in sdomain.keys():
            if k not in states:
                sdomain.pop(k)

        # backward compatibility
        if len(sdomain) == 0 and len(states) > 0:
            try:
                import warnings
                min = get_address(self.data,
                                  ["options:grid:a", "options:grid:min"])
                max = get_address(self.data,
                                  ["options:grid:b", "options:grid:max"])
                for i, s in enumerate(states):
                    sdomain[s] = [min[i], max[i]]
                # shall we raise a warning for deprecated syntax ?
            except Exception as e:
                print(e)
                pass

        if len(sdomain) < len(states):
            missing = [s for s in states if s not in sdomain]
            raise Exception("Missing domain for states: {}.".format(
                str.join(', ', missing)))

        from dolo.compiler.objects import CartesianDomain
        from dolo.compiler.language import eval_data
        sdomain = eval_data(sdomain, calibration)
        domain = CartesianDomain(**sdomain)
        domain.states = states

        return domain
예제 #2
0
###

from dolo.numeric.distribution import UNormal
exogenous = UNormal(σ=0.001)

# ###
# ### Discretized grid for endogenous states
# ###

# from dolo.numeric.grids import UniformCartesianGrid
# grid = UniformCartesianGrid(min=[-0.01, 5], max=[0.01, 15], n=[20, 20])

###
### Domain for endogenous states

domain = CartesianDomain(z=[-0.01, 0.01], k=[5, 15])

###
### Solve model
###

# now we should be able to solve the model using
# any of the availables methods

model = PureModel(symbols, calibration, functions, domain, exogenous)

from dolo.algos.time_iteration import time_iteration
from dolo.algos.perturbation import perturb
from dolo.algos.simulations import simulate
from dolo.algos.improved_time_iteration import improved_time_iteration