在python中创建仿生计算智能算法的框架

inspyred的Python项目详细描述


inspyred是一个免费的开源框架,用于创建受生物启发的 python中的计算智能算法,包括进化算法 计算、群体智能和免疫计算。另外,inspyred 为 不需要太多定制的用户。

示例

下面的示例演示inspyred包的基础知识。在这个 例如,候选解决方案是10位二进制字符串,其十进制值 应最大化:

import random
import time
import inspyred

def generate_binary(random, args):
    bits = args.get('num_bits', 8)
    return [random.choice([0, 1]) for i in range(bits)]

@inspyred.ec.evaluators.evaluator
def evaluate_binary(candidate, args):
    return int("".join([str(c) for c in candidate]), 2)

rand = random.Random()
rand.seed(int(time.time()))
ga = inspyred.ec.GA(rand)
ga.observer = inspyred.ec.observers.stats_observer
ga.terminator = inspyred.ec.terminators.evaluation_termination
final_pop = ga.evolve(evaluator=evaluate_binary,
                      generator=generate_binary,
                      max_evaluations=1000,
                      num_elites=1,
                      pop_size=100,
                      num_bits=10)
final_pop.sort(reverse=True)
for ind in final_pop:
    print(str(ind))

要求

  • Requires at least Python 2.6+ or 3+.
  • Numpy and Pylab are required for several functions in ^{tt1}$.
  • Pylab and Matplotlib are required for several functions in ^{tt2}$.
  • Parallel Python (pp) is required if ^{tt3}$ is used.

许可证

这个软件包是根据麻省理工学院的许可证分发的。可以找到此许可证 在线http://www.opensource.org/licenses/MIT

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
ArrayList Java中的搜索字符串   另一个web应用程序的java访问会话   另一个应用程序中的活动和服务之间的java通信   java根据Json字符串类型将Json字符串转换为对象   eclipse如何解决java中的错误异常。lang.NoSuchMethodError:'java。字符串javax。摆动JOptionPane。showInputDialog(java.lang.String)'   线程“main”java中的安卓异常。lang.NoClassDefFoundError:org/codehaus/jackson/JsonParseException   java如何在安卓 emulator上显示Mat图像?使用NDK   Java在本地读取测试源文件,但在服务器上读取失败   java dowhile循环用于计算输入数字中的数字。故障排除代码   JAva初学者在编写获取成本的方法时遇到困难   java是shell游戏。我如何让物体移动,特别是在特定的曲线上,但顺序是随机的?   java如何区分两个同名的JButton   java为什么我在Spring Boot中需要一个接口?   java将文件路径插入数据库将删除\   使用InterfaceType初始化java对象   java如何部署一个分为Angular、Spring Boot和MySQL的项目?   java如何使用Symja解决不等式?