def setup(cls, t_obj, tpg, err_func): tpg_obj = cls(t_obj, tag=tpg.get("tag", None)) set_attributes(tpg_obj, tpg.get("attributes", {}), err_func) set_parameters(tpg_obj, tpg.get("parameters", {}), err_func) for lun in tpg.get("luns", []): LUN.setup(tpg_obj, lun, err_func) for p in tpg.get("portals", []): NetworkPortal.setup(tpg_obj, p, err_func) for acl in tpg.get("node_acls", []): NodeACL.setup(tpg_obj, acl, err_func) tpg_obj.enable = tpg.get("enable", True) dict_remove(tpg, ("luns", "portals", "node_acls", "tag", "attributes", "parameters", "enable")) for name, value in tpg.iteritems(): if value: try: setattr(tpg_obj, name, value) except: err_func("Could not set tpg %s attribute '%s'" % (tpg_obj.tag, name))
def ss_olg(): # Set parameters of the model params = set_parameters() # Compute real wage and capital w, K_L = ss_production(params['r'], params['alpha'], params['delta']) K = K_L * params['workers'] # Balance government budget tau, d = government(w, params['retirees'], tau=0.2) # Calibrate 'beta' such that A=K params['beta'] = opt.newton(error, x0=0.95, args=(K, params, r, w, tau, d)) # Store steady-state objects at the calibrated 'beta' ss = household_ss_olg(params, params['r'], w, tau, d) return ss
def setup(cls, t_obj, tpg, err_func): tpg_obj = cls(t_obj, tag=tpg.get("tag", None)) set_attributes(tpg_obj, tpg.get('attributes', {}), err_func) set_parameters(tpg_obj, tpg.get('parameters', {}), err_func) for lun in tpg.get('luns', []): LUN.setup(tpg_obj, lun, err_func) for p in tpg.get('portals', []): NetworkPortal.setup(tpg_obj, p, err_func) for acl in tpg.get('node_acls', []): NodeACL.setup(tpg_obj, acl, err_func) tpg_obj.enable = tpg.get('enable', True) dict_remove(tpg, ('luns', 'portals', 'node_acls', 'tag', 'attributes', 'parameters', 'enable')) for name, value in tpg.iteritems(): if value: try: setattr(tpg_obj, name, value) except: err_func("Could not set tpg %s attribute '%s'" % (tpg_obj.tag, name))
def setup(cls, t_obj, tpg, err_func): tpg_obj = cls(t_obj, tag=tpg.get("tag", None)) tpg_obj.enable = tpg.get('enable', True) set_attributes(tpg_obj, tpg.get('attributes', {})) set_parameters(tpg_obj, tpg.get('parameters', {})) for lun in tpg.get('luns', []): LUN.setup(tpg_obj, lun, err_func) for p in tpg.get('portals', []): NetworkPortal.setup(tpg_obj, p, err_func) for acl in tpg.get('node_acls', []): NodeACL.setup(tpg_obj, acl, err_func) dict_remove(tpg, ('luns', 'portals', 'node_acls', 'tag', 'attributes', 'parameters', 'enable')) for name, value in tpg.iteritems(): if value: try: setattr(tpg_obj, name, value) except: err_func("Could not set tpg %s attribute '%s'" % (tpg_obj.tag, name))
# depth and number of agents d = 1 na = 6 try: if len(sys.argv) == 2: raise ParameterError('wrong number of parameters.') if len(sys.argv) > 2: d = int(sys.argv[1]) na = int(sys.argv[2]) if d <= 0 or na <= 1: raise ParameterError('wrong value for <depth> or <number of agents>') set_parameters(d, na) print('Generating atoms for depth ' + str(depth()) + ' and ' + str(nb_agts()) + ' agents...') base = Goal() # negative goals if len(sys.argv) > 3: ast = parseSet(sys.argv[3]) print('Generating negative goals ' + str(ast) + '...') update_negative_goals(base, ast) except ParameterError as e: print('Error: ' + str(e)) print('Usage: python gp_generator.py ' + '<depth> <number of agents> ["<description of negative goals>"] ' +