http://geatpy.com/
import geatpy as ea
import numpy as np
# 构建问题
r = 1 # 目标函数需要用到的额外数据
@ea.Problem.single
def evalVars(Vars): # 定义目标函数(含约束)
f = np.sum((Vars - r) ** 2) # 计算目标函数值
x1 = Vars[0]
x2 = Vars[1]
CV
http://geatpy.com/
import geatpy as ea
import numpy as np
# 构建问题
r = 1 # 目标函数需要用到的额外数据
@ea.Problem.single
def evalVars(Vars): # 定义目标函数(含约束)
f = np.sum((Vars - r) ** 2) # 计算目标函数值
x1 = Vars[0]
x2 = Vars[1]
CV