iiasa / message_ix

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

GAMS errored with return code 3: There was an execution error #626

Open PelinaP opened 2 years ago

PelinaP commented 2 years ago

My baseline solves, and two scenarios also solves when i run code but when i try another scenario with correct code, i get this error. I'm accessing message environment through anaconda navigator. Please assist me with this.

ModelError Traceback (most recent call last) Input In [14], in <cell line: 1>() ----> 1 scen.solve()

File ~\anaconda3\envs\message_env\lib\site-packages\message_ix\core.py:549, in Scenario.solve(self, model, solve_options, kwargs) 529 def solve(self, model='MESSAGE', solve_options={}, kwargs): 530 """Solve MESSAGE or MESSAGE-MACRO for the Scenario. 531 532 By default, :meth:ixmp.Scenario.solve is called with 'MESSAGE' as the (...) 547 :class:.GAMSModel. 548 """ --> 549 super().solve(model=model, solve_options=solve_options, **kwargs)

File ~\anaconda3\envs\message_env\lib\site-packages\ixmp\core\scenario.py:835, in Scenario.solve(self, model, callback, cb_kwargs, **model_options) 833 # Iterate until convergence 834 while True: --> 835 model_obj.run(self) 837 # Store an iteration number to help the callback 838 if not hasattr(self, "iteration"):

File ~\anaconda3\envs\message_env\lib\site-packages\message_ix\models.py:119, in GAMSModel.run(self, scenario) 116 optfile.write_text('\n'.join(lines)) 118 try: --> 119 result = super().run(scenario) 120 finally: 121 # Remove the optfile regardless of whether the run completed 122 # without error. The file may have been removed already by another 123 # run (in a separate process) that completed before this one. 124 # py37 compat: check for existence instead of using 125 # unlink(missing_ok=True) 126 if optfile.exists():

File ~\anaconda3\envs\message_env\lib\site-packages\ixmp\model\gams.py:296, in GAMSModel.run(self, scenario) 293 check_call(command, shell=os.name == "nt", cwd=self.cwd) 294 except CalledProcessError as exc: 295 # Do not remove self.temp_dir; the user may want to inspect the GDX file --> 296 raise self.format_exception(exc, model_file) from None 298 # Read model solution 299 scenario.platform._backend.read_file( 300 self.out_file, 301 ItemType.MODEL, (...) 306 var_list=as_str_list(self.var_list) or [], 307 )

ModelError: GAMS errored with return code 3: There was an execution error

Anaconda prompt doesnt give output Output of message-ix show-versions (base) C:\Users\energy> message-ix show-versions 'message-ix' is not recognized as an internal or external command, operable program or batch file.

OFR-IIASA commented 2 years ago

Hi Pelina, in order to see what is going on, you can look at two files. Both are located in your message_ix repository folder message_ix/model/:

  1. MESSAGE_run.log -> this file will provide a first glimpse of the log output resulting from the optimization process (CPLEX) which is normally also printed in the command-line window.
  2. MESSAGE_run.lst -> This provides more details related and is a log written by GAMS. If you have compilation errors for example, this would be the place to start looking.

I would believe that the issue you have is that CPLEX couldnt solve your scenario (infeasible). Therefore, if you are unsure what the reason is, you can look here for some guidance on how to start debugging infeasibilities.

PelinaP commented 2 years ago

I found that the issue is my demand and supply despite being equal. infeasibility row 'COMMODITY_BALANCE_GT(Zambia.Electricity.Secondary.2019.Jan)': 0 >= 0.0374603.

I am not sure how to solve this because my base generation for January is equal to the demand. Hence where is message calculating this imbalance?