from gekko import GEKKO import numpy as np import matplotlib.pyplot as plt t = np.linspace(0,1,101) m = GEKKO(remote=False); m.time=t d = m.Param(np.cos(2*np.pi*t)+3) g = m.Var(d[0]) J = m.CV(0) J.STATUS=1; J.SPHI=J.SPLO=0 J.WSPHI=1000; J.WSPLO=1 r = m.MV(0,lb=-1,ub=1); r.STATUS=1 m.Equations([g.dt()==r, J==d-g]) m.options.IMODE=6; m.solve() plt.plot(t,g,'b:',label='Production') plt.plot(t,d,'r-',label='Demand') plt.plot(t,r,'k--',label='Ramp Rate') plt.legend(); plt.grid(); plt.show()