Pyomo / pyomo

An object-oriented algebraic modeling language in Python for structured optimization problems.
https://www.pyomo.org
Other
2.01k stars 517 forks source link

Issue running pyomo via GAMS (using idaes models) #2446

Closed MAZamarripa closed 2 years ago

MAZamarripa commented 2 years ago

Summary

Pyomo GAMS writer is failing to convert IDAES models to GAMS code. potential issues: expressions are not included in the GAMS writer (example below "func_tau" showing error $140 "unknown symbol"

I get these errors: 34 c1.. x1 - ((647.096/func_tau((222.03374024716794), (101.325))) - (647.096/func_tau((0.05550843506179198x2), (0.001x3)))) =e= 0 ; $140,145 $8,37,409 8 ')' expected 37 '=l=' or '=e=' or '=g=' operator expected 140 Unknown symbol 145 Set identifier or quoted element expected 409 Unrecognizable item - skip to find a new statement *** looking for a ';' or a key word to get started again 35 c2.. x4 - ((647.096/func_tau((0.05550843506179198x5), (0.001*x6)))

Steps to reproduce the issue

run example attached (run_heat_exchanger.py)

Error Message

$ # Output message here, including entire stack trace, if available

Traceback (most recent call last): File ".\run_heat_exchanger.py", line 157, in add_options=['gams_model.optfile=1;']) File "C:\Users\ZAMARRIM.conda\envs\idaes\lib\site-packages\pyomo\solvers\plugins\solvers\GAMS.py", line 845, in solve raise RuntimeError("GAMS encountered an error during solve. " RuntimeError: GAMS encountered an error during solve. Check listing file for details.

Information on your system

Pyomo version: 6.4.0 Python version: 3.7.13 Operating system: Windows 10 How Pyomo was installed (PyPI, conda, source): via idaes extensions (I will guess via conda)

Solver (if applicable): GAMS Release: GAMS Studio 1.10.2 64 bit Build Date: May 13 2022 14:35:10 GAMS Release: 39.1.1 dbf03b78 WEX-WEI x86 64bit/MS Windows Release Date: 2022

Additional information

the attachment includes an idaes model that can be used to replicate the issue. run_heat_exchanger.zip

There are other issues that I observed during testing but cannot replicate with the small example.

Issue with Baron solver: failing to run Baron solver (see below) For information on BARON, see https://minlp.com/about-baron ERROR: Solver (baron) returned non-zero return code (3) ERROR: See the solver log above for diagnostic information. Traceback (most recent call last): File "c:/Users/ZAMARRIM/Documents/IDAES2/idaes_examples_run/run_heat_exchanger.py", line 164, in results = solver.solve(m, tee=True) File "C:\Users\ZAMARRIM.conda\envs\idaes\lib\site-packages\pyomo\opt\base\solvers.py", line 596, in solve "Solver (%s) did not exit normally" % self.name) pyomo.common.errors.ApplicationError: Solver (baron) did not exit normally

Issue with pyomo model: The pyomo model is running in GAMS (solving to optimal) but failing to return variable values from GAMS to Pyomo

--- DICOPT: Best integer solution found: 367758.749140 --- Reading solution for model GAMS_MODEL --- Executing after solve: elapsed 0:00:25.021 --- model.gms(277999) 90 Mb --- model.gms(287562) 90 Mb --- model.gms(403886) 90 Mb --- model.gms(417031) 90 Mb --- Putfile results C:\Users\ZAMARRIM\Documents\IDAES2\idaes_examples_run\temp\results.dat --- Putfile statresults C:\Users\ZAMARRIM\Documents\IDAES2\idaes_examples_run\temp\resultsstat.dat *** Status: Normal completion --- model.gms(417031) 86 Mb --- Job model.gms Stop 06/24/22 10:03:30 elapsed 0:00:25.265

GAMS WORKING DIRECTORY: temp

Traceback (most recent call last): File "c:/Users/ZAMARRIM/Documents/Github/project-pareto/pareto/strategic_water_management/run_strategic_model.py", line 139, in solve_model(model=strategic_model, options=options) File "c:\users\zamarrim\documents\github\project-pareto\pareto\strategic_water_management\strategic_produced_water_optimization.py", line 7509, in solve_model solve_MINLP_quality(model, opt) File "c:\users\zamarrim\documents\github\project-pareto\pareto\strategic_water_management\strategic_produced_water_optimization.py", line 7126, in solve_MINLP_quality results = SolverFactory(solver_source).solve( File "C:\Users\ZAMARRIM.conda\envs\pareto\lib\site-packages\pyomo\solvers\plugins\solvers\GAMS.py", line 852, in solve model_soln, stat_vars = self._parse_dat_results( File "C:\Users\ZAMARRIM.conda\envs\pareto\lib\site-packages\pyomo\solvers\plugins\solvers\GAMS.py", line 1222, in _parse_dat_results stat_vars[items[0]] = float(items[1]) IndexError: list index out of range (idaes) PS C:\Users\ZAMARRIM\Documents\IDA

mrmundt commented 2 years ago

Thanks, @MAZamarripa - this is a duplicate of #2440 (in that the issue is related to the newer version of GAMS). I'll add your comment to issue and will close this one.

mrmundt commented 2 years ago

@MAZamarripa - Looking into this, the issue is actually that this IDAES example uses external functions, which are not supported in BARON or GAMS. We have opened issue #2448 for this - for now, we do not have it on our radar to support ExternalFunction components.