GEKKO (pip install gekko) is a Python package for machine learning and optimization of mixed-integer and differential algebraic equations. It is coupled with large-scale solvers for linear, quadratic, nonlinear, and mixed integer programming (LP, QP, NLP, MILP, MINLP). Modes of operation include parameter regression, dynamic simulation, and nonlinear predictive control. GEKKO is an object-oriented Python library and is released under the MIT License.
Introduction
GEKKO is a Python software library for large-scale nonlinear optimization. It is designed to find (local) solutions of mathematical optimization problems of the form
min f(x)
x in R^n
s.t. g(dx/dt,x) <= 0
h(dx/dt,x) = 0
x_L <= x <= x_U
where f(x): R^n --> R
is the objective function,
g(dx/dt,x): R^n --> R^m
are the inequality constraint functions, and
h(dx/dt,x): R^n --> R^m
are the equality constraint functions. The vectors
x_L
and x_U
are the simple bounds on the variables x
. The
functions f
, g
, and h
can be nonlinear and nonconvex, but should
be twice continuously differentiable. The variables may be binary, integer,
differential, or continuous. GEKKO was created from
NSF grant #1547110 and is released under the MIT License.
Background
GEKKO is a Python package for machine learning and optimization of mixed-integer and differential algebraic equations. It is coupled with large-scale solvers for linear, quadratic, nonlinear, and mixed integer programming (LP, QP, NLP, MILP, MINLP). Modes of operation include parameter regression, data reconciliation, real-time optimization, dynamic simulation, and nonlinear predictive control. GEKKO is an object-oriented Python library to facilitate local execution of APMonitor. The original author of the package is Logan Beal and it is maintained by the BYU PRISM group.
GEKKO can be used on Linux/UNIX, Mac OS X, ARM, and Windows platforms and any other platform that runs Python.
Example
The following is the solution to the Hock Schittkowski benchmark problem #71.
from gekko import GEKKO
import numpy as np
m = GEKKO()
x = m.Array(m.Var,4,value=1,lb=1,ub=5)
x1,x2,x3,x4 = x
# change initial values
x2.value = 5; x3.value = 5
m.Equation(x1*x2*x3*x4>=25)
m.Equation(x1**2+x2**2+x3**2+x4**2==40)
m.Minimize(x1*x4*(x1+x2+x3)+x3)
m.solve()
print('x: ', x)
print('Objective: ',m.options.OBJFCNVAL)
Solution with IPOPT:
---------------------------------------------------
Solver : IPOPT (v3.12)
Solution time : 9.699999995063990E-003 sec
Objective : 17.0140171270735
Successful solution
---------------------------------------------------
Results
x1: [1.000000057]
x2: [4.74299963]
x3: [3.8211500283]
x4: [1.3794081795]
Related Links
APMonitor is run locally or as a web-service as a backend solution engine for GEKKO.
Documentation: Installation, options, and examples.
GitHub: Source code repository.
Online Course: GEKKO for machine learning and dynamic optimization
References: GEKKO and APMonitor references.
Wikipedia: Overview of GEKKO.