Exemple #1
0
 def objs(self, x):
     mod = Kursawe()
     min_objs, max_objs = mod.baseline_objs()
     frontier = ga(x[0], x[1], x[2]).run(mod)
     filename = "hyper.out"
     Utility.write_to_file(mod, filename, frontier, min_objs, max_objs)
     output = HyperVolume_wrapper()
     ## Will always
     hve = 0
     for out in output:
         hve = out.hypervolume
     return hve
Exemple #2
0
 def objs(self, x):
     mod = Kursawe()
     min_objs, max_objs = mod.baseline_objs()
     frontier = ga(x[0], x[1], x[2]).run(mod)
     filename = "hyper.out"
     Utility.write_to_file(mod, filename, frontier, min_objs, max_objs)
     output = HyperVolume_wrapper()
     ## Will always
     hve = 0
     for out in output:
         hve = out.hypervolume
     return hve
Exemple #3
0
     f.close()
 ######################### End function to write to File
 repeats = 5
 objs = [2,4,6,8]
 decs = [10,20,40]
 for model in [DTLZ1,DTLZ3,DTLZ5,DTLZ7]:
     for obj in objs:
         for dec in decs:
             cur_e = []
             mod = model(dec,obj)
             min_objs,max_objs = mod.baseline_objs()
             for _ in range(repeats):
                 print("# Repeat: %d" % (_))
                 data = []
                 mod = model(dec,obj)
                 opt_rpt = []
                 g_algo = ga()
                 t1 = time.time()
                 frontier = ga().run(mod)
                 t2 = time.time()
                 filename = mod.name + "-" + str(mod) +"-" + str(dec) + "-PF-"+ str(_)
                 write_to_file(mod,filename,frontier,min_objs,max_objs)
                 print("# Runtime: %.3f secs" % (t2-t1))
                 opt_rpt.append(float(t2-t1))
             avg_time = sum(opt_rpt) / len(opt_rpt)
             #avg_energy = (avg_energy - min)/(max - min)
             print "="*50
             print "\nStarting Model = %s Optimizer = %s No. of Decision = %s No. of Objectives = %s \n" % (mod.name,str("GA"),str(dec),str(obj))
             print("# Average: %.3f secs" % (avg_time))
             print "="*50
 HyperVolume_wrapper()
Exemple #4
0
 local = []
 local.append(facts[s])
 for model in [DTLZ7]:
     data = []
     opt_rpt = []
     #opt_rpt.append(ga.name)
     for obj in objs:
         for dec in decs:
             cur_e = []
             mod = model(dec,obj)
             min_objs,max_objs = mod.baseline_objs()
             for _ in range(repeats):
                 #print "Starting Model = %s Optimizer = %s \n" % (mod.name,str("ga"))
                 print "-"*50
                 t1 = time.time()
                 frontier = ga(setting[0],setting[1],setting[2]).run(mod)
                 t2 = time.time()
                 filename = mod.name + "-" + str(obj)
                 Utility.write_to_file(mod,filename,frontier,min_objs,max_objs)
                 print("# Runtime: %.3f secs" % (t2-t1))
                 output = HyperVolume_wrapper()
                 for out in output:
                     local.append(out.hypervolume)
                 opt_rpt.append(float(t2-t1))
                 print "-"*50
             avg_time = sum(opt_rpt) / len(opt_rpt)
             print "="*50
             print "\nModel = %s Optimizer = %s No. of Decision = %s No. of Objectives = %s \n" % (mod.name,str("GA"),str(dec),str(obj))
             print "min = ", min_objs
             print "max = ", max_objs
             print("# Average: %.3f secs" % (avg_time))
Exemple #5
0
 ######################### End function to write to File
 repeats = 5
 objs = [2, 4, 6, 8]
 decs = [10, 20, 40]
 for model in [DTLZ1, DTLZ3, DTLZ5, DTLZ7]:
     for obj in objs:
         for dec in decs:
             cur_e = []
             mod = model(dec, obj)
             min_objs, max_objs = mod.baseline_objs()
             for _ in range(repeats):
                 print("# Repeat: %d" % (_))
                 data = []
                 mod = model(dec, obj)
                 opt_rpt = []
                 g_algo = ga()
                 t1 = time.time()
                 frontier = ga().run(mod)
                 t2 = time.time()
                 filename = mod.name + "-" + str(mod) + "-" + str(
                     dec) + "-PF-" + str(_)
                 write_to_file(mod, filename, frontier, min_objs, max_objs)
                 print("# Runtime: %.3f secs" % (t2 - t1))
                 opt_rpt.append(float(t2 - t1))
             avg_time = sum(opt_rpt) / len(opt_rpt)
             #avg_energy = (avg_energy - min)/(max - min)
             print "=" * 50
             print "\nStarting Model = %s Optimizer = %s No. of Decision = %s No. of Objectives = %s \n" % (
                 mod.name, str("GA"), str(dec), str(obj))
             print("# Average: %.3f secs" % (avg_time))
             print "=" * 50
Exemple #6
0
 local = []
 local.append(facts[s])
 for model in [DTLZ7]:
     data = []
     opt_rpt = []
     #opt_rpt.append(ga.name)
     for obj in objs:
         for dec in decs:
             cur_e = []
             mod = model(dec, obj)
             min_objs, max_objs = mod.baseline_objs()
             for _ in range(repeats):
                 #print "Starting Model = %s Optimizer = %s \n" % (mod.name,str("ga"))
                 print "-" * 50
                 t1 = time.time()
                 frontier = ga(setting[0], setting[1],
                               setting[2]).run(mod)
                 t2 = time.time()
                 filename = mod.name + "-" + str(obj)
                 Utility.write_to_file(mod, filename, frontier,
                                       min_objs, max_objs)
                 print("# Runtime: %.3f secs" % (t2 - t1))
                 output = HyperVolume_wrapper()
                 for out in output:
                     local.append(out.hypervolume)
                 opt_rpt.append(float(t2 - t1))
                 print "-" * 50
             avg_time = sum(opt_rpt) / len(opt_rpt)
             print "=" * 50
             print "\nModel = %s Optimizer = %s No. of Decision = %s No. of Objectives = %s \n" % (
                 mod.name, str("GA"), str(dec), str(obj))
             print "min = ", min_objs