iiasa / message_ix

The integrated assessment and energy systems model MESSAGEix
https://docs.messageix.org
Apache License 2.0
111 stars 149 forks source link

GAMS infeasibilities with limited foresight/rolling horizon setting #418

Open aaronliuqy opened 3 years ago

aaronliuqy commented 3 years ago

When I set the $SETGLOBAL foresight to any value more than 0 in model_setup.gms, the model fails to solve. I am using the scenario.solve() command, and even with all constraints relaxed, it still fails to solve. This is an example error message from the terminal when I set the foresight to 10 using the Austria tutorial model.

Optimal solution found. Objective : 97345.372405

--- Restarting execution --- MESSAGE_run.gms(4268) 2 Mb --- Reading solution for model MESSAGE_LP --- MESSAGE_run.gms(4158) 3 Mb +++ Solve the recursive-dynamic version of MESSAGEix - iteration 2030 +++ Give it a bit more time, not even two minutes yet... --- Generating LP model MESSAGE_LP --- MESSAGE_run.gms(4268) 3 Mb 1 Error SOLVE aborted --- MESSAGE_run.gms(4268) 3 Mb 1 Error Status: Execution error(s) --- Job MESSAGE_run.gms Stop 11/01/20 12:59:54 elapsed 0:00:00.271 [I 13:01:44.629 NotebookApp] Saving file at /iiasa-message_ix-ee0287a/tutorial/Austrian_energy_system/austria.ipynb

I have tried it with the Westeros tutorial and a model I built, neither would solve with the recursive dynamic model.


https://github.com/iiasa/message_ix/blob/aa02d8c545aec4466fb98290cafbba598a9e56b8/message_ix/model/MESSAGE_master.gms#L55-L59

khaeru commented 3 years ago

In order to diagnose this issue, please:

aaronliuqy commented 3 years ago

The output of show versions:

ixmp: 3.1.0 message_ix: 3.1.0 message_data: None

click: 7.1.2 dask: 2.28.0 graphviz: None jpype: 1.0.2 … JVM path: C:\Users\30338\anaconda3\envs\message_env\Library\bin\server\jvm.dll pandas: 1.1.2 pint: 0.16.1 xarray: 0.16.1 xlrd: 1.2.0 xlsxwriter: 1.3.6 yaml: 5.3.1

iam_units: installed jupyter: installed matplotlib: 3.3.2 plotnine: None pyam: 0.7.0

python: 3.8.5 | packaged by conda-forge | (default, Sep 24 2020, 16:20:24) [MSC v.1916 64 bit (AMD64)] python-bits: 64 OS: Windows OS-release: 10 machine: AMD64 processor: Intel64 Family 6 Model 158 Stepping 13, GenuineIntel byteorder: little LC_ALL: None LANG: None LOCALE: Chinese (Simplified)_China.936

MESSAGE_run.zip

The LST file was not supported so I included it in a zip file.

Thank you.

khaeru commented 3 years ago

MESSAGE_run.zip

The LST file was not supported so I included it in a zip file.

Thanks! The relevant lines appear to be the ones I've extracted below, detectable by ****.

I note that $SETGLOBAL foresight "5". Some additional questions:

---- COMMODITY_BALANCE_GT  =G=  commodity supply greater than or equal demand

COMMODITY_BALANCE_GT(Australia,coal_export,useful,2015,year)..  ACT(Australia,coal_export,2015,2015,standard,year) =G= 9343 ; (LHS = 0, INFES = 9343 ****)

COMMODITY_BALANCE_GT(Australia,gas_export,useful,2015,year)..  ACT(Australia,gas_export,2015,2015,standard,year) =G= 1975 ; (LHS = 0, INFES = 1975 ****)

COMMODITY_BALANCE_GT(Australia,oil_export,useful,2015,year)..  ACT(Australia,oil_export,2015,2015,standard,year) =G= 58 ; (LHS = 0, INFES = 58 ****)

COMMODITY_BALANCE_GT(Australia,oil_demand,useful,2015,year)..  ACT(Australia,oil_demand,2015,2015,standard,year) =G= 0 ; (LHS = 0)

COMMODITY_BALANCE_GT(Australia,gas_demand,useful,2015,year)..  ACT(Australia,gas_demand,2015,2015,standard,year) =G= 1504.9 ; (LHS = 0, INFES = 1504.9 ****)

COMMODITY_BALANCE_GT(Australia,coal_demand,useful,2015,year)..  ACT(Australia,coal_demand,2015,2015,standard,year) =G= 1956.1 ; (LHS = 0, INFES = 1956.1 ****)

COMMODITY_BALANCE_GT(Australia,electricity_demand,useful,2015,year)..  ACT(Australia,electricity_demand,2015,2015,standard,year) =G= 26.2328767123288 ; (LHS = 0, INFES = 26.2328767123288 ****)

COMMODITY_BALANCE_GT(Australia,oil,secondary,2015,year)..  ACT(Australia,oil_import,2015,2015,standard,year) =G= 0 ; (LHS = 0)

COMMODITY_BALANCE_GT(Australia,coal,secondary,2015,year)..  ACT(Australia,coal_import,2015,2015,standard,year) =G= 0 ; (LHS = 0)

COMMODITY_BALANCE_GT(Australia,gas,secondary,2015,year)..  ACT(Australia,gas_import,2015,2015,standard,year) =G= 0 ; (LHS = 0)

COMMODITY_BALANCE_GT(Australia,electricity,secondary,2015,year)..  ACT(Australia,coal_ppl,2015,2015,standard,year) + ACT(Australia,gas_ppl,2015,2015,standard,year) + ACT(Australia,oil_ppl,2015,2015,standard,year)

      + ACT(Australia,bio_ppl,2015,2015,standard,year) + ACT(Australia,hydro_ppl,2015,2015,standard,year) + ACT(Australia,wind_ppl,2015,2015,standard,year) + ACT(Australia,csp_15h_ppl,2015,2015,standard,year)

      - ACT(Australia,electricity_grid,2015,2015,standard,year) =G= 0 ; (LHS = 0)

COMMODITY_BALANCE_GT(Australia,electricity,final,2015,year)..  ACT(Australia,utility_pv_ppl,2015,2015,standard,year) + ACT(Australia,roof_pv_ppl,2015,2015,standard,year) + ACT(Australia,electricity_grid,2015,2015,standard,year)

      - ACT(Australia,electricity_demand,2015,2015,standard,year) =G= 0 ; (LHS = 0)

COMMODITY_BALANCE_GT(Australia,petrol_demand,useful,2015,year)..  0.559*ACT(Australia,crude_to_petrol,2015,2015,standard,year) =G= 1254 ; (LHS = 0, INFES = 1254 ****)

COMMODITY_BALANCE_GT(Australia,petroleum_products_demand,useful,2015,year)..  0.2345*ACT(Australia,crude_to_petroleum_products,2015,2015,standard,year) =G= 519.06 ; (LHS = 0, INFES = 519.06 ****)

COMMODITY_BALANCE_GT(Australia,fuel_oil_demand,useful,2015,year)..  0.093*ACT(Australia,crude_to_fuel_oil,2015,2015,standard,year) =G= 204.6269 ; (LHS = 0, INFES = 204.6269 ****)

COMMODITY_BALANCE_GT(Australia,refinery_demand,useful,2015,year)..  0.1135*ACT(Australia,crude_to_refinery,2015,2015,standard,year) =G= 252.615 ; (LHS = 0, INFES = 252.615 ****)

[…]

---- ACTIVITY_BOUND_LO  =G=  lower bound on activity summed over all vintages

ACTIVITY_BOUND_LO(Australia,coal_import,2015,standard,year)..  ACT(Australia,coal_import,2015,2015,standard,year) =G= 0.000114155251141553 ; (LHS = 0, INFES = 0.000114155251141553 ****)

ACTIVITY_BOUND_LO(Australia,gas_import,2015,standard,year)..  ACT(Australia,gas_import,2015,2015,standard,year) =G= 0.0114155251141553 ; (LHS = 0, INFES = 0.0114155251141553 ****)

ACTIVITY_BOUND_LO(Australia,oil_import,2015,standard,year)..  ACT(Australia,oil_import,2015,2015,standard,year) =G= 0.0273205479452055 ; (LHS = 0, INFES = 0.0273205479452055 ****)

ACTIVITY_BOUND_LO(Australia,coal_ppl,2015,standard,year)..  ACT(Australia,coal_ppl,2015,2015,standard,year) =G= 18.5111643835616 ; (LHS = 0, INFES = 18.5111643835616 ****)

ACTIVITY_BOUND_LO(Australia,gas_ppl,2015,standard,year)..  ACT(Australia,gas_ppl,2015,2015,standard,year) =G= 5.79554794520548 ; (LHS = 0, INFES = 5.79554794520548 ****)

ACTIVITY_BOUND_LO(Australia,oil_ppl,2015,standard,year)..  ACT(Australia,oil_ppl,2015,2015,standard,year) =G= 0.710045662100457 ; (LHS = 0, INFES = 0.710045662100457 ****)

ACTIVITY_BOUND_LO(Australia,bio_ppl,2015,standard,year)..  ACT(Australia,bio_ppl,2015,2015,standard,year) =G= 0.416221461187215 ; (LHS = 0, INFES = 0.416221461187215 ****)

ACTIVITY_BOUND_LO(Australia,hydro_ppl,2015,standard,year)..  ACT(Australia,hydro_ppl,2015,2015,standard,year) =G= 1.62517123287671 ; (LHS = 0, INFES = 1.62517123287671 ****)

ACTIVITY_BOUND_LO(Australia,wind_ppl,2015,standard,year)..  ACT(Australia,wind_ppl,2015,2015,standard,year) =G= 1.35420091324201 ; (LHS = 0, INFES = 1.35420091324201 ****)

ACTIVITY_BOUND_LO(Australia,csp_15h_ppl,2015,standard,year)..  ACT(Australia,csp_15h_ppl,2015,2015,standard,year) =G= 0 ; (LHS = 0)

ACTIVITY_BOUND_LO(Australia,utility_pv_ppl,2015,standard,year)..  ACT(Australia,utility_pv_ppl,2015,2015,standard,year) =G= 0.0317009132420091 ; (LHS = 0, INFES = 0.0317009132420091 ****)

ACTIVITY_BOUND_LO(Australia,roof_pv_ppl,2015,standard,year)..  ACT(Australia,roof_pv_ppl,2015,2015,standard,year) =G= 0.676141552511416 ; (LHS = 0, INFES = 0.676141552511416 ****)

[…]

**** Exec Error at line 2632: Equation infeasible due to rhs value

**** INFEASIBLE EQUATIONS ...

---- COMMODITY_BALANCE_GT  =G=  commodity supply greater than or equal demand

COMMODITY_BALANCE_GT(Australia,petroleum_products_demand,useful,2015,year)..  0 =G= 1.13686837721616E-13 ; (LHS = 0, INFES = 1.13686837721616E-13 ****)

COMMODITY_BALANCE_GT(Australia,fuel_oil_demand,useful,2015,year)..  0 =G= 2.8421709430404E-14 ; (LHS = 0, INFES = 2.8421709430404E-14 ****)

REMAINING 16 ENTRIES SKIPPED
aaronliuqy commented 3 years ago

Hi Paul

Thank you very much for your help. I didn't know that the .lst file contained information for troubleshooting. I have 2015 up to 2050 in the model with a 5-year time step.

I have been able to resolve most of the infeasibility besides this one. ---- CAPACITY_CONSTRAINT =L= capacity constraint for technology (by sub-annual time slice) I do not have sub-annual time slices in the model.

I have the new file attached. MESSAGE_run.zip Thanks Aaron

khaeru commented 3 years ago

I have been able to resolve most of the infeasibility besides this one. ---- CAPACITY_CONSTRAINT =L= capacity constraint for technology (by sub-annual time slice)

I have the new file attached. MESSAGE_run.zip

The file shows the same **** beside the COMMODITY_BALANCE_GT lines that I copied above, and then later:

**** Exec Error at line 2702: Equation infeasible due to rhs value

**** INFEASIBLE EQUATIONS ...

---- CAPACITY_CONSTRAINT  =L=  capacity constraint for technology (by sub-annual time slice)

CAPACITY_CONSTRAINT(Australia,coal_ppl,2015,2020,year)..  0 =L= -18.5111643835616 ; (LHS = 0, INFES = 18.5111643835616 ****)

CAPACITY_CONSTRAINT(Australia,gas_ppl,2015,2020,year)..  0 =L= -5.79554794520548 ; (LHS = 0, INFES = 5.79554794520548 ****)

CAPACITY_CONSTRAINT(Australia,bio_ppl,2015,2020,year)..  0 =L= -0.416221461187215 ; (LHS = 0, INFES = 0.416221461187215 ****)

CAPACITY_CONSTRAINT(Australia,hydro_ppl,2015,2020,year)..  0 =L= -1.62517123287671 ; (LHS = 0, INFES = 1.62517123287671 ****)

CAPACITY_CONSTRAINT(Australia,wind_ppl,2015,2020,year)..  0 =L= -1.35420091324201 ; (LHS = 0, INFES = 1.35420091324201 ****)

CAPACITY_CONSTRAINT(Australia,utility_pv_ppl,2015,2020,year)..  0 =L= -0.0317009132420091 ; (LHS = 0, INFES = 0.0317009132420091 ****)

CAPACITY_CONSTRAINT(Australia,roof_pv_ppl,2015,2020,year)..  0 =L= -0.676141552511416 ; (LHS = 0, INFES = 0.676141552511416 ****)

REMAINING 27 ENTRIES SKIPPED

Notice 27 compared to 16—this means there are now more infeasibilities, not fewer.

I have notified my colleagues, so if this is a well-known general hurdle in limited-foresight models, with a well-known solution, they may leave a comment.

In general, though, we do not (for lack of resources) offer free support for every possible model(s)/parametrizations that a user might create using the MESSAGEix framework.