df = pd.read_csv("data.csv")
xm1 = np.array(df["T"]) #Dep Var 1
xm2 = np.array(df["t"]) #Dep Var 2
xm3 = np.array(df["L"]) #Dep Var 3
ym = np.array(df["S"]) #Indep Var
# GEKKO model
m = GEKKO()
a = m.FV(lb=-100.0,ub=100.0)
b = m.FV(lb=-100.0,ub=100.0)
c = m.FV(lb=-100.0,ub=100.0)
d = m.FV(lb=-100.0,ub=100.0)
e = m.FV(lb=-100.0,ub=100.0)
f = m.FV(lb=-100.0,ub=100.0)
g = m.FV(lb=-100.0,ub=100.0)
x1 = m.Param(value=xm1)
x2 = m.Param(value=xm2)
x3 = m.Param(value=xm3)
z = m.Param(value=ym)
y = m.Var()
m.Equation(y == a+x1*b+x2*c+x3*d+e*(x1**2)+f*(x2**2)+g*(x3**2)
m.Obj(((y-z)/z)**2)
I am getting a SyntaxError: invalid syntax
on m.Obj(((yz)/z)**2)
. I have followed APMonitor.com's code for this. This code works perfectly for the example there. But it shows this syntax error when I modify it to fit my regression problem with more FVs. Syntax error pic attached
Not really sure what's wrong with this. Any help would be appreciated.
The error occurs due to this line:
m.Equation(y == a+x1*b+x2*c+x3*d+e*(x1**2)+f*(x2**2)+g*(x3**2)
there is extra parenthesis before y
declaration
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.