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

Correct MACRO GDP reporting & update docs #430

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

GamzeUnlu95
Copy link
Contributor

@GamzeUnlu95 GamzeUnlu95 commented Dec 8, 2020

This PR:

  • Corrects the reporting of GDP which includes the deduction of trade_costs coming from MESSAGE.

  • Updates MESSAGEix based total_cost parameter in iteration with MACRO including the trade balance.

  • Extends the documentation of the capital constraint section in MACRO to explain the reasoning behind the changes.

PR #422 can be closed after merging this.

  • Continuous integration checks all ✅
  • Add or expand tests; coverage checks both ✅
  • Add, expand, or update documentation.
  • Update release notes.

@GamzeUnlu95 GamzeUnlu95 added bug Doesn't work as advertised/unintended effects docs Documentation labels Jan 13, 2021
@khaeru khaeru changed the title MACRO GDP reporting correction and documentation updated Correct MACRO GDP reporting & update docs Apr 27, 2021
@francescolovat francescolovat added the macro MACRO model or MESSAGE-MACRO link label Apr 29, 2021
@codecov
Copy link

codecov bot commented Jun 22, 2021

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.4%. Comparing base (aabb789) to head (5dfd483).

Additional details and impacted files
@@          Coverage Diff          @@
##            main    #430   +/-   ##
=====================================
  Coverage   95.4%   95.4%           
=====================================
  Files         46      46           
  Lines       4354    4354           
=====================================
  Hits        4156    4156           
  Misses       198     198           

@behnam-zakeri behnam-zakeri mentioned this pull request Jul 5, 2021
12 tasks
Copy link
Contributor

@behnam-zakeri behnam-zakeri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @GamzeUnlu95 for drafting this correction. In my view, this is an enhancement; just a few points before merging:

  • I suggested some minor edits in the GAMS files as inline comments
  • More importantly, can you develop a test that show this correction. For example, a test that asserts that the calculated GDP should be equal to a certain value?
  • I believe after applying these changes, some overnight tests may not pass because the objective value may change. I can't see that at the moment as the PR needs to be rebased and the tests should be run again.
    Overall, nice contribution.

@gidden
Copy link
Member

gidden commented Mar 21, 2022

Hi @GamzeUnlu95 - I understand there are still some requirements left for this to be merged. Would you say it is available to try to use on a trial basis?

@gidden gidden mentioned this pull request Mar 25, 2022
4 tasks
@gidden
Copy link
Member

gidden commented Apr 5, 2022

Hi folks, I wanted to report back after having tried to use this PR in some of my ongoing work.

Observed issue: Running a mitigation scenario with a calibrated scenario causes MESSAGE LP infeasibility within MESSAGE-MACRO iteration.

Suggestion: Before merging this, run a test case on the current ENGAGE set up where MACRO is recalibrated with these changes and confirm that mitigation cases can still converge.

More specifics:

It's hard for me to pin point exactly why this PR causes my failure, but I am combining a number of updates - I start from the new R15 model, apply 1-year time steps for early periods, and calibrate using this MACRO branch. I did not observe any issues while creating baselines or non-mitigation scenarios.

When I reverted back to current main, I was able to calibrate and run mitigation scenarios without issue, so strongly suspect these changes were the culprit.

@khaeru
Copy link
Member

khaeru commented Apr 5, 2022

MESSAGE LP infeasibility within MESSAGE-MACRO iteration

Can you please upload a snippet from the GAMS .lst file to indicate which variables are infeasible?

@gidden
Copy link
Member

gidden commented Apr 5, 2022

That file has already been overwritten. I can try later to reproduce - can you tell me what to grep for?

@gidden
Copy link
Member

gidden commented Apr 5, 2022

But this is a good opportunity to plug our need for better tooling when dealing with infeasibilities. It would be great to have some first (or even second) class support to say, dump out why a model was infeasible at the end of a run that is persistable.

@khaeru
Copy link
Member

khaeru commented Apr 5, 2022

can you tell me what to grep for?

#418 (comment) for example

@OFR-IIASA
Copy link
Contributor

I have pulled these changes onto the latest main branch, updated the macro-calibration xlsx but then encountered errors.

**** Exec Error at line 544: log: FUNC SINGULAR: x = 0
**** Exec Error at line 544: overflow in * operation (mulop)

Has anyone encountered such issues? Was this PR already tested with the calibration? I have added the macro_run.lst file as a .txt file if this helps with debugging.
MACRO_run.txt

@GamzeUnlu95
Copy link
Contributor Author

I have pulled these changes onto the latest main branch, updated the macro-calibration xlsx but then encountered errors.

**** Exec Error at line 544: log: FUNC SINGULAR: x = 0
**** Exec Error at line 544: overflow in * operation (mulop)

Has anyone encountered such issues? Was this PR already tested with the calibration? I have added the macro_run.lst file as a .txt file if this helps with debugging. MACRO_run.txt

Thanks for adding the .lst file. I attempted to test this PR with calibration a couple of months ago and at that time there was an issue with the macro-calibration xlsx in the main branch and I could not complete it. I need to find and allocate time soon to test this PR again and finalize it.

@GamzeUnlu95
Copy link
Contributor Author

I tested this PR with the ENGAGE setup by using the model ENGAGE_SSP2_v4.1.7_T4.5_r3.1_test. I did not experience any issues with the calibration of the baseline. I ran the mitigation case with 600 budget and was able to get a solution for EN_NPi2020_600. However, in Step 3 of EN_NPi2020_400, in the third iteration, there is an execution error division by eps as in this MESSAGE-MACRO_run.log and MESSAGE-MACRO_run_lst file. Not sure if this is directly related to the changes that are made in this PR. The line indicated in the error message is the following:

price_diff_rel(iteration,node_macro,sector,year)$( price_init(node_macro,sector,year) ) =
5455      price_diff_abs(iteration,node_macro,sector,year) / price_init(node_macro,sector,year)

@glatterf42
Copy link
Member

At today's message meeting, this PR was suggested to me as a possible fix for #752. As far as I can tell, this PR does not enable usage of user-defined units. However, I rebased this onto current main so if you want to run any tests again to see if this can be merged, this might be a good time, @GamzeUnlu95, @OFR-IIASA, @gidden.

@khaeru
Copy link
Member

khaeru commented Apr 18, 2024

This PR may even predate the PR template, but it is missing one item that appears there: "Update release notes". I've added this to the PR description above.

These notes are especially important when the behaviour and outputs of the core GAMS code change, as in this PR. Users must have an opportunity to notice and understand how their model outputs may be affected by a new release.

@glatterf42
Copy link
Member

As discussed in yesterday's weekly meeting, we hold off on merging these changes because we don't trust our current test suite to adequately verify that the changes won't break anything. As @gidden suggested (please correct me if I misunderstood), we should set up a testing workflow that runs a full emission baseline and a peak budget scenario. Since these runs might take a while, we would ideally keep them optional and either run them as part of nightly tests or enable them on PRs that affect the GAMS code. This would allow us to trust the changes here.

@Jihoon noted that the line currently causing the test failure reported by @GamzeUnlu95 had caused issues before, so was removed locally in his installation without any noticeable negative consequences. No one else in the room knew what this line might be good for, so in a separate PR, we could try to remove it -- and test that with the new test cases proposed above.

@gidden
Copy link
Member

gidden commented Apr 19, 2024

Thanks @glatterf42. My suggestion is to follow @khaeru's example here and combine this with @OFR-IIASA's ENGAGE process script here.

I would suggest to run

  1. a baseline scenario
  2. a full century budget scenario
  3. a peak-budget scenario

And compare a few key metrics on the output excel (e.g., co2 emissions, kyoto emissions, gdp, primary energy, final energy).

@khaeru
Copy link
Member

khaeru commented Apr 22, 2024

My suggestion is to follow @khaeru's example here and combine this with @OFR-IIASA's ENGAGE process script here.

While I generally agree with this idea directionally and the basic observation underlying it, to implement these ideas would involve, conservatively, at least 2 person-weeks of work. Either we accept that this PR sits until someone is assigned/freed-up to spend that time, or we find a simpler, manual check (and someone to do it) that can assure that this PR will not change [expected behaviour].

In order to avoid derailing this particular PR with that broader discussion, I'll open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Doesn't work as advertised/unintended effects docs Documentation macro MACRO model or MESSAGE-MACRO link
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants