#### How to make the gekko code more efficient

I have the following problem to solve

I rewrote the problem to Gekko to continuous optimization like this:

``````pt_values = dataframe.select("pt").to_numpy().ravel()
rt_values= dataframe.select("rt").to_numpy().ravel()
number_periods = df.shape[0]
# initialize gekko
m = GEKKO(remote=True)
# set time periods
m.time = np.linspace(0, number_periods-1, number_periods )
# Variables
kt =m.SV(value=ks,lb=0,ub=k_overline,integer=True)
rev_t =m.SV(value=revs)
zt = m.Var(value=zs, lb=-k_overline, ub=r_overline, integer=False)
pt = m.Param(value=pt_value)
rt = m.Param(value=rt_value)

#equations
m.Equation(kt.dt()==m.if3(rt-zt,m.max2(rt-zt,-hr),m.min2(m.min2(k_overline-kt+kt.dt(), rt-zt), hr)))
m.Equation(rev_t.dt()==zt*pt)
#restrictions on zt
m.Equation(kt-kt.dt()+rt>=zt)
p = np.zeros(number_periods)
p[-1] = 1.0
final = m.Param(value=p)

m.Maximize(rev_t*final)
m.options.IMODE = 6
m.solve(disp=False, debug=0)
``````

The problem that my df.shape[0]=8000. It is a lot. For this reason I went to the continuous expressions. The discrete setting fails very quickly. However, this is still a problem. I am searching for suggestions how to improve. I am open to switching to other optimization packages.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website