Пример #1
0
 def getObjectives(self,m,n):
     obj = self.model(m,n).objectives
     dec = self.model(m,n).decisions
     ###$print "\nRunning GA"
     ###$print "x = ",self.x
     DifferentSeeds=random.randint(0,10000)
     pf,hv=ga(self.model,decisions=dec,objectives=obj,someSeed=DifferentSeeds,candidates=self.x[2],generations=1000,mutationRate=self.x[1],lives=self.x[0])
     ###$print "completed GA"
     self.fx=[hv]
     return hv
Пример #2
0
from GeneticAlgorithm import GeneticAlgorithm as ga

g1 = ga()
g1.evolve(50)
print(g1)

                #print "start tuner..."
                TunedLives,TunedMutationRate,TunedCandidates = TuneGAparametersUsingDE(model,decisions=decisions,objectives=decisions)          
                "Printing Tuned paramenters"
                #print "Tuned:[Lives,MutationRate,Candidates]=",TunedLives,TunedMutationRate,TunedCandidates
                
                i = 1
                HV =[]
                PF =[]
                tunedHV=[]
                tunedPF=[]
                #print "Iteration...."
                for k in xrange(numOfIterations):
                    print k,
                    DifferentSeeds=random.randint(0,10000)
                         
                    paretoFront,HyperVolume=ga(model,decisions=decisions,objectives=objectives,someSeed=DifferentSeeds,candidates=100,generations=1000,mutationRate=0.05,lives=5)
                    #print " START TUNED ONE...................."
                    tunedPF,tunedHyperVolume=ga(model,decisions=decisions,objectives=objectives,someSeed=DifferentSeeds,candidates=TunedCandidates,generations=1000,mutationRate=TunedMutationRate,lives=TunedLives)

                    HV.append(HyperVolume)
                    PF.append(paretoFront)
                    tunedHV.append(tunedHyperVolume)
                    tunedPF.append(tunedPF)
                    i += 1
                    #print k," ITERATIONs DONE...................."

                #Print data for this Decision/objective pair
                print ""
                print "----------------------------------------------------------------"
                print "Finished processing ",model.__name__," with Decisions = ",decisions," and  Objectives = ",objectives
                fo.write('++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n')