Python Can';t实例化抽象<;类别';deap.creator.Fitnessmin'&燃气轮机;具有抽象属性权重

Python Can';t实例化抽象<;类别';deap.creator.Fitnessmin'&燃气轮机;具有抽象属性权重,python,genetic-algorithm,deap,Python,Genetic Algorithm,Deap,我的类有问题,我真的不知道该怎么办,下面是代码 来自deap导入库,创建者 从deap导入算法 来自deap导入工具 将numpy作为np导入 随机输入 weight=[23,31,29,44,53,38,63,85,89,82] profit=[92,57,49,68,60,43,67,84,87,72] maxw=165 i=1000 def fit(x): totp= np.sum(np.asarray(x)*np.sdsrray(profit)) totw=np.sum(

我的类有问题,我真的不知道该怎么办,下面是代码

来自deap导入库,创建者 从deap导入算法 来自deap导入工具 将numpy作为np导入 随机输入

weight=[23,31,29,44,53,38,63,85,89,82]
profit=[92,57,49,68,60,43,67,84,87,72]
maxw=165
i=1000
def fit(x):
    totp= np.sum(np.asarray(x)*np.sdsrray(profit))
    totw=np.sum(np.asarray(x)*np.asarray(weight))
    if totw>max:
        totp=totp+(maxw-totw)*3
    totp=max(totp,0)
    return totp

creator.create("Fitnessmin",base.Fitness, ws=(1.0,))
creator.create("Individual",list, fitness=creator.Fitnessmin)
toolbox= base.Toolbox()
toolbox.register("select", tools.selRoulette)
toolbox.register("mutate", tools.mutFlipBit, indpb=0.1)
toolbox.register("mate", tools.cxOnePoint)
toolbox.register("evaluate", fit)
toolbox.register("attribute", random.randint, a=0, b=1)
toolbox.register("individual", tools.initRepeat, creator.Individual, toolbox.attribute, n=10)
toolbox.register("population", tools.initRepeat, list, toolbox.individual)
pobl=toolbox.population(n=10)

stats= tools.Statistics(key=lambda ind: ind.fitness.values)
stats.register("max", np.max)
stats.register("min", np.min)
stats.register("avg", np.mean)
stats.register("std", np.std)
hof=tools.HallofFame(3)
init raise TypeError中的第174行(“无法用抽象实例化抽象%r”