这是一个简单的延迟系统,或者说DDD
我相信当给出τ
时,参数k
可以用直接配置法估计.问题是如何用GEKKO做到这一点.
以下是我所做的:
首先,对系统进行了jitcdde
个包的仿真
from jitcdde import t, y, jitcdde
import numpy as np
# the constants in the equation
k = -0.2
tau = 0.5
# the equation
f = [
k*y(0, t-tau)
]
# initialising the integrator
DDE = jitcdde(f)
# enter initial conditions
DDE.constant_past([1.0])
# short pre-integration to take care of discontinuities
DDE.step_on_discontinuities()
# create timescale
stoptime = 10.5
numpoints = 100
times = np.arange(DDE.t, stoptime, 1/10)
# integrating
data = []
for time in times:
data.append( DDE.integrate(time) ) # The warning is due to small sample step, no worry
然后,做估算
# The sample is taken every 0.1s and the delay is 0.5s
# so ydelayed should be taken 5 steps before ydata
tdata = times[5:]
ydata = np.array(data)[5:]
ydelayed = np.array(data)[0:-5]
m = GEKKO(remote=False)
m.time = tdata
x = m.CV(value=ydata); x.FSTATUS = 1 # fit to measurement
xdelayed = m.CV(value=ydelayed); x.FSTATUS = 1 # fit to measurement
k = m.FV(); k.STATUS = 1 # adjustable parameter
m.Equation(x.dt()== k * xdelayed) # differential equation
m.options.IMODE = 5 # dynamic estimation
m.options.NODES = 5 # collocation nodes
m.solve(disp=False) # display solver output
k = k.value[0]
显示k=-0.03253
,但真实值是-0.2
.如何修复身份识别?