See a short introduction to my numerical setup here
Note: The code has only been tested on Windows and will likely not work without modifications on iOS.
File structure:
Example.ipynb: Main execution file (Jupyter Notebook) from which the model is solved and simulated. Also contains plots.Example.py: Main Python module. This file defines the model class, initializes parameters (inparstruct), allocates memory to store the solution in (solstruct), and allocates memory to store the simulated paths in (simstruct). This builds on theEconModelclass.cppfuncs: Folder containing all c++ files. The main file linking to Python is thecpp_link_file.cpp. Thesolve.cppfiles contains the solution algorithm andsimulate.cppcontains the simulation module.cpp_link_file.dll: The executable file, constructed when compiling the c++ code inExample.ipynb. This is all done automatically once you have followed the installation guide below.
Installation guide:
- Download Anaconda using default options
- Add the location of the Anaconda-installation to PATH in "environment variables".
- Download Git
- Download Visual Studio Code
- in VS-code, install the "Python" extension.
- Download Visual Studio Community compiler. Remember to add C/C++ features for installation.
- Clone this repository from GitHub by i) opening the Anaconda Prompt, ii) navigating to the location on disk where you want the files cloned to, iii) write
git clone https://github.com/ThomasHJorgensen/NumericalSetup.gitand hit enter. - In Anaconda Prompt install required Python packages by typing
pip install econmodel consav
To learn more about how this code uses OpenMP and NLopt to parallelize and solve numerical optimization problems, respectively, see e.g. EconModelNotebooks.