def set_bad_score(self): self.score = 9999. # search space boundaries: searchspace = (('amp 1', -6.4, +6.35), ('omega 1', -6.4, +6.35), ('amp 2', -6.4, +6.35), ('omega 2', -6.4, +6.35), ('amp 3', -6.4, +6.35), ('omega 3', -6.4, +6.35)) dim = len(searchspace) # search space dimension ps = 80 parents = Population(FMsynthC, ps, dummyfunc, searchspace) offspring = Population(FMsynthC, ps, dummyfunc, searchspace) rec = Recorder(parents) ea = ComboB(parents, offspring) # instanciate the algorithm from library def gcb(eaobj): if eaobj.F0.gg % 10 == 0: # every 10th generation b = eaobj.F0[0] b.plot_FMsynth_solution() print 'gcb: generation: {} score: {} DNA: {}'.format( eaobj.F0.gg, b.score, b.DNA) rec.save_status() ea.generation_callbacks.append(gcb) # set algorithm parameters (meaning of unexplained parameters should be inferred from source code) ea.set_bunchsizes([8, 12, 10, 10, 20, 20])
rec=Recorder(p0) elif problem == 'rastrigin': space=simple_searchspace(ndim, -6., 6.) p0=Population(rastrigin,ps,dummyfunc,space) p1=Population(rastrigin,ps,dummyfunc,space) rec=Recorder(p0) elif problem == 'sphere': space=simple_searchspace(ndim, -2., 2.) p0=Population(sphere,ps,dummyfunc,space) p1=Population(sphere,ps,dummyfunc,space) rec=Recorder(p0) if EA_type == 'THEA': eac=ComboB(p0,p1) bs=eac.bunching() eac.set_bunchsizes(bs) eac.make_bunchlists() varlist=[] varlist.append({'name':'selpC', 'type':float, 'inival':1.0}) varlist.append({'name':'selpD', 'type':float, 'inival':2.0}) varlist.append({'name':'selpE', 'type':float, 'inival':2.0}) varlist.append({'name':'selpF', 'type':float, 'inival':3.0}) varlist.append({'name':'mstep', 'type':float, 'inival':0.18}) varlist.append({'name':'Pm', 'type':float, 'inival':0.6}) varlist.append({'name':'mr', 'type':float, 'inival':0.5}) varlist.append({'name':'cigar2uniform', 'type':float, 'inival':0.3}) varlist.append({'name':'cigar_aspect', 'type':float, 'inival':0.3}) varlist.append({'name':'WHX2BLX', 'type':float, 'inival':0.0})