{"id":9004,"library":"gekko","title":"GEKKO Optimization Suite","description":"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.","status":"active","version":"1.3.2","language":"en","source_language":"en","source_url":"https://github.com/BYU-PRISM/GEKKO","tags":["optimization","machine learning","dynamic systems","control","DAE","NLP","mathematical programming"],"install":[{"cmd":"pip install gekko","lang":"bash","label":"Install GEKKO"}],"dependencies":[{"reason":"Used for numerical operations and often implicitly required for data handling.","package":"numpy","optional":false},{"reason":"Optional extension for interfacing with Pyomo models.","package":"pyomo","optional":true},{"reason":"Optional integration for Gaussian Process Regression (GPR) models in ML module.","package":"gpflow","optional":true},{"reason":"Optional integration for various tree-based and other ML models.","package":"scikit-learn","optional":true}],"imports":[{"symbol":"GEKKO","correct":"from gekko import GEKKO"}],"quickstart":{"code":"from gekko import GEKKO\n\nm = GEKKO() # Initialize model\n\n# Define variables with initial guess and bounds\nx = m.Var(value=1, lb=0, ub=4)\ny = m.Var(value=1, lb=0, ub=4)\n\n# Define equations (constraints)\nm.Equation(x + y == 3)\nm.Equation(x**2 + y**2 >= 5)\n\n# Define objective function (to minimize)\nm.Minimize((x-2)**2 + (y-1)**2)\n\n# Solve the optimization problem\nm.solve(disp=False) # disp=False suppresses solver output\n\n# Print results\nprint(f\"Optimal Solution: x = {x.value[0]}, y = {y.value[0]}\")\nprint(f\"Optimal Objective: {m.options.objfcnval}\")","lang":"python","description":"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."},"warnings":[{"fix":"To explicitly use the public server for solving, initialize the model with `m = GEKKO(remote=True)`.","message":"The default behavior for solving models changed from remote (cloud server) to local execution (`remote=False`). Users accustomed to models running on public servers will now have models solve locally by default.","severity":"breaking","affected_versions":">=1.3.1"},{"fix":"Replace `math.exp(x)` or `np.sin(y)` with `m.exp(x)` or `m.sin(y)` where `x` and `y` are GEKKO variables. Direct use of `math` or `numpy` functions will typically result in `AttributeError` or `TypeError`.","message":"When defining equations or objective functions, use GEKKO's symbolic math operations (e.g., `m.exp()`, `m.sin()`) rather than standard Python `math` or `numpy` functions directly on GEKKO variables. GEKKO performs automatic differentiation, which requires its internal representations.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If experiencing solver issues or needing specific solvers, consider using `m = GEKKO(remote=True)` to leverage the public server, or consult GEKKO documentation for specific local solver bundles for your OS/architecture.","message":"Local solver availability and performance can vary by operating system and architecture. Some advanced solvers (like IPOPT for Linux/macOS) are often only available via the `remote=True` option due to distribution size or licensing restrictions.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Simplify your model by reducing variables or equations, splitting the problem into sub-problems, or using a remote server (`remote=True`) which might have increased limits. You may also need to check model formulation for redundant expressions.","message":"Complex models with many equations or variables can encounter a 'Max Equation Length' error, indicating the model is too large for the current configuration.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Run `pip install gekko` in your terminal or environment.","cause":"The GEKKO library is not installed in the current Python environment.","error":"ModuleNotFoundError: No module named 'gekko'"},{"fix":"Examine `m.options.APPSTATUS` and `m.options.APPINFO` for specific error codes. Try different initial values for variables, relax constraints, or switch to a different solver (`m.options.SOLVER = 1` for APOPT, `3` for IPOPT if available). Set `m.options.DEBUG=1` or `disp=True` during `m.solve()` for more verbose output.","cause":"The solver failed to find a feasible solution or reached maximum iterations. This could be due to an ill-posed problem, infeasible constraints, poor initial guesses, or solver limitations.","error":"Exception: @error: Solution Not Found. Check model formulation and solver options."},{"fix":"Replace `math.function(m.Var)` or `np.function(m.Var)` with `m.function(m.Var)`. For example, use `m.exp(x)` instead of `math.exp(x)`.","cause":"Attempting to use standard Python `math` or `numpy` functions directly on GEKKO symbolic variables. GEKKO variables require GEKKO's own symbolic operations for automatic differentiation.","error":"AttributeError: 'GEKKO' object has no attribute 'exp' (or 'sin', 'log', etc.)\nTypeError: object of type 'int' has no len() (or similar with numpy/math functions)"},{"fix":"Ensure GEKKO is correctly installed and its executables are present. If running on an unsupported architecture for local solve, or if executables are corrupted, consider using `m = GEKKO(remote=True)` to offload solving to the public server. Reinstalling GEKKO (`pip install --upgrade gekko`) might also resolve missing executables.","cause":"GEKKO is configured for a local solve (`remote=False`), but the necessary APM solver executables are missing or cannot be found in the specified temporary directory or system PATH.","error":"GEKKO: Invalid APM server or file. Check if 'apm.exe' (Windows), 'apm' (Linux), 'apm_mac' (MacOS) exists in C:\\Users\\...\\AppData\\Local\\Temp\\..."}]}