파이썬 오류원인 좀 해결 해주세요 ㅠㅠ
본문
아래 프로그래밍에 오류 원인을 모르겠습니다. ㅠㅠ 도와주세요
from gekko import GEKKO
import numpy as np
import matplotlib.pyplot as plt
m = GEKKO(remote=True)
m.options.SOLVER = 1
hour = 24
Num_User = 3
Num_ESS = 1
p_i = m.Array(m.Var,(hour, Num_User))
alpha = np.array([0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5])
a = alpha
omega = np.array([4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4])
w = omega
pi_t = np.array([70,70,70,70,70,70,70,70,70,121.2,143.7,143.7,121.2,143.7,143.7,143.7,143.7,121.2,121.2,121.2,121.2,121.2,121.2,70])
p_t = pi_t
U_EC = bin
C = U_EC
U_ED = bin
D = U_ED
x_t = m.Array(m.Var,(hour, Num_User))
SOC_t = m.Array(m.Var,(hour, Num_User))
ESS_c = m.Array(m.Var,(hour, Num_User))
ESS_d = m.Array(m.Var,(hour, Num_User))
for tt in range(0,hour):
p_i[tt,0].lower = 0; p_i[tt,1].lower = 0; p_i[tt,2].lower = 0; x_t[tt,0].lower = 0
p_i[tt,0].upper = 21.09; p_i[tt,0].upper = 20; p_i[tt,0].upper = 21.84; x_t[tt,0].upper = 2
for tt in range(0,hour):
x_t[tt,0].lower = 0; x_t[tt,1].lower = 0; x_t[tt,2].lower = 0
x_t[tt,0].upper = 8; x_t[tt,1].upper = 8; x_t[tt,0].upper = 8
for tt in range(0,hour):
SOC_t[tt,0].lower = 0; ESS_c[tt,0].lower = 0; ESS_d[tt,0].lower = 0
SOC_t[tt,0].upper = 20; ESS_c[tt,0].upper = 100; ESS_d[tt,0].upper = 100
eq_U = np.zeros((hour, 3))
eq_U = list(eq_U)
for tt in range(0, hour):
for i in range(0,Num_User):
if x_t[tt,i] >= w[tt,i]/a[tt,i]:
eq_U[tt] = w[i,tt]/a[i,tt]
else:
eq_U[tt] = w[i,tt]*x_t[i,tt]-(a[i,tt]/2)*x_t[i,tt]**2
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
Cell In [10], line 8
6 for tt in range(0, hour):
7 for i in range(0,Num_User):
----> 8 if x_t[tt,i] >= w[tt,i]/a[tt,i]:
9 eq_U[tt] = w[i,tt]/a[i,tt]
10 else:
IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed
답변 1
IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed
==
1차원 배열을
2차원처럼 썼다고 하네요