14. Installing OG-Core#
14.1. Installing and Running OG-Core from Python Package Index (PyPI.org)#
Open your terminal (or Conda command prompt), and make sure you have the most recent version of
pip(the Python Index Package manager) by typing on a Unix/macOS machinepython3 -m pip install --upgrade pipor on a Windows machinepy -m pip install --upgrade pip.Install the
ogcorepackage from the Python Package Index by typingpip install ogcore.Navigate to a folder
./YourFolderName/where you want to save scripts to run OG-Core and output from the simulations in those scripts.Save the python script
run_ogcore_example.pyfrom the OG-Core GitHub repository in the folder where you are working on your local machine./YourFolderName/run_ogcore_example.py.Run the model with an example reform from terminal/command prompt by typing
python run_ogcore_example.pyYou can adjust the
run_ogcore_example.pyscript by modifying model parameters specified in theog_specdictionary.Model outputs will be saved in the following files:
./run_example_plotsThis folder will contain a number of plots generated from OG-Core to help you visualize the output from your run
./ogcore_example_output.csvThis is a summary of the percentage changes in macro variables over the first ten years and in the steady-state.
./OUTPUT_BASELINE/model_params.pklModel parameters used in the baseline run
See
execute.pyin the OG-Core repository for items in the dictionary object in this pickle file
./OUTPUT_BASELINE/SS/SS_vars.pklOutputs from the model steady state solution under the baseline policy
See
SS.pyin the OG-Core repository for what is in the dictionary object in this pickle file
./OUTPUT_BASELINE/TPI/TPI_vars.pklOutputs from the model time path solution under the baseline policy
See
TPI.pyin the OG-Core repository for what is in the dictionary object in this pickle file
An analogous set of files in the
./OUTPUT_REFORMdirectory, which represent objects from the simulation of the reform policy
Note that, depending on your machine, a full model run (solving for the full time path equilibrium for the baseline and reform policies) can take more than two hours of compute time.
If you run into errors running the example script, please open a new issue in the OG-Core repo with a description of the issue and any relevant trace backs you receive.
The CSV output file ./ogcore_example_output.csv can be compared to the ./run_examples/expected_ogcore_example_output.csv file in the OG-Core repository to confirm that you are generating the expected output. The easiest way to do this is to copy the example-diffs and example-diffs.bat files from the OG-Core repository and use the sh example-diffs command (or example-diffs on Windows) from the run_examples directory. If you run into errors running the example script, please open a new issue in the OG-Core repo with a description of the issue and any relevant trace backs you receive.
14.2. Installing and Running OG-Core from GitHub repository#
Install the Anaconda distribution of Python
Clone the
OG-Corerepository to a directory on your computerFrom the terminal (or Conda command prompt), navigate to the directory to which you cloned this repository and run
conda env create -f environment.ymlThen,
conda activate ogcore-devThen install by
pip install -e .Navigate to
./run_examplesRun the model with an example reform from terminal/command prompt by typing
python run_ogcore_example.pyYou can adjust the
./run_examples/run_ogcore_example.pyscript by modifying model parameters specified in theog_specdictionary.Model outputs will be saved in the following files:
./run_examples/run_example_plotsThis folder will contain a number of plots generated from OG-Core to help you visualize the output from your run
./run_examples/ogcore_example_output.csvThis is a summary of the percentage changes in macro variables over the first ten years and in the steady-state.
./run_examples/OUTPUT_BASELINE/model_params.pklModel parameters used in the baseline run
See
execute.pyfor items in the dictionary object in this pickle file
./run_examples/OUTPUT_BASELINE/SS/SS_vars.pklOutputs from the model steady state solution under the baseline policy
See
SS.pyfor what is in the dictionary object in this pickle file
./run_examples/OUTPUT_BASELINE/TPI/TPI_vars.pklOutputs from the model time path solution under the baseline policy
See
TPI.pyfor what is in the dictionary object in this pickle file
An analogous set of files in the
./run_examples/OUTPUT_REFORMdirectory, which represent objects from the simulation of the reform policy
Note that, depending on your machine, a full model run (solving for the full time path equilibrium for the baseline and reform policies) can take more than two hours of compute time.
If you run into errors running the example script, please open a new issue in the OG-Core repo with a description of the issue and any relevant trace backs you receive.
The CSV output file ./run_examples/ogcore_example_output.csv can be compared to the ./run_examples/expected_ogcore_example_output.csv file that is checked into the repository to confirm that you are generating the expected output. The easiest way to do this is to use the sh example-diffs command (or example-diffs on Windows) from the run_examples directory. If you run into errors running the example script, please open a new issue in the OG-Core repo with a description of the issue and any relevant trace backs you receive.
14.3. Exercises#
Exercise 14.1
Intall and run the OG-Core example file as instructed above on your computer. How long did it take to execute?