文件名称:背包问题的遗传算法解法
文件大小:25KB
文件格式:RAR
更新时间:2009-01-25 04:33:35
其它类别 背包问题. 遗传算法解法
本程序利用遗传算法来求解背包问题.采用二进制字符串编码,1表示选择物体,0则不选择. 背包问题描述:在M件物品取出若干件放在空间为W的背包里,每件物品的重量为W1,W·2……Wn,与之相对应的价值为P1,P2……Pn。求出获得最大价值的方案。注意:在本题中,所有的重量值均为整数。 以下是本程序的主要函数说明: 1.GetRandChromosomes(szChromosome() As String, iChromosomeCount As Integer):随机初始化染色体 2.GetRandValueAndContent(iValue() As Integer, iContent() As Integer, iObjectCount As Integer):随机初始化物体容量和物体价值 3.GetRandAllContentByContent(iContent() As Integer, iObjectCount As Integer):根据物体体积随机初始背包容量,使得物体的总体积大于背包的容量 4.CopyChromosomes(iProbability() As Single, szChromosome() As String, iChromosomeCount As Integer):染色体复制 5.SelChromosomeBySelProba(iProbability() As Single, iChromosomeCount As Integer) As Integer:根据选择概率选择染色体 6.IsLiveGene(szChromosome As String, iContent() As Integer, iKitContent As Integer) As Boolean:判断染色体是否为活的染色体,即是否满足条件 7.Cross(szChromosome1 As String, szChromosome2 As String, iObjectCount As Integer):染色体之间进行杂交 8.Aberrance(szChromosome As String, iObjectCount As Integer):染色体变异 9.GetAdaptablity(szChromosome As String, iValue() As Integer, iContent() As Integer, iChromosomeCount As Integer) As Integer:得到染色体的适应度 10.GetSelectProbability(iAdaptablity() As Integer, iChromosomeNum As Integer, iChromosomeCount As Integer) As Single:得到选择概率
【文件预览】:
背包问题的遗传算法解法
----GA.gif(12KB)
----frmMain.frm(11KB)
----源码说明.txt(2KB)
----GA.vbp(673B)
----GA.exe(32KB)