-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUtils.py
More file actions
41 lines (35 loc) · 810 Bytes
/
Utils.py
File metadata and controls
41 lines (35 loc) · 810 Bytes
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
37
38
39
40
41
import random
class Utils:
def __init__(self):
self.COLOR_LEN=3
self.MAX_WORLD_VALUE = 254
self.MIN_WORLD_VALUE = 0
self.FIT_CHROMO_COUNT = 3
def getUnsignedInt(b):
return 0;
def getSignedInt(b):
return -1
@staticmethod
def getrandInt(self,min,max):
rand=Random()
randomNum=random.random(min,max)
return randomNum
@staticmethod
def getMinDx(self,allGenes,solution):
genes=allGenes
minDX=abs(solution-genes[0])
chosen=0
for i in range(len(genes)):
if abs(solution-genes[i])<minDX:
minDX=abs(solution-genes[i])
chosen=i
for i in range(len(genes)):
if chosen==i:
genes[i]=(solution-genes[i])
else:
genes[i]=-1000
return genes
@staticmethod
def getFileExtension(file):
name=file.name
return substring.substringByChar(name, startChar=".")