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

Westeros scenario does not solve with --foresight=1 #736

Open
MESSAGEix-SK-Woo opened this issue Aug 22, 2023 · 6 comments
Open

Westeros scenario does not solve with --foresight=1 #736

MESSAGEix-SK-Woo opened this issue Aug 22, 2023 · 6 comments
Labels
bug Doesn't work as advertised/unintended effects

Comments

@MESSAGEix-SK-Woo
Copy link

Hi, I'm making power sector model using MESSAGEix.

And I was wondering what is difference between perfect-foresight and recursive-dynamic.

So, I just try westores examples at first.

below is what i did.

  1. open the 'westeros_baseline.ipynb'
  2. chage a code 'scenario.solve()' to 'scenario.solve(gams_args =["--foresight=1"])'
    ※python version: 3.9.7 and I use latest version of all package(message-ix, ixmp, ...)

And then, the moel said 'GAMS errored with return code 3: There was an execution error'.

So I found MESSAGE_run.lst, and I can find some error like that.
※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※
**** Exec Error at line 2780: Equation infeasible due to rhs value
**** INFEASIBLE EQUATIONS ...
---- CAPACITY_CONSTRAINT =L= capacity constraint for technology (by sub-annual time slice)
CAPACITY_CONSTRAINT(Westeros,coal_ppl,690,700,year).. 0 =L= -18.2648401826484 ; (LHS = 0, INFES = 18.2648401826484 ****)
CAPACITY_CONSTRAINT(Westeros,wind_ppl,690,700,year).. 0 =L= -12.1765601217656 ; (LHS = 0, INFES = 12.1765601217656 ****)
REMAINING 5 ENTRIES SKIPPED

**** Exec Error at line 2806: Equation infeasible due to rhs value
**** INFEASIBLE EQUATIONS ...
---- CAPACITY_MAINTENANCE_HIST =E= constraint for capacity maintenance historical installation (built before start of model horizon)
CAPACITY_MAINTENANCE_HIST(Westeros,coal_ppl,690,700).. 0 =E= 18.2648401826484 ; (LHS = 0, INFES = 18.2648401826484 ****)
CAPACITY_MAINTENANCE_HIST(Westeros,wind_ppl,690,700).. 0 =E= 33.8237781160156 ; (LHS = 0, INFES = 33.8237781160156 ****)

**** Exec Error at line 2830: Equation infeasible due to rhs value
**** INFEASIBLE EQUATIONS ...
---- CAPACITY_MAINTENANCE_NEW =E= constraint for capacity maintenance of new capacity built in the current period (vintage == year)
CAPACITY_MAINTENANCE_NEW(Westeros,coal_ppl,700,700).. 0 =E= 3.5527136788005E-15 ; (LHS = 0, INFES = 3.5527136788005E-15 ****)
※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※

I know the above code's meanings, but...

Why did I get these results?

How can I solve it?

I guess "scenario.solve(gams_args =["--foresight=1"])" is right, because if i adjust ["--foresight=0"], it operate well( 0 means perfect-foresight, you know)

Please.. help me!

Thanks! :)

@glatterf42
Copy link
Member

Hi @MESSAGEix-SK-Woo, thanks for asking these questions and already including a lot of information :)

Two tips for including code or error messages in the future: you can include in-line code using `some code` (which you can also enable with ctrl+e) and you can format code blocks nicely using e.g.
```python

some code 
on multiple lines

```

As for your question, I have to say that I don't have a lot of model experience myself. However, search our documentation for 'perfect foresight', I found two things in particular: a theoretical explanation and some notes on use cases.
From these, I understand that you are using the ["--foresight=1"] correctly, as any value greater than 0 will cause the recursive-dynamic :)
I can also see that perfect foresight is used much more frequently and recursive-dynamic only for specific applications. The mathematical difference seems to be that in perfect foresight, GAMS optimizes the objective function including all years of the model, while with recursive-dynamic, GAMS loops over the years of the model and optimizes each step individually, only keeping the values of prior steps fixed. Judging from this explanation, I don't see any reason why the westeros tutorials shouldn't be solvable with recursive-dynamic, but someone with more model experience might know more about this, so I will ask one of my colleagues.

@MESSAGEix-SK-Woo
Copy link
Author

Hi @glatterf42 , Thank you for giving reply and useful information.

I also agree with your comment 'perfect foresight is used much more frequently' but I want to compare with two method in my MESSAGE. That's Why I try it!

Maybe I made a mistake, but I don't know which part.
Thanks you for asking this problem to your colleagues!
Have a woderful day :)

@khaeru
Copy link
Member

khaeru commented Aug 23, 2023

I confirm this is reproducible; here's a MWE using the testing utility we have that sets up the Westeros scenario:

import ixmp
from message_ix.testing import make_westeros

mp = ixmp.Platform()
s = make_westeros(mp)

s.solve(gams_args=["--foresight=1"])

I also attach the terminal output.txt and MESSAGE_run.lst.

@ywpratama @gidden, given your work on #697 and related, I think you are most/currently familiar with the recursive-dynamic operation of MESSAGE.

  • Are these familiar error symptoms to you?
  • Is there anything that is missing from the Westeros model that would be needed to solve with --foresight=1? @glatterf42 and I looked in the documentation, but could not find any specific mention.

@gidden
Copy link
Member

gidden commented Aug 23, 2023

@ywpratama will have to chime in with specifics, but from my memory the current implementation of dynamic recursive solves are not expected to work on the main branch, and indeed are why #697 is needed. @MESSAGEix-SK-Woo could you try working from the branch currently in #697 to see if you get the same errors? We can then in parallel wait for @ywpratama to comment here.

I'd note that in the referenced PR there is a dynamic recursive tutorial as well, which would be a good starting point.

@khaeru khaeru changed the title How can I solve theses problems(using westroes about recursive-dynamic)? Westeros scenario does not solve with --foresight=1 Aug 23, 2023
@khaeru khaeru added the bug Doesn't work as advertised/unintended effects label Aug 23, 2023
@MESSAGEix-SK-Woo
Copy link
Author

Thanks, @khaeru and @gidden .
I created a new environment in Anaconda and utilized @ywpratama 's message_ix instead of my existing message_ix.
This is because I thought the problem was in the gams code itself, not in python.
Also, I thought that ywpratama's message_ix was GAMS modified for recursive-dynamic.
But this also gives me an error.

  • This is my first time so I don't know how can I use Git's functions. I'll study What is branch and How can I handle it, and then try. Thanks! (I need a little time)

@glatterf42
Copy link
Member

Take your time, no problem. You may find these links useful:

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
Projects
None yet
Development

No branches or pull requests

4 participants