BYU-PRISM / GEKKO

GEKKO Python for Machine Learning and Dynamic Optimization
https://machinelearning.byu.edu
Other
594 stars 104 forks source link

Solution incorrect with 1 time step and IMODE=7 #125

Open APMonitor opened 3 years ago

APMonitor commented 3 years ago

Solution is not reported correctly when there is one time step with IMODE=7. Example:

from gekko import GEKKO
import numpy as np
m = GEKKO()
m.time = np.linspace(0, 5, 2)
x = m.Var(1)
m.Equation(x.dt() == 1)
m.options.IMODE = 7
m.options.SOLVER = 2
m.solve(disp=False)
print(x.value)

Produces [1.0,1.0] when the answer should be [1.0,6.0].