Questions tagged [gekko]

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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
8 views

GEKKO IPOPT trajectory propagation

I am trying to propagate a spacecraft to optimize the time of flight using IPOPT in GEKKO/Python. Here is the code for my GEKKO model: m = GEKKO() #manipulating variables and initial guesses al_a = m....
pbhuter's user avatar
  • 373
0 votes
0 answers
40 views

GEKKO: Access Violation or Connection Variable A Not Found Errors for bsplines

I have a model with starting values for fluid state. Basically, I want to use CoolProp in my model to calculate the state variables (a follow-up of this question). When I try to calculate the pressure ...
Visitor's user avatar
  • 15
1 vote
0 answers
19 views

How can I optimise a trajectory to pass through waypoints in GEKKO?

My goal is to calculate the optimal trajectory of a fixed wing drone so that it reaches a series of specified x coordinates (eg. [150, 0]). I have tried a couple of approaches to enforce the waypoint ...
fwg's user avatar
  • 23
1 vote
1 answer
32 views

Gekko seems to ignore an equation MINLP

I am using Gekko (latest version as of September 2023) to solve the following MINLP problem. For the problem with constraints in Latex format see here: $\max_{x} \sum_{i=1}^{K} \sum_{j=1}^{N}x_i p_i ...
Gabriele Vecchio's user avatar
1 vote
1 answer
38 views

setting a lower bound constraint based on condition in gekko

I am trying to set up something similar to the facility location problem using gekko in python. I'm trying to minimize the distance between a set of facilities and corresponding counties while ...
finman69's user avatar
  • 301
1 vote
1 answer
31 views

GEKKO / IPOPT - NL Optimization becomes unfeasible because of a change in exponent

I am attempting to run a dynamic optimization model in discrete time with GEKKO and IPOPT (v3.10.2). My model is the following : from gekko import GEKKO import numpy as np # Simulation time T = 5 ...
GaL's user avatar
  • 41
0 votes
0 answers
26 views

How does GEKKO integrals choose the variable to be integrated?

I am building an optimization model where the objective function features one variable that needs to be integrated, while another variable is part of the integrated function, whithout being itself ...
GaL's user avatar
  • 41
0 votes
0 answers
12 views

Intermediate Arrays in GEKKO

If I have an optimization problem with a grid, is it better to create arrays of variables or intermediates?. By "better" I am referring primarily to performance with a secondary interest in ...
D.J. P.'s user avatar
  • 98
0 votes
0 answers
27 views

Python GEKKO: How to express contraints with random variables in gekko?

I spent a time trying to solve the following problem with gekko, but hard to tell if I am writting the codes right. I am saying this, because the problem become infeasible when I decrease a bit the ...
Ineza's user avatar
  • 1
0 votes
0 answers
55 views

Python GEKKO: Right use of 2D Intermediates

I have recently asked a about modeling a plug flow reactor with a large reaction network using GEKKO where I had problems with the intermediate calculations. I now tried to use the m.Intermediate and ...
MoDi's user avatar
  • 11
1 vote
1 answer
68 views

Python GEKKO: Modeling large chemical reaction network in plug flow reactor

I have a chemical reaction network including 65 reactions and 21 chemical species and I wanted to use GEKKO to model a simple plug flow reactor or to be more precise use GEKKO to solve the resulting ...
MoDi's user avatar
  • 11
1 vote
1 answer
21 views

Python Gekko dynamic optimisation - set constraint at final timestep

I have been working on a similar problem as in How can I speed up my optimization with Gekko?. The solution provided with IMODE= 6 has been very useful. So thank you. I have trying to expand the model ...
rickwol's user avatar
  • 35
1 vote
1 answer
28 views

Why does Gekko_NN_TF add so many degrees of freedom?

I am using Gekko for trajectory optimisation. The dynamics of my system are being modelled by a NN and wrapped for Gekko. In the minimal example below I am approximating a sinusoid with the NN. Using ...
fwg's user avatar
  • 23
1 vote
1 answer
25 views

How to express constraints involving array slicing by GEKKO variables?

I'm trying to solve a balls-in-bins-type problem using Gekko: I have N bins that t items will be thrown into following some distribution I need to 1) group the slots into k buckets 2) decide how many ...
Ryan Lehmkuhl's user avatar
1 vote
1 answer
35 views

Gekko solutions not found while trying to implement an elastic net regression

I am presently trying to build a elastic net regression model by using Gekko. I'm using Gekko instead of sklearn etc. because I'd also need to implement additional constraints on my variable ...
ArniBandyo's user avatar
1 vote
1 answer
25 views

Minimize value by manipulating variables in GEKKO+Python

This is an extension of this question. I want to minimize the delta-V (impulse) by manipulating the launch date, flyby date, and arrival date. These are defined as my manipulation variables as follows:...
pbhuter's user avatar
  • 373
1 vote
1 answer
46 views

Gekko differentiation with Coolprop

I am trying to solve a differential problem with Gekko for the first time. I have defined the parameters with CoolProp as suggested here: Gekko and CoolProp I would like to have a nice plot of T over ...
Visitor's user avatar
  • 15
2 votes
1 answer
26 views

GEKKO Python + IPOPT minimize delta-V

I have the following as my GEKKO model in Python: # Initialize model m = GEKKO() # Manipulating variables and initial guesses launch = m.MV(value = np.array([2460310.5, 0, 0]), lb = np.array([2460310....
pbhuter's user avatar
  • 373
2 votes
1 answer
18 views

Python GEKKO Using Manipulation Variables

Using Python GEKKO with IPOPT for Poliastro/Astropy, I have the following: # Manipulating variables and initial guesses launch = m.MV(value = 2460159.5, lb = 2460159.5, ub = 2460525.5) launch.STATUS = ...
pbhuter's user avatar
  • 373
4 votes
1 answer
20 views

GEEKO Result explanation

would you mind sparing some time explaining why the obj is zero here in some iterations? tcstd and tdstd is min-max standardize of tc and td. I want to minimize tcstd*tdstd so the value of objective ...
kennnn's user avatar
  • 83
2 votes
1 answer
31 views

Using GEKKO for switch mode power electronics circuit

I recently came across GEKKO and APMonitor when I looked into python toolkits for solving systems of differential algebraic equations that arise from modelling switch mode power supply circuits like a ...
Erik Iverson's user avatar
2 votes
1 answer
38 views

Python Gekko Parameter Estimation: too long computational time because of "Dynamic Init C"

I have coded a parameter estimation of a 5-state Resistor-Capacitor (RC) model of a large building through Python GEKKO using 5 differential equations in MHE mode (IMODE 5). The code works fine but ...
Giulio Tonellato's user avatar
2 votes
1 answer
29 views

There is an python code to solve an optimal control problem but I don't get the solution. I don't what is wrong

The goal is to minimise the compartment M_u and F_u at the end and maximize M_i and F_i. My function objective is: In LaTeX: $J(u)=M_u^2+F_u^2+ \int_0^T(Mi+Fi)u^2dt$ the ode system to control is the ...
Nash's user avatar
  • 21
2 votes
1 answer
27 views

Non-linear equations in GEKKO with constant input range and iterative initial values

I'm trying to solve non-linear equations in GEKKO using bounds and initial values. The following example illustrates two main problems I'm trying to solve for a larger system of non-linear equations. ...
itedin's user avatar
  • 23
2 votes
1 answer
19 views

Ordering intermediate variables in Gekko

I am writing a python code to solve a MINLP problem in Gekko. I have an independent variable x and a list of intermediate variables Int=[Int_1,Int_2,...Int_n], which are functions of x. I would like ...
huang mary's user avatar
2 votes
1 answer
35 views

Access decision variable value in function outside objective function Gekko

I need to access the decision variable outside the objective function. I have the following. tc_var = {} for index in index_f_a: tc_var[index] = m.Var(value=25, name='tc_var_{}'.format(index), lb=...
Rita s's user avatar
  • 55
1 vote
1 answer
42 views

Grey-box parameter estimation with GEKKO (@error: Insufficient Model)

I am using GEKKO to estimate the parameters of a thermal storage tank. I divided the tank into 20 isothermal layers and have written the energy balance for each. The unknown parameters are the thermal ...
nagpalh's user avatar
  • 51
2 votes
1 answer
95 views

Gekko is taking too long to solve very complex MINLP problem

I am trying to solve a MINLP model where I have people that have different schedules and can perform different tasks, and there is a maximum of tasks that each can perform at each schedule, according ...
Rita s's user avatar
  • 55
2 votes
0 answers
48 views

Solving for weights as coefficients using linear optimization in Python

I have a numpy array containing x variables and a y variable that I'd like to use to calculate coefficients on where each coefficient is between 0 and 1 and the sum of all the weights equals 1. How ...
finman69's user avatar
  • 301
2 votes
1 answer
47 views

Compiling Gekko with auto-py-to-exe Python

My app starts in remote="False" , m.options.SOLVER=3 mode and works fine in vscode. I needed to convert to exe file. Auto-Py-To-Exe can generate an exe file from a Python program. I managed ...
mohammad's user avatar
1 vote
1 answer
58 views

Multiple linear regression with GEKKO

Okay, so I need to complete a linear regression in which I fit predicted histograms to an experimental set. The relationship must be linear, and I know for a fact that there are possible solutions. ...
Sakshi Krishna's user avatar
2 votes
1 answer
32 views

Usage of if2/if3 to create prioritization of variables

I want to create a constraint that introduces ordering between variables. Use case: variable 1 -> Door_1 variable 2 -> Door_2 All doors have floating point positions that can range from 0 to ...
Saheli De's user avatar
3 votes
1 answer
60 views

Getting solution as nan for mixed integer non linear programming problem with objective function as a fraction

I wanted to maximize gross profit margin (total profit/total revenue) with binary variables, say whether products will be in the mix or not by that variables will be 1 or 0 (binary), trying to solve ...
soumyajt's user avatar
2 votes
1 answer
64 views

GEKKO (Python) giving incorrect solution

Consider the following GEKKO code: import numpy as np from gekko import GEKKO import matplotlib.pyplot as plt # Build model #initialize GEKKO model m = GEKKO() m.options.solver = 1 # Seed np....
DuttaA's user avatar
  • 913
2 votes
1 answer
43 views

Python gekko line break in equation definition

I'm currently implementing the Galerkin-Method for finite Elements by hand and using python gekko to solve the resulting non-linear algebraic equation system. This creates no issues for small systems ...
The_One_And_Only's user avatar
2 votes
1 answer
24 views

Why does my gekko ARX simulation start with unreasonable values?

I used gekko sysid to model a process with 5 MV's and 4 CV's. I want to simulate the real process and it does fairly well, except at the beginning. Even with a good initial value for CV's, the plots ...
Erik Hobson's user avatar
2 votes
1 answer
31 views

Constraint On Binary Variable Not Always Holding in Gekko

I am creating a non-linear program in Python using the Gekko package. The program includes a constraint of the form: m.Equation(i <= M*q) where i is a decision variable, M is a large constant (...
Dragonslayer's user avatar
2 votes
1 answer
60 views

Using B-spline method of the form z = f(x, y) to fit z = f(x)

As a potential solution to this question, how could one coerce GEKKO's m.bspline method which builds 2D B-splines in the form z = f(x, y) to build 1D B-splines in the form z = f(x)? More specifically, ...
Florent H's user avatar
  • 323
2 votes
1 answer
49 views

How to avoid creating many binary switching variables in GEKKO

I am solving for 14 variables by minimizing on the order of thousands of equations with IMODE = 3 in GEKKO. Each equation is the squared error between the true response and the prediction of a P-...
Florent H's user avatar
  • 323
2 votes
1 answer
30 views

Gekko - Chemical Library - How do I get the list of available component?

I did some test with the chemical library in Gekko. I wanted to see if I can use it with some component i'm working on right now. The test is just to try to get molecular weight for now. Here what I ...
Claquettes-Sandales's user avatar
3 votes
2 answers
42 views

Does anyone see where the error in the following GEKKO-IPOPT nonlinear optimization problem is?

In my code, I get the following error when running: Exception: @error: Equation Definition Equation without an equality (=) or inequality (>,<) ((((((((((-cos(v4)))*(sin(v5)))-((((sin(v4))*(...
pbhuter's user avatar
  • 373
2 votes
1 answer
68 views

How to use If...else in lambda with gekko

The scenario is the following: I want to minimalize the cost of the running motors. I have X number of motors, each have a lower and an upper bound. It can not go over the upper bound and it can't go ...
Miguff's user avatar
  • 45
2 votes
1 answer
44 views

Gekko not finding solution to non-linear program unless I predefine values of integer variables

I'm currently using Gekko to solve a non-linear program. The program involves sending some input volume through multiple exchanges, and every exchange along the way requires users to pay a one-time ...
Dragonslayer's user avatar
2 votes
1 answer
41 views

How to implement OR constraint in GEKKO

I have an optimization problem, that I have to find the the lowest cost of the given motors. And there is a constraint that, the motor either run or doesn't run. But if it runs, it has to reach the ...
Miguff's user avatar
  • 45
2 votes
1 answer
71 views

Using the predict() methods of fitted models with gekko

Many model-fitting Python packages have a predict() method, which outputs a prediction of the fitted model given observations of the predictor(s). Question: How would I use these predict() methods to ...
Florent H's user avatar
  • 323
1 vote
1 answer
59 views

Increase the accuracy of GEKKO solver

I am working on an optimization problem and I am using APOPT to solve such a problem, but the optimizer does not return an optimal solution, especially when the number of variables is a bit high (more ...
Ziad's user avatar
  • 83
2 votes
1 answer
23 views

Optimization of Hamiltonian system of a double spherical pendulum with gekko. Works without opt vars, no solution when trying to actually optimize

I am trying to optimize a set of equations simulating pendulums with springs between the initial vector and eachother, in R^3. It is actually a system of matrices and vectors, but I have written it ...
Petter's user avatar
  • 81
2 votes
1 answer
51 views

Speed up Gekko when minimizing many equations with interactive variables

I am using gekko to solve for 14 variables by minimizing around 10,000 equations with IMODE=3. Each equation is the squared error between a response y and the output of a polynomial model at row i in ...
Florent H's user avatar
  • 323
2 votes
1 answer
49 views

Why does GEKKO return a decimal value for an integer variable in my optimization code?

Why does GEKKO optimisation return a decimal value for an Integer variable? Hello everyone, With my GEKKO code I want to optimise a cutting pattern, with the maximum surface area of rectangles in the ...
Vincente's user avatar
2 votes
2 answers
43 views

Is there a way to handle zero over zero issues when using Gekko to solve systems of equations?

I am using gekko to (try) to solve a system of equations. I run into an issue as a type of term in my equations is m.asin(q1.T@q2)/m.sqrt(1-(q1.T@q2)**2), where q1 and q2 are unit vectors in R3. When ...
Petter's user avatar
  • 81

1
2 3 4 5
17