2021年1月1日星期五

TypeError: must be real number, not GK_Operators

I don't know much about python, but I need help to understand why my optimization equation pops up "TypeError: must be real number, not GK_Operators". What I did wrong?? Anybody can help me,please??It's urgent. This problem could be found on apmonitor.com, hs87.

from gekko import GEKKO    import math  m = GEKKO ()  #Parameters  a = 131.078  b = 1.48477  #Hock & Schittkowski say 1.48577  c = 0.90798  d0 = 1.47588  e0 = 1.47588  d = math.cos(d0)  e = math.sin(e0)  lim1 = 300  lim2 = 100  lim3 = 200       rate1 = 30  rate2 = 31  rate3 = 28  rate4 = 29  rate5 = 30      #var x1 >= 0, <= 400;  #var x2 >= 0, <= 1000;  #var x3 >= 340, <= 420;  #var x4 >= 340, <= 420;  #var x5 >= -1000, <= 1000;  # Hock & Schittkowski say <= 10000  #var x6 >= 0, <= 0.5236;    add[1:3] > 0  slk[1:3]  x1 = m.Var(value = 390)  x2 = m.Var(value = 1000)  x3 = m.Var(value = 419.5)  x4 = m.Var(value = 340.5)  x5 = m.Var(value = 198.175)  x6 = m.Var(value = 0.5)    add1 = x1 - lim1 + slk1  add2 = x2 - lim2 + slk2  add3 = x2 - lim3 + slk3  m.Equations(300 - x3*x4*math.cos(b - x6)/a + c*x3^2*d/a)  m.Equations(-x3*x4*math.cos(b + x6)/a + c*x4^2*d/a)  m.Equations(-x3*x4*math.sin(b + x6)/a + c*x4^2*e/a)  m.Equations(200 - x3*x4*math.sin(b - x6)/a + c*x3^2*e/a == 0)  m.obj(rate1*x1 + (rate2-rate1)*add1)  m.obj(rate3*x2 + (rate4-rate3)*add2 + (rate5-rate4)*add3)  m.solve(disp=False)    print(x1.value)  print(x2.value)  print(x3.value)  print(x4.value)  print(x5.value)  print(x6.value)  
https://stackoverflow.com/questions/65535623/typeerror-must-be-real-number-not-gk-operators January 02, 2021 at 10:48AM

没有评论:

发表评论