Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update environment.yml and related files for new OG-Core version #25

Merged
merged 9 commits into from
Jan 9, 2023

Conversation

rickecon
Copy link
Collaborator

@rickecon rickecon commented Jan 9, 2023

This PR updates the OG-ZAF environment.yml file and related other files to update the repository for the recent changes in the OG-Core repository dependency. This PR does the following:

  • Deletes the environment-M1.yml file
  • Updates the environment.yml file such that the mkl dependency is deleted, python can go up to v3.10.8, and added ipython and setuptools
  • Updates README.md with new badges and with updated running instructions that no longer include separate Apple M1 chip instructions
  • Updates setup.py.

cc: @SeaCelo @sarvonz

@rickecon rickecon marked this pull request as draft January 9, 2023 10:19
@rickecon
Copy link
Collaborator Author

rickecon commented Jan 9, 2023

I did the following steps and ran the example script on my Apple M1 computer and everything ran great.

  • go to your main branch of your OG-ZAF repository
  • Make sure your main branch is up to date and synched with the EAPD-DRB/OG-ZAF main branch:
    • git fetch upstream
    • git merge upstream/main
    • git push origin main
  • Delete your current ogzaf-dev conda environment: conda remove --name ogzaf-dev --all
  • Create a new branch with my development branch's name: git checkout -b rickecon-newenv main
  • Pull the files from my development branch into your new branch: git pull https://github.com/rickecon/OG-ZAF.git newenv
  • Now create a new ogzaf-dev conda environment with the updated environment.yml file in this new branch: conda env create -f environment.yml
  • Run the example script and make sure it runs on your apple M1 machines: python ./examples/run_og_zaf.py

Here is the output and computation times that I got on my machine.

Baseline steady state successfully computed equilibrium output

GE loop errors =  [0.0, 6.938893903907228e-18, -2.220446049250313e-16, 0.0, 2.4424906541753444e-15, 1.700029006457271e-16, 1.6653345369377348e-16, -1.457167719820518e-16, -1.0408340855860843e-16, -1.1449174941446927e-16, -3.95516952522712e-16, 6.114900252818245e-16, 9.71445146547012e-17, -4.163336342344337e-17]
Iteration: 01  Distance:  4.7950347054193925e-14
SS debt =  1.1046080277131487 0.002153550713183966
IO:  (1, 1) , C:  (1,)
Foreign debt holdings =  0.25960572435975426
Foreign capital holdings =  1.1284127214380768
resource constraint:  [-1.77080572e-14]
Checking constraints on capital, labor, and consumption.
	There were no violations of the constraints on labor  supply.
	There were no violations of the constraints on  consumption.
Maximum error in labor FOC =  1.1324274851176597e-13
Maximum error in savings FOC =  1.141309269314661e-13
JUST SAVED SS output to  /Users/richardevans/Docs/Economics/OSE/OG-ZAF/examples/OG-ZAF-Example/OUTPUT_BASELINE/SS/SS_vars.pkl

Baseline transition path successfully computed equilibrium output (18 min, 43 sec)

Maximum debt ratio:  5.694607668942559
w diff:  8.595252589671531e-07 -6.212452585696582e-07
r diff:  3.73451034332839e-08 -4.993343398485006e-08
r_p diff:  3.73451034332839e-08 -4.993343398485006e-08
p_m diff:  0.0 0.0
BQ diff:  2.612471139765149e-07 -3.686940223610047e-10
TR diff:  4.555215703250237e-08 -2.5034477808827393e-07
Iteration: 23
	Distance: 7.722996106926913e-06
Max absolute value resource constraint error: 2.405068691799239e-06
Checking time path for violations of constraints.
Max Euler error, savings:  2.454036973631446e-12
Max Euler error labor supply:  1.5782930518071225e-12
Time path iteration complete.
It took 1122.6613419055939 seconds to get that part done.
run time =  1122.662897825241
making dir:  /Users/richardevans/Docs/Economics/OSE/OG-ZAF/examples/OG-ZAF-Example/OUTPUT_REFORM/SS
making dir:  /Users/richardevans/Docs/Economics/OSE/OG-ZAF/examples/OG-ZAF-Example/OUTPUT_REFORM/TPI

Reform steady state successfully computed equilibrium output

GE loop errors =  [2.9073965457371287e-15, 2.9906632725840154e-15, -3.1086244689504383e-15, 0.0, 2.220446049250313e-16, 4.145989107584569e-16, 2.5673907444456745e-16, 3.0184188481996443e-16, 1.7867651802561113e-16, 1.6653345369377348e-16, 9.020562075079397e-17, 1.6609977282477928e-16, 2.0816681711721685e-17]
Iteration: 01  Distance:  3.6784974315546605e-14
SS debt =  0.7498685342806954 0.009533714709629593
IO:  (1, 1) , C:  (1,)
Foreign debt holdings =  0.2999474137122782
Foreign capital holdings =  0.05218567020720602
resource constraint:  [-2.35818309e-14]
Steady state government spending is negative to satisfy budget
Checking constraints on capital, labor, and consumption.
	There were no violations of the constraints on labor  supply.
	There were no violations of the constraints on  consumption.
Maximum error in labor FOC =  9.170442183403793e-14
Maximum error in savings FOC =  9.769962616701378e-14
/Users/richardevans/opt/anaconda3/envs/ogzaf-dev/lib/python3.9/site-packages/ogcore/SS.py:1378: UserWarning: Warning: The combination of the tax policy you specified and your target debt-to-GDP ratio results in an infeasible amount of government spending in order to close the budget (i.e., G < 0)
  warnings.warn(
JUST SAVED SS output to  /Users/richardevans/Docs/Economics/OSE/OG-ZAF/examples/OG-ZAF-Example/OUTPUT_REFORM/SS/SS_vars.pkl

Reform transition path successfully computed equilibrium output (33 min, 11 sec)

Maximum debt ratio:  2.557433818920087
w diff:  3.3661276210850133e-07 -9.787312098552547e-07
r diff:  8.369785002917962e-08 -3.085605355598875e-08
r_p diff:  7.393014317055857e-08 -2.867165810327421e-08
p_m diff:  0.0 0.0
BQ diff:  4.472062528973475e-08 -1.0957020255518424e-07
TR diff:  1.666109511466729e-08 -1.4364215403239733e-07
Iteration: 39
	Distance: 7.228144766475768e-06
Max absolute value resource constraint error: 2.675644699551283e-07
Checking time path for violations of constraints.
Max Euler error, savings:  3.396394276933279e-12
Max Euler error labor supply:  9.132694600566538e-13
Time path iteration complete.
It took 1991.3265969753265 seconds to get that part done.
run time =  1991.3276779651642
Percentage changes in aggregates: Year                    Variable   2021   2022  ...   2030  2021-2030     SS
0                    GDP ($Y_t$) -36.67 -37.16  ... -38.90     -38.59 -43.43
1            Consumption ($C_t$)   2.82  15.18  ... -17.52      -6.45 -28.21
2          Capital Stock ($K_t$) -28.33 -32.21  ... -47.23     -40.56 -60.57
3                  Labor ($L_t$) -11.31  -9.73  ...  -1.26      -6.25   2.93
4     Real interest rate ($r_t$) -66.45 -58.96  ... -19.34     -38.46  27.98
5                      Wage rate -16.52 -18.61  ... -27.66     -23.44 -35.75

[6 rows x 13 columns]

We can update some CI tests in a future PR to make sure this runs on all other platforms.

@rickecon rickecon marked this pull request as ready for review January 9, 2023 11:00
@SeaCelo
Copy link
Collaborator

SeaCelo commented Jan 9, 2023

I'm testing this now but one issue that somehow was lost in the shuffle is the use of openssl. I had prepared a PR that included this change but I somehow didn't merge this particular change.
The issue is discussed here.
My original proposed merge here.

Anaconda has recently changed their default version of openssl from 1.1.1 to 3.0.7. This means the new environment will inherit this version as well. As I found, the API for UN Population doesn't work with the more recent version of openssl.

I'm not sure if OG-CORE wants to make this change as I don't know much about the security implications of keeping the older openssl, but we should do it in the OG-ZAF installation or the demographics.py script will likely break.

As a longer term solution I will inform the colleagues in UN Population about this issue.

@SeaCelo SeaCelo linked an issue Jan 9, 2023 that may be closed by this pull request
@rickecon
Copy link
Collaborator Author

rickecon commented Jan 9, 2023

@SeaCelo. I just updated the environment.yml file to include openssl=1.1.1. I ran the example script on my machine with this new ogzaf-dev conda environment, and everything works great. This PR is ready to go.

@SeaCelo
Copy link
Collaborator

SeaCelo commented Jan 9, 2023

I agree

@SeaCelo SeaCelo merged commit b478323 into EAPD-DRB:main Jan 9, 2023
@rickecon rickecon deleted the newenv branch February 10, 2023 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update installation instructions for ARM Macs (M1 and M2)
2 participants