forked from himanshuRepo/Biogeography-Based-Optimization
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClearDups.py
More file actions
36 lines (23 loc) · 1.14 KB
/
ClearDups.py
File metadata and controls
36 lines (23 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# -*- coding: utf-8 -*-
"""
Python code of Biogeography-Based Optimization (BBO)
Coded by: Raju Pal (emailid: raju3131.pal@gmail.com) and Himanshu Mittal (emailid: himanshu.mittal224@gmail.com)
The code template used is similar to code given at link: https://github.com/himanshuRepo/CKGSA-in-Python
and matlab version of the BBO at link: http://embeddedlab.csuohio.edu/BBO/software/
Reference: D. Simon, Biogeography-Based Optimization, IEEE Transactions on Evolutionary Computation, in print (2008).
@author: Dan Simon (http://embeddedlab.csuohio.edu/BBO/software/)
-- ClearDups File: Function for removing the duplicates in the Population
Code compatible:
-- Python: 2.* or 3.*
"""
import random
import numpy
def ClearDups(population, popSize, dim, maxParValue, minParValue):
for i in range(popSize):
chrom1 = numpy.sort(population[i,:])
for j in range(i + 1, popSize):
Chrom2 = numpy.sort(population[j,:])
if chrom1 is Chrom2:
parnum = numpy.ceil(dim * random.random())
population[j, parnum] = minParValue + (maxParValue - minParValue) * random.random()
return population