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 (inpar
struct), allocates memory to store the solution in (sol
struct), and allocates memory to store the simulated paths in (sim
struct). This builds on theEconModel
class.cppfuncs
: Folder containing all c++ files. The main file linking to Python is thecpp_link_file.cpp
. Thesolve.cpp
files contains the solution algorithm andsimulate.cpp
contains 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.git
and 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.