资源简介
python遗传算法 源代码python遗传算法 源代码python遗传算法 源代码

代码片段和文件信息
import numpy as np
import ObjFunction
class GAIndividual:
‘‘‘
individual of genetic algorithm
‘‘‘
def __init__(self vardim bound):
‘‘‘
vardim: dimension of variables
bound: boundaries of variables
‘‘‘
self.vardim = vardim
self.bound = bound
self.fitness = 0.
def generate(self):
‘‘‘
generate a random chromsome for genetic algorithm
‘‘‘
len = self.vardim
rnd = np.random.random(size=len)
self.chrom = np.zeros(len)
for i in range(0 len):
self.chrom[i] = self.bound[0 i] + \
(self.bound[1 i] - self.bound[0 i]) * rnd[i]
def calculateFitness(self):
‘‘‘
calculate the fitness of the chromsome
‘‘‘
self.fitness = ObjFunction.GrieFunc(
self.vardim self.chrom self.bound)
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-04-24 10:04 遗传算法\
目录 0 2018-04-24 19:34 遗传算法\.idea\
文件 185 2018-04-24 08:58 遗传算法\.idea\misc.xm
文件 276 2018-04-24 08:58 遗传算法\.idea\modules.xm
文件 18950 2018-04-24 19:34 遗传算法\.idea\workspace.xm
文件 455 2018-04-24 08:59 遗传算法\.idea\遗传算法.iml
文件 923 2018-04-24 10:04 遗传算法\GAIndividual.py
文件 6523 2018-04-24 10:01 遗传算法\GeneticAlgorithm.py
文件 528 2018-04-24 08:59 遗传算法\ObjFunction.py
目录 0 2018-04-24 10:04 遗传算法\__pycache__\
文件 1281 2018-04-24 10:04 遗传算法\__pycache__\GAIndividual.cpython-36.pyc
文件 767 2018-04-24 09:14 遗传算法\__pycache__\ObjFunction.cpython-36.pyc
相关资源
- 遗传算法解决第一类生产平衡问题
- python遗传算法解决八皇后问题
- Python-使用遗传算法和深度学习训练
- 遗传算法python
- 经典遗传算法(SGA)解01背包问题的
- 遗传算法python代码
- python实现的改进的遗传算法解决工件
- GA-BP算法的python实现
- 模拟退火-遗传算法 34省会城市TSP问题
- 遗传算法的Python实现
- 遗传算法实现入侵检测,AISpython实现
- python遗传算法求函数极值.py
- 遗传算法Python实现.zip
- 遗传算法求sinx最大值
- 遗传算法解决 TSP 问题
- python遗传算法
- Python-通过神经网络和遗传算法进化的
- 遗传算法python实现
- 经典遗传算法(SGA)解非线性最优化
- 遗传算法、禁忌搜索、模拟退火、蚁
评论
共有 条评论