目录
Base
基础模块提供了构建进化算法的基本结构。它包含工具箱Toolbox,用于存储进化算子,以及一个用作基类的Fitness类,用于表示任何个体的优劣。
1、Toolbox
class deap.base.
Toolbox
工具箱的具体用法体现在在创建类型用于初始化,和在运算符和算法教程中显示工具容器。
register
(alias, method[, argument[, ...]])
Parameters: |
|
---|
unregister
(alias)decorate
(alias, decorator[, decorator[, ...]]
2、Fitness
适合度是衡量解决方案质量的指标。如果值作为元组提供,则使用这些值初始化适应度,否则它为空(或无效)。
Creator
deap.creator.
create
(name, base[, attribute[, ...]])
在creator
模块中创建一个新的类名,该类名继承自基类。新类可以具有由传递给函数create的后续关键字参数定义的属性。如果参数是一个类(没有括号),则在初始化新对象的实例时调用__init__函数,并将返回的实例添加为类实例的属性。否则,如果参数不是类(例如int),它将作为类的“静态”属性添加。
Parameters: |
|
---|
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
- Fitness
- Individual