파이썬 오류원인 좀 해결 해주세요 ㅠㅠ

파이썬 오류원인 좀 해결 해주세요 ㅠㅠ

QA

파이썬 오류원인 좀 해결 해주세요 ㅠㅠ

답변 1

본문

아래 프로그래밍에 오류 원인을 모르겠습니다. ㅠㅠ 도와주세요

 

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

답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
전체 122
© SIRSOFT
현재 페이지 제일 처음으로