コード例 #1
0
import matplotlib as mpl
import matplotlib.pyplot as plt
from peabox_individual import Individual
from peabox_population import Population
from peabox_testfuncs import CEC05_test_function_producer as tfp
from peabox_helpers import parentselect_exp as pse
from peabox_helpers import simple_searchspace

#-------------------------------------------------------------------------------
#--- part 1: Ingredients -------------------------------------------------------
#-------------------------------------------------------------------------------

dim = 10
f11 = tfp(11, dim)  # Weierstrass function in 10 dimensions

searchspace = simple_searchspace(10, -3., 1.)

ps = 40  # population size
G = 80  # number of generations to go through
parents = Population(Individual, ps, f11, searchspace)
offspring = Population(Individual, ps, f11, searchspace)

#-------------------------------------------------------------------------------
#--- part 2: initialisation ----------------------------------------------------
#-------------------------------------------------------------------------------

seed(
    1
)  # seeding numpy's random number generator so we get reproducibly the same random numbers
parents.new_random_genes()
parents.eval_all()
コード例 #2
0

#-------------------------------------------------------------------------------
#--- intermezzo: the colormap used in peabox_plotting.ancestryplot -------------
#-------------------------------------------------------------------------------

show_these_colormaps([ancestcolors],'colormap_used_for_ancestry_coloring.png')

#-------------------------------------------------------------------------------
#--- part 1: Ingredients -------------------------------------------------------
#-------------------------------------------------------------------------------

dim=10
f11=tfp(11,dim)   # Weierstrass function in 10 dimensions

searchspace=simple_searchspace(10,-3.,1.)

ps=80    # population size
G=120     # number of generations to go through
parents=SAGA_Population(Individual,ps,f11,searchspace); parents.objname='CEC05 f11'
offspring=SAGA_Population(Individual,ps,f11,searchspace); offspring.objname='CEC05 f11'

parents.ncase=1   # let this be case 1, plots and pickles will contain the number
offspring.ncase=1

rec=Recorder(parents) # creating this Recorder instance to collect survey data on parent population
rec.snames.append('sa_improverate') # appending a scalar property's name to the survey list
rec.snames.append('sa_toleraterate')
rec.snames.append('ga_improverate')
rec.snames.append('sa_bestcontributions')
rec.snames.append('ga_bestcontributions')
コード例 #3
0
ファイル: psotest3.py プロジェクト: stromatolith/peabox
    def do_step(self):
        PSO_Individ.do_step(self)
        self.memorize()

    def get_trajectory_components(self, dims):
        output = []
        for d in dims:
            output.append([self.traj[i][d] for i in range(len(self.traj))])
        return output


dim = 2
f1 = tfp(1, dim)  # Weierstrass function in 2 dimensions
f11 = tfp(11, dim)  # Weierstrass function in 2 dimensions
searchspace = simple_searchspace(dim, -3., 1.)
p = Pswarm(Memorizing_PSO_Individ, 12, f1, searchspace, [3, 4], 1)
p.random_ini()
#p.alpha=0.95

if True:
    dude = p[0]
    #dude.random_influence='1D'
    dude.add_attractor(ones(dim), 1.)
    dude.speed[:] = 1, 0

    for i in range(20):
        dude.do_step()

    x, y = dude.get_trajectory_components([0, 1])
    plt.plot(x, y, 'bo-')
コード例 #4
0
ファイル: psotest3.py プロジェクト: stromatolith/peabox
    def memorize(self):
        self.traj.append(self.get_copy_of_DNA())
        self.trajqual.append(self.score)
    def do_step(self):
        PSO_Individ.do_step(self)
        self.memorize()
    def get_trajectory_components(self,dims):
        output=[]
        for d in dims:
            output.append([self.traj[i][d] for i in range(len(self.traj))])
        return output

dim=2
f1=tfp(1,dim)   # Weierstrass function in 2 dimensions
f11=tfp(11,dim)   # Weierstrass function in 2 dimensions
searchspace=simple_searchspace(dim,-3.,1.)
p=Pswarm(Memorizing_PSO_Individ,12,f1,searchspace,[3,4],1)
p.random_ini()
#p.alpha=0.95


if True:
    dude=p[0]
    #dude.random_influence='1D'
    dude.add_attractor(ones(dim),1.)
    dude.speed[:]=1,0
    
    for i in range(20):
        dude.do_step()
    
    x,y=dude.get_trajectory_components([0,1])
コード例 #5
0
ファイル: tkearun.py プロジェクト: stromatolith/peabox
from comboCbeta import ComboC_beta
from tkframe import TKEA_win
import matplotlib.pyplot as plt
#plt.ion()

def dummyfunc(x):
    return np.sum(x)
    
ndim=8
ps=80

problem = 'gf_kragtraeger'
EA_type = 'CMAES'

if problem == 'FMsynth':
    space=simple_searchspace(ndim, -6.4, +6.35)
    p0=Population(FMsynth,ps,dummyfunc,space)
    p1=Population(FMsynth,ps,dummyfunc,space)
    rec=Recorder(p0)
    
elif problem == 'necklace':
    space=simple_searchspace(ndim, 0., 360.)
    p0=Population(necklace,ps,dummyfunc,space)
    p1=Population(necklace,ps,dummyfunc,space)
    rec=Recorder(p0)

elif problem == 'hilly':
    space=simple_searchspace(ndim, 0., 360.)
    p0=Population(hilly,ps,dummyfunc,space)
    p1=Population(hilly,ps,dummyfunc,space)
    rec=Recorder(p0)