运算/abs 绝对值
np.abs(fitness_list[-1])
运算/linalg.norm 范数
np.linalg.norm(city_coors[i] - city_coors[j])
运算/exp e的次方
np.exp(x)
运算/sqrt 开平方
np.sqrt(x)
运算/power 次方
np.power(2, f_gen)
运算/sum 求和
np.sum(x ** 2)
运算/dot 矩阵乘法
np.dot(w, al) + b
运算/* 元素乘法
m*n
初始化/创建
e=np.array([1,2,3])
e=np.array([[1,2,3]])
创建/diag 对角阵
np.diag([float("inf")] * self.num_city)
创建/zeros 全0
np.zeros(dim)
np.zeros((1, dim))
np.zeros((num, dim))
创建/ones 全1
np.ones((self.num_city, self.num_city))
创建/uniform 统一分布
np.random.uniform(0, 1, self.grey_wolf_num) * (self.ub[i] - self.lb[i]) + self.lb[i]
np.random.uniform(self.x_min, self.x_max, (self.NP, self.D))
np.random.uniform(self.x_min, self.x_max, (self.NP, self.D))
创建/permutaion 排列
np.random.permutation(range(self.num_city))[:self.NP]
操作/clip 限制范围
np.clip(self.positions[i, j], self.lb[j], self.ub[j])
操作/random 随机数
np.random.random()
np.random.random((num_city, 2)) * 1500
操作/rand 随机数
np.random.rand()
操作/randint
np.random.randint(0, self.NP, 1)
操作/min 取最小值
min_v=np.min(self.fitnesss)
操作/argmin 最小值下标
min_idx=np.argmin(self.fitnesss)
操作/切片 行列
a = np.array([[1,2,3],[3,4,5],[4,5,6]])
print (a[...,1])
print (a[1,...])
print (a[...,1:])