Skip to content

Commit f8602ae

Browse files
author
linyiqun
committed
修复了遗传算法在选择操作时数量有时会变少的bug
修复了遗传算法在选择操作时数量有时会变少的bug
1 parent 7022e8d commit f8602ae

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Others/DataMining_GA/GATool.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ private ArrayList<int[]> selectOperate(ArrayList<int[]> initCodes) {
119119
for (int i = 0; i < initSetsNum; i++) {
120120
randomNum = random.nextInt(100) + 1;
121121
randomNum = randomNum / 100;
122+
//因为1.0是无法判断到的,,总和会无限接近1.0取为0.99做判断
123+
if(randomNum == 1){
124+
randomNum = randomNum - 0.01;
125+
}
122126

123127
sumAdaptiveValue = 0;
124128
// 确定区间

0 commit comments

Comments
 (0)