GEKKO Optimization Suite

1.3.2 · active · verified Thu Apr 16

GEKKO is a Python package for machine learning and optimization of mixed-integer and differential algebraic equations (DAE) systems, coupled with large-scale solvers for various programming types (LP, QP, NLP, MILP, MINLP). It provides an object-oriented interface to the APMonitor optimization suite, supporting modes like parameter regression, dynamic data reconciliation, real-time optimization, dynamic simulation, and nonlinear predictive control. Currently at version 1.3.2, GEKKO is actively maintained with frequent releases and consistently sees over 100,000 downloads per month.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart defines a simple nonlinear programming (NLP) problem with two variables, two constraints, and an objective function. It initializes a GEKKO model, sets up the variables, equations, and objective, and then solves the problem, printing the optimal variable values and objective function value.

from gekko import GEKKO

m = GEKKO() # Initialize model

# Define variables with initial guess and bounds
x = m.Var(value=1, lb=0, ub=4)
y = m.Var(value=1, lb=0, ub=4)

# Define equations (constraints)
m.Equation(x + y == 3)
m.Equation(x**2 + y**2 >= 5)

# Define objective function (to minimize)
m.Minimize((x-2)**2 + (y-1)**2)

# Solve the optimization problem
m.solve(disp=False) # disp=False suppresses solver output

# Print results
print(f"Optimal Solution: x = {x.value[0]}, y = {y.value[0]}")
print(f"Optimal Objective: {m.options.objfcnval}")

view raw JSON →