예제 #1
0
파일: randomf.py 프로젝트: yumaj/project
	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
파일: randomf.py 프로젝트: yumaj/project
    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
    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
예제 #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 "GA best = " , best

        return best