Пример #1
0
	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
Пример #2
0
    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
Пример #3
0
longitudemax = 145
longitudemin = 140
latitudemax = 35
latitudemin = 30
Interval = 1

longitudebinnum = (int)((longitudemax - longitudemin)/Interval)   #how many bins 
latitudenum = (int)((latitudemax - latitudemin)/Interval)  #how many bins 	




######### loop ########################    
best = -100000
data = earthquakedata.dataremodel()


path = 'data.dat'

######## map setting #######

data.longitudemax = 145
data.longitudemin = 140


data.latitudemax = 35
data.latitudemin = 30

data.Interval = 1
Пример #4
0
    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()

        #here's our data to plot, all normal Python lists


        ############# from data model end ########################

        ####################### GA start  ########################
        #n  =    1 ###set n times

        #best = Evalate(integerrandomforecat)
       
        ############# first Population ############################
        newPopulation = np.zeros((self.Population_size, data.latitudenum , data.longitudebinnum ),float)
        for i in range(0, self.Population_size):
            newPopulation[i] = randommodel.generatemodel(data.latitudenum , data.longitudebinnum );
        for i in range(0, self.Population_size):
            self.Population.append(newPopulation[i])

        ######### loop ########################    
        best = -100000

        for g in range(0,self.Generation):

            
            score = np.zeros(len(self.Population),float)

            for i in range(0, len(self.Population) ):
                intPopulation = randommodel.intergermodel(self.Population[i], data.latitudenum , data.longitudebinnum );
                score[i] = self.Evalate(intPopulation,data)

            for i in range(0,len(score)):
                if score[i] > best :
                    best = score[i]
            
            self.P_sort(score)

            while len(self.Population) > self.Population_size:
                self.Population.pop()


            score = np.zeros(len(self.Population),float)            
            
            for i in range(0, len(self.Population) ):
                intPopulation = randommodel.intergermodel(self.Population[i], data.latitudenum , data.longitudebinnum )
                score[i] = self.Evalate(intPopulation,data)

            self.P_sort(score)
            self.newpoolclear()
            self.tournament_selection()
            self.Corssover()
            self.Mutation()

        print "GAwithoutUNDX best = " , best

        return best
Пример #5
0
    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()

        #here's our data to plot, all normal Python lists


        ############# from data model end ########################

        ####################### GA start  ########################
        #n  =    1 ###set n times

        #best = Evalate(integerrandomforecat)
       
        ############# first Population ############################
        newPopulation = np.zeros((self.Population_size, data.latitudenum , data.longitudebinnum ),float)
        for i in range(0, self.Population_size):
            newPopulation[i] = randommodel.generatemodel(data.latitudenum , data.longitudebinnum );
        for i in range(0, self.Population_size):
            self.Population.append(newPopulation[i])

        ######### loop ########################    
        best = -100000

        for g in range(0,self.Generation):

            
            score = np.zeros(len(self.Population),float)

            for i in range(0, len(self.Population) ):
                intPopulation = randommodel.intergermodel(self.Population[i], data.latitudenum , data.longitudebinnum );
                score[i] = self.Evalate(intPopulation,data)

            for i in range(0,len(score)):
                if score[i] > best :
                    best = score[i]
            
            self.P_sort(score)

            while len(self.Population) > self.Population_size:
                self.Population.pop()


            score = np.zeros(len(self.Population),float)            
            
            for i in range(0, len(self.Population) ):
                intPopulation = randommodel.intergermodel(self.Population[i], data.latitudenum , data.longitudebinnum )
                score[i] = self.Evalate(intPopulation,data)

            self.P_sort(score)
            self.newpoolclear()
            self.tournament_selection()
            self.Corssover()
            self.Mutation()

        print "GA best = " , best

        return best
Пример #6
0
Crossover_Chance = 0.9
Mutation_Chance_individual = 0.8

longitudemax = 145
longitudemin = 140
latitudemax = 35
latitudemin = 30
Interval = 1

longitudebinnum = (int)(
    (longitudemax - longitudemin) / Interval)  #how many bins
latitudenum = (int)((latitudemax - latitudemin) / Interval)  #how many bins

######### loop ########################
best = -100000
data = earthquakedata.dataremodel()

path = 'data.dat'

######## map setting #######

data.longitudemax = 145
data.longitudemin = 140

data.latitudemax = 35
data.latitudemin = 30

data.Interval = 1

data.datareader(path)