-
-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tracking bug in bequest portfolio consumer model check
- Loading branch information
Showing
2 changed files
with
94 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from HARK.ConsumptionSaving.ConsPortfolioModel import (\n", | ||
" PortfolioConsumerType,\n", | ||
" init_portfolio,\n", | ||
")\n", | ||
"from HARK.ConsumptionSaving.ConsBequestModel import BequestWarmGlowPortfolioType\n", | ||
"\n", | ||
"from HARK.ConsumptionSaving.ConsIndShockModel import (\n", | ||
" init_idiosyncratic_shocks\n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"port_type = PortfolioConsumerType(**init_portfolio)\n", | ||
"port_type.cycles = 0\n", | ||
"port_type.solve()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 21, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"ename": "AttributeError", | ||
"evalue": "'PortfolioSolution' object has no attribute 'cFunc'", | ||
"output_type": "error", | ||
"traceback": [ | ||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", | ||
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)", | ||
"Cell \u001b[0;32mIn[21], line 7\u001b[0m\n\u001b[1;32m 4\u001b[0m beq_type\u001b[38;5;241m.\u001b[39mTermBeqFac \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m0\u001b[39m\n\u001b[1;32m 5\u001b[0m beq_type\u001b[38;5;241m.\u001b[39mBeqFac \u001b[38;5;241m=\u001b[39m [\u001b[38;5;241m0\u001b[39m]\n\u001b[0;32m----> 7\u001b[0m \u001b[43mbeq_type\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msolve\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n", | ||
"File \u001b[0;32m~/mambaforge/envs/hark/lib/python3.9/site-packages/HARK/core.py:519\u001b[0m, in \u001b[0;36mAgentType.solve\u001b[0;34m(self, verbose)\u001b[0m\n\u001b[1;32m 513\u001b[0m \u001b[38;5;66;03m# Ignore floating point \"errors\". Numpy calls it \"errors\", but really it's excep-\u001b[39;00m\n\u001b[1;32m 514\u001b[0m \u001b[38;5;66;03m# tions with well-defined answers such as 1.0/0.0 that is np.inf, -1.0/0.0 that is\u001b[39;00m\n\u001b[1;32m 515\u001b[0m \u001b[38;5;66;03m# -np.inf, np.inf/np.inf is np.nan and so on.\u001b[39;00m\n\u001b[1;32m 516\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m np\u001b[38;5;241m.\u001b[39merrstate(\n\u001b[1;32m 517\u001b[0m divide\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mignore\u001b[39m\u001b[38;5;124m\"\u001b[39m, over\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mignore\u001b[39m\u001b[38;5;124m\"\u001b[39m, under\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mignore\u001b[39m\u001b[38;5;124m\"\u001b[39m, invalid\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mignore\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 518\u001b[0m ):\n\u001b[0;32m--> 519\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mpre_solve\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m \u001b[38;5;66;03m# Do pre-solution stuff\u001b[39;00m\n\u001b[1;32m 520\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39msolution \u001b[38;5;241m=\u001b[39m solve_agent(\n\u001b[1;32m 521\u001b[0m \u001b[38;5;28mself\u001b[39m, verbose\n\u001b[1;32m 522\u001b[0m ) \u001b[38;5;66;03m# Solve the model by backward induction\u001b[39;00m\n\u001b[1;32m 523\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mpost_solve()\n", | ||
"File \u001b[0;32m~/mambaforge/envs/hark/lib/python3.9/site-packages/HARK/ConsumptionSaving/ConsPortfolioModel.py:188\u001b[0m, in \u001b[0;36mPortfolioConsumerType.pre_solve\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 186\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mpre_solve\u001b[39m(\u001b[38;5;28mself\u001b[39m):\n\u001b[1;32m 187\u001b[0m AgentType\u001b[38;5;241m.\u001b[39mpre_solve(\u001b[38;5;28mself\u001b[39m)\n\u001b[0;32m--> 188\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mupdate_solution_terminal\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n", | ||
"File \u001b[0;32m~/mambaforge/envs/hark/lib/python3.9/site-packages/HARK/ConsumptionSaving/ConsBequestModel.py:141\u001b[0m, in \u001b[0;36mBequestWarmGlowPortfolioType.update_solution_terminal\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 138\u001b[0m BequestWarmGlowConsumerType\u001b[38;5;241m.\u001b[39mupdate_solution_terminal(\u001b[38;5;28mself\u001b[39m)\n\u001b[1;32m 140\u001b[0m \u001b[38;5;66;03m# Consume all market resources: c_T = m_T\u001b[39;00m\n\u001b[0;32m--> 141\u001b[0m cFuncAdj_terminal \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msolution_terminal\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcFunc\u001b[49m\n\u001b[1;32m 142\u001b[0m cFuncFxd_terminal \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mlambda\u001b[39;00m m, s: \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39msolution_terminal\u001b[38;5;241m.\u001b[39mcFunc(m)\n\u001b[1;32m 144\u001b[0m \u001b[38;5;66;03m# Risky share is irrelevant-- no end-of-period assets; set to zero\u001b[39;00m\n", | ||
"\u001b[0;31mAttributeError\u001b[0m: 'PortfolioSolution' object has no attribute 'cFunc'" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"beq_type = BequestWarmGlowPortfolioType(\n", | ||
" **init_portfolio)\n", | ||
"\n", | ||
"beq_type.TermBeqFac = 1\n", | ||
"beq_type.BeqFac = [0]\n", | ||
"\n", | ||
"beq_type.solve()\n", | ||
"\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "hark", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.18" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters