deap库常见模块

目录

Base

1、Toolbox

2、Fitness

Creator

3、Creating Types


Base

基础模块提供了构建进化算法的基本结构。它包含工具箱Toolbox,用于存储进化算子,以及一个用作基类的Fitness类,用于表示任何个体的优劣。 

1、Toolbox

class deap.base.Toolbox

工具箱的具体用法体现在在创建类型用于初始化,和在运算符和算法教程中显示工具容器。

register(alias, method[, argument[, ...]])

Parameters:
  • alias – The name the operator will take in the toolbox. If the alias already exist it will overwrite the operator already present.
  • function – The function to which refer the alias.
  • argument One or more argument (and keyword argument) to pass aut
  • omatically to the registered function when called, optional.

unregister(alias)

decorate(alias, decorator[, decorator[, ...]]
 

2、Fitness

适合度是衡量解决方案质量的指标。如果值作为元组提供,则使用这些值初始化适应度,否则它为空(或无效)。

Creator

deap.creator.create(name, base[, attribute[, ...]])

creator模块中创建一个新的类名,该类名继承自基类。新类可以具有由传递给函数create的后续关键字参数定义的属性。如果参数是一个类(没有括号),则在初始化新对象的实例时调用__init__函数,并将返回的实例添加为类实例的属性。否则,如果参数不是类(例如int),它将作为类的“静态”属性添加。

Parameters:
  • name – The name of the class to create.
  • base – A base class from which to inherit.
  • attribute – One or more attributes to add on instantiation of this class, optional.

The following is used to create a class Foo inheriting from the standard list and having an attribute bar being an empty dictionary and a static attribute spam initialized to 1.

3、Creating Types

  1.  Fitness
  2. Individual

 


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

且行且安~

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值