# gekko | A bitcoin trading bot written in node - https://gekkowizbit/ | Cryptocurrency library

## kandi X-RAY | gekko Summary

## kandi X-RAY | gekko Summary

Gekko is a Bitcoin TA trading and backtesting platform that connects to popular Bitcoin exchanges. It is written in JavaScript and runs on Node.js.

### Support

### Quality

### Security

### License

### Reuse

### Top functions reviewed by kandi - BETA

- Converts a number to a number .
- Computes the linest .
- create a humanizer
- apply highlight to the canvas
- Calculates days in the current date .
- Ensures that a and b are valid
- Convert time time to ISO 8601 format
- Implementation of i . e .
- Day of a language list
- Scale values by y axis .

## gekko Key Features

## gekko Examples and Code Snippets

## Community Discussions

Trending Discussions on gekko

QUESTION

I want to solve linear programming with Python. The model is:

...ANSWER

Answered 2022-Feb-24 at 19:57As I mentioned in the comment section, simply changing `sum(x1 , x2)`

to `x1 + x2`

should solve the issue. Also, you should try Solving the `model`

with `model.solve()`

! so:

QUESTION

I am seeking to find optimal control (aoa and bank angle) to maximize cross range for a shuttle type reentry vehicle using Gekko. Below is my code currently and I am getting a "Solution not found" with "EXIT: Maximum Number of Iterations Exceeded". The simulation assumes a point mass with a non-rotating earth frame. The EOMS are 6 coupled, non-linear ODEs. I have tried using different solvers, implementing/removing state and control constraints, increasing maximum number of iterations, etc. I am not confident with my setup and implementation of the problem in Gekko and am hoping for some feedback on what I can try next. I have tried to follow the setup and layouts in APMonitor's Example 11. Optimal Control with Integral Objective, Inverted Pendulum Optimal Control, and Example 13. Optimal Control: Minimize Final Time. Solutions I'm seeking are below.

Any help is very much appreciated!

...ANSWER

Answered 2022-Jan-14 at 04:17I got a successful solution by decreasing the final time (max=0.04 for successful solution) and rearranging the equations to avoid a possible divide-by-zero:

QUESTION

I'm having trouble understanding an error message I'm getting from my GEKKO model.

For context, this model is supposed to optimize the gas spring force and dimension parameters of a gas-spring assisted door to minimize the operator force required to close the door. My intent is to calculate the required force at a series of angles between 0 and 90 degrees, then sum the absolute value of the force at all angles and minimize that value. There is also a constraint on the gas spring length so the optimization doesn't come up with unrealistic dimension parameters. I've defined the force and other values that need to be computed at each angle as lists of Intermediate variables.

The error appears to be related to one of these lists of Intermediate variables, but I don't know how to interpret "Position: 2" in the error message, let alone "Error in syntax of function string". I've searched in some other answers on here, but I haven't found a clear answer on how to use this position information to troubleshoot the model. What is the message trying to tell me?

...ANSWER

Answered 2022-Jan-15 at 05:44One way to locate the error is to open the run directory and inspect the text model file `gk_model0.apm`

.

QUESTION

everyone and Professor John

We are using gekko to do MPC on tclab simulation model. We try to emulate the situation that on site the actuator deviates from MV calculated by gekko because of the problems of actuator.

If the deviation is in the fixed pattern, for example a quite big constant deviation happens for a long time and may come back then work well for a long time. We can deal with it by extra logic to detect deviation and add the deviation value to the mv calculated by gekko.

one day, I noticed that there could be meas for MV when fstatus = 1. So I gave it a try. I hope gekko could deal with the deviation by itself. for example, if mv from gekko is 10 and the measurement is 5 and the pattern continues, gekko may spit out a higher MV value than 10, for example 15 and measurement is 10.

In the simulation, when I set MV's fstatus=1, the MV's curve becomes to :

q1a is the q1 with manual deviation. In the above pic, q1a == q1. It looks like gekko takes one more step thinking about the MV's effect.

In the below pic, there are two times range, one with "q1a == q1+20" and the other with "q1a == q1 -20". q1a's value is fed to tclab and mv(q1)'s meas.

I do not understand why the q1 calculated by gekko is going up or going down when meas deviates despite the t1 is going far away from sp.

**Edit: Example Code**

See the screen shot below from "normal" HMI. The sluggish MV disappeared, so it maybe caused by bug in my code. But the up-going or down-going could still be seen. See my code below:

...ANSWER

Answered 2021-Sep-03 at 18:20Is the `FSTATUS`

also ON for the CVs such as `t1.FSTATUS=1`

? If you update the measurement such as:

QUESTION

ANSWER

Answered 2021-Aug-18 at 16:17Use `m.integral`

or `m.vsum()`

to create a time weighted summation or vertical summation along the time direction. Here is a solution that replicates the exact solution.

QUESTION

I need to solve 1D plane flight optimal control problem. I have a plane that is 1000m high. I need it to travel certain distance (x) forward along x-axis while minimizing fuel consumption. And when it achieves travels that distance x I need program to stop. This function controls it: `m.Equation(x*final<=1500)`

.

And for some reason during the simulation my x value does not want to go higher than 1310.

How could I fix that "blockage"?

My gekko script:

...ANSWER

Answered 2021-Apr-27 at 04:13The lower bound on `Tcontr`

is preventing the `x`

value from going above 1310. Setting the lower value to 0.1 improves the final value of `x`

to 2469.76 if the constraint `m.Equation(x*final<=1500)`

is removed.

QUESTION

I want to minimize the cost for achieving a given set of non-negative integer values b that are computed linearly from two sets of non-negative integer variables x, y in GEKKO. If have stated my problem in a way, that the b's are constraints on the x & y. My cost function is non-linear: quadratic using a conditional/minimum. In addition to these standard constraints, I have a constraints which requires the number of non-zero elements in x is at least as large as the largest element in x (e.g. that the L0-norm is equal to the LInifity-norm).

My difficulty is now twofold, since I'm fairly new to optimization and a novice in GEKKO.

- I saw that GEKKO supports numpy arrays which would make the problem statement rather concise, but I struggle to get it to work - resulting in a lot of list comprehensions instead of vectorized operations.
- I managed to define the L0-norm constraint and GEKKO actually runs with it, but it fails to find a solution. I recognize that L0 problems are really hard (e.g. combinatoric), but somehow the solution is fairly easy to find by "hand". I feel just that I'm doing something wrong.

I would appreciate any help! Here is what I have done so far:

...ANSWER

Answered 2021-Jan-24 at 15:18Gekko uses gradient-based solvers so the equations shouldn't change iteration-to-iteration. There is a way to get the count of non-zero variables that is compatible with gradient based solvers. Here is an alternative form to give you count and max for your `x`

vector. This uses `if3`

, `max3`

, and `min3`

as found in the documentation on Model Building Functions with logical conditions.

QUESTION

I need to run an optimization for 100k to 500k variables, but it gives me max equation length reached an error. Can anyone help me out to set up this problem? Time is not a constraint as long as it takes 3-4 hours to run, it's fine.

...ANSWER

Answered 2021-Jan-23 at 15:57When creating a question, it is important to have a Minimal Example that is complete. Here is a modification that creates a random DataFrame with `n`

rows.

QUESTION

ANSWER

Answered 2021-Jan-13 at 13:52The optimal control problem as it is currently written is unbounded. The value of `c`

will go to infinity to maximize the function. I set an upper bound of `100`

on `c`

and the solver went to that bound. I reformulated the model to reflect the current problem statement. Here are a few suggestions:

- Use the
`m.integral()`

function to make the model more readable. - Initialize
`c`

at a value other than`0`

(default). You may also want to set a lower bound with`c>0.01`

so that`m.log(c)`

is not undefined if the solver tries a value`<0`

. - Only use Gekko functions inside Gekko equations such as with
`factor = m.exp(rate)`

. Use`factor = np.exp(rate)`

instead unless it is in a Gekko equation where it can be evaluated. - Include a plot of the exact solution so that you can compare the exact and numerical solution.
- Use
`m.options.NODES=3`

with`c=m.MV()`

and`c.STATUS=1`

to increase the solution accuracy. The default is`m.options.NODES=2`

that isn't as accurate. - You can free the initial condition with
`m.free_initial(c)`

to calculate the initial value of`c`

.

QUESTION

I tried with this code and the result was `(2,2)`

. Obviously it's not true, since `(0,4)`

is a best solution. could you please tell me where is it the problem?

ANSWER

Answered 2021-Jan-02 at 23:29All of the solvers (`m.options.SOLVER`

with `1=APOPT`

, `2=BPOPT`

, `3=IPOPT`

) find the local maximum point `(2,2)`

with initial guess `(0,0)`

and other initial guesses as well. There are two local optima at `(0,4)`

and `(4,0)`

. This is a non-convex optimization problem. The solvers are nonlinear convex optimization solvers so they "should" find one of the local solutions. This problem reminds me of a saddle point problem if you rotate the graph to orient with the `x0=x1`

line. Optimizers can have problems with saddle points if there is no check for an indefinite Hessian.

Better initial guesses help the solver find the optimal solution such as `x0=1`

and `x1=3`

. Also, an upper bound `<1.999`

on one of the variables or a lower bound of `>2.001`

also finds the optimal value. The constraints limit the search region so that it is a convex optimization problem and avoids the saddle point.

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

## Vulnerabilities

## Install gekko

## Support

## Reuse Trending Solutions

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

Find more librariesStay Updated

Subscribe to our newsletter for trending solutions and developer bootcamps

Share this Page