BYU-PRISM / GEKKO

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

double free or corruption #76

Closed david-waterworth closed 4 years ago

david-waterworth commented 4 years ago

I've just started investigating GEKKO. I'm working through examples on the webpage (http://apmonitor.com/wiki/index.php/Main/GekkoPythonOptimization) - I'm getting the following error for "4 - Interpolation with Cubic Spline"

I've altered to run locally - it was giving my an HTTP timeout for remote. Locally it looks like some sort of exception being thrown by the solver? I'm using Python 3.6 on Linux (Ubuntu 18.04)

Error: double free or corruption (out)

Program received signal SIGABRT: Process abort signal.

Backtrace for this error:

0 0x6c278f

1 0x6aacd0

2 0x7f2a7e4f2f1f

3 0x7f2a7e4f2e97

4 0x7f2a7e4f4800

5 0x7f2a7e53d896

6 0x7f2a7e544909

7 0x7f2a7e54be74

8 0x5260ff

9 0x449776

10 0x449d6f

11 0x44816a

12 0x66d64f

13 0x4026ec

14 0x7f2a7e4d5b96

15 0x40275c

16 0xffffffffffffffff

from gekko import GEKKO
import numpy as np
import matplotlib.pyplot as plt  

xm = np.array([0,1,2,3,4,5])
ym = np.array([0.1,0.2,0.3,0.5,1.0,0.9])

m = GEKKO(remote=False)
m.x = m.Param(value=np.linspace(-1,6))
m.y = m.Var()
m.options.IMODE=2
m.cspline(m.x,m.y,xm,ym)
m.solve(disp=False)
#help(m.cspline)

p = GEKKO(remote=False)
p.x = p.Var(value=1,lb=0,ub=5)
p.y = p.Var()
p.cspline(p.x,p.y,xm,ym)
p.Obj(-p.y)
p.solve(disp=False)

plt.plot(xm,ym,'bo',label='data')
plt.plot(m.x.value,m.y.value,'r--',label='cubic spline')
plt.plot(p.x.value,p.y.value,'ko',label='maximum')
plt.legend(loc='best')
plt.show()
APMonitor commented 4 years ago

I did a little initial troubleshooting. It appears that this is only a problem on the apm executable that is compiled for Linux with a gcc compiler (gekko v0.2.7, apm v0.9.2). The public server executable (also Linux, apm v0.9.1) is compiled with an Intel Fortran compiler and the script also runs without error with the local Windows executable (apm v0.9.2). The gcc compilers are generally very good so it may be catching an errors with memory allocation so I'll run it again soon to look at those issues. Thanks for highlighting this problem.

david-waterworth commented 4 years ago

BTW The public server isn't timing out today - so that was unrelated.

APMonitor commented 4 years ago

I recompiled the local APM executable with Intel compilers and the problem is resolved. It will be in the next Gekko release (v0.2.8) or you can replace the apm executable manually in the gekko bin directory.

https://github.com/BYU-PRISM/GEKKO/blob/master/gekko/bin/apm

When the new version of Gekko is available, you can get the upgraded package with:

pip install gekko --upgrade