我有以下一组方程:
x = [x1, x2, x3, x4, x5, x6, x7]
c = [1, 2, 3, 4, 5, 6, 7]
g_cons = [1, 2, 3, 4, 5, 6, 7]
d_cons = [1, 2, 3, 4, 5, 6, 7]
g = Σ(x*g_cons)
d = Σ(x*d_cons)
d_p = d/g*100
e = -0.0038 * d_p * d_p + 0.3501 *d_p – 0.811
ef = (g*(e/100)*365)/55.65
tc = Σ(x*c)
我的目标函数是最小化(ef)和最小化(tc)主题。至 Σx <40 且 xi 界限为 [0,15]
我尝试了下面的代码,但它抛出了一个错误
super().__init__(n_var=7,
n_obj=2,
n_constr=1,
xl=np.array([0, 0, 0, 0, 0, 0, 0]),
xu=np.array([15, 15, 15, 15, 15, 15, 15]))
def _evaluate(self, x, out, *args, **kwargs):
c = [1, 2, 3, 4, 5, 6, 7]
g_cons = [1, 2, 3, 4, 5, 6, 7]
d_cons = [1, 2, 3, 4, 5, 6, 7]
f1 = (sum(x*g_cons)*(-0.0038 *(pow(sum(x*g_cons)/sum(x*d_cons)*100,2))+
0.3501*(sum(x*g_cons)/sum(x*d_cons)*100)- 0.811)/100*365)/55.65
f2 = sum(x*c)
f1, f2 = f1, f2
g1 = sum(x)-40
out["F"] = np.column_stack([f1, f2])
out["G"] = g1
错误信息:
Exception: Population Set Attribute Error: Number of values and population size do not match!