Previously, I had committed the solver extension module to link up with amplpy allowing access to more solvers - see https://github.com/BYU-PRISM/GEKKO/pull/176. This PR extends that module to solve through Pyomo. Pyomo interfaces with ASL (AMPL Solver Library) and so can provide the same functionality as AMPL, however it is completely open-source, so it does not have any limits and can be used commercially under the BSD license.
This PR maintains compatible with the previous version of the solver extension module, however, a lot has been refactored in the codebase:
Split gk_solver_extension.py into 3 files:
gk_solver_extension.py: Holds the code for running the different converter modules, and an abstract base GKConverter class that the converters need to implement. This base class reduces repeated code and provides a template if this module were to be extended again in the future.
gk_solver_extension_amplpy.py: Holds the amplpy converter - changed to fit with the new abstract base converter class.
gk_solver_extension_pyomo.py: Holds the pyomo converter
Modified the option m.options.SOLVER_EXTENSION:
0 / GEKKO (default): Solver extension off, solve GEKKO as normal
1 / AMPL / AMPLPY: Solver extension on, solve through amplpy - maintains compatibility with previous version
2 / PYOMO: Solver extension on, solve through pyomo
Update documentation
Rewrote a lot of docs/solver_extension.rst to include the pyomo converter
Updated docs/global.rst - SOLVER_EXTENSION option in global options
In order to keep GEKKO lightweight, the two converters continue to not require amplpy or pyomo to be installed, unless the solver extension module is used.
The Pyomo converter supports about the same amount of model building functions as the amplpy converter, and definitely all the core optimization functions. It's missing a few more pre-built objects (didn't work straight out of the box as with amplpy), but hopefully this should be OK for now. It also currently does not support dynamic modelling (time, derivatives, etc), however, this could be added with Pyomo's DAE (differential algebraic equations) module in the future.
Previously, I had committed the solver extension module to link up with
amplpy
allowing access to more solvers - see https://github.com/BYU-PRISM/GEKKO/pull/176. This PR extends that module to solve throughPyomo
. Pyomo interfaces with ASL (AMPL Solver Library) and so can provide the same functionality as AMPL, however it is completely open-source, so it does not have any limits and can be used commercially under the BSD license.This PR maintains compatible with the previous version of the solver extension module, however, a lot has been refactored in the codebase:
gk_solver_extension.py
into 3 files:gk_solver_extension.py
: Holds the code for running the different converter modules, and an abstract baseGKConverter
class that the converters need to implement. This base class reduces repeated code and provides a template if this module were to be extended again in the future.gk_solver_extension_amplpy.py
: Holds theamplpy
converter - changed to fit with the new abstract base converter class.gk_solver_extension_pyomo.py
: Holds thepyomo
converterm.options.SOLVER_EXTENSION
:0
/GEKKO
(default): Solver extension off, solve GEKKO as normal1
/AMPL
/AMPLPY
: Solver extension on, solve throughamplpy
- maintains compatibility with previous version2
/PYOMO
: Solver extension on, solve throughpyomo
docs/solver_extension.rst
to include the pyomo converterdocs/global.rst
-SOLVER_EXTENSION
option in global optionsIn order to keep GEKKO lightweight, the two converters continue to not require
amplpy
orpyomo
to be installed, unless the solver extension module is used.The Pyomo converter supports about the same amount of model building functions as the amplpy converter, and definitely all the core optimization functions. It's missing a few more pre-built objects (didn't work straight out of the box as with amplpy), but hopefully this should be OK for now. It also currently does not support dynamic modelling (time, derivatives, etc), however, this could be added with Pyomo's DAE (differential algebraic equations) module in the future.