-
Notifications
You must be signed in to change notification settings - Fork 0
/
randomf.py
66 lines (42 loc) · 1.33 KB
/
randomf.py
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import GA
import randommodel
import earthquakedata
import numpy as np
class randomf():
def __init__(self):
self.longitudemax = 145
self.longitudemin = 140
self.latitudemax = 35
self.latitudemin = 30
self.Interval = 0.5
self.longitudebinnum = (int)((self.longitudemax - self.longitudemin)/self.Interval) #how many bins
self.latitudenum = (int)((self.latitudemax - self.latitudemin)/self.Interval) #how many bins
def main(self):
############ generate model from data ##################
data = earthquakedata.dataremodel()
path = 'data.dat'
######## map setting #######
data.longitudemax = 145
data.longitudemin = 140
data.latitudemax = 35
data.latitudemin = 30
data.Interval = 0.5
data.datareader(path)
######## setting end ######
data.selectyear = 2010
data.selectmonths = 1
data.selectmonthe = 12
data.setnum()
data.findhappentimes()
#data.setmodel()
best = -100000
GAf = GA.GA()
for i in range(0, 200 * 200):
rf = randommodel.generatemodel(self.latitudenum,self.longitudebinnum)
intPopulation = np.zeros((data.latitudenum , data.longitudebinnum ),float)
intPopulation = randommodel.intergermodel(rf,self.latitudenum,self.longitudebinnum)
score = GAf.Evalate(intPopulation,data)
if score > best :
best = score
print "R best = ", best
return best