Пример #1
0
N=6
#p2a=Population(Individual,N,parabolic,searchspace2)
#p3a=Population(Individual,N,parabolic,searchspace3)
p5a=Population(Individual,N,parabolic,searchspace5)
p5b=Population(Individual,N,parabolic,searchspace5)

npr.seed(1)
p5a.marker_genes()
p5b.marker_genes(offset=10)

print 'printing results of get_DNAs()'
print p5a.get_DNAs()
print p5b.get_DNAs()
print '\n'
print 'using p.print_stuff() and p.print_stuff(slim_True)'
p5a.print_stuff(slim=True)
print '\n\nHere comes p5a'
p5a.print_stuff()
print '\nHere comes p5b'
p5b.print_stuff()
print 2*'\n'

print "filling p5a with crossed-over DNAs from first and last of p5b"
parentA=p5b[0]
parentB=p5b[-1]
for dude in p5a:
    dude.CO_from(parentA,parentB)
p5a.print_stuff()

print 'restoring initial setting'
p5a.marker_genes()
Пример #2
0
             ('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))

ps=4   # population size
dim=len(searchspace)  # search space dimension

pC=Population(FMsynthC,ps,dummyfunc,searchspace)
pC.set_ncase(1)
pC.new_random_genes()
pC.eval_all()
print 'DNAs of pC:'
print pC.get_DNAs()
pC.print_stuff(slim=True)
for dude in pC:
    dude.plot_FMsynth_solution()


# and the modified version
pD=Population(FMsynthC,ps,dummyfunc,searchspace)
pD.set_ncase(2)
for dude in pD:
    dude.w[1]=4.7
    dude.initialize_target()
pD.copy_otherpop(pC)
pD.eval_all()
print 'DNAs of pD:'
print pD.get_DNAs()
pD.print_stuff(slim=True)
Пример #3
0
# 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))

ps = 4  # population size
dim = len(searchspace)  # search space dimension

# now let's create a population to test version A of the objective function implementation
pA = Population(Individual, ps, FMsynthA, searchspace)
pA.new_random_genes()
pA.eval_all()
print 'DNAs of pA:'
print pA.get_DNAs()
pA.print_stuff(slim=True)

# and here the objective function version B and another population to test it
problem_instance = FMsynthB()
objfuncB = problem_instance.call
pB = Population(Individual, ps, objfuncB, searchspace)
pB.copy_otherpop(pA)
pB.eval_all()
print 'DNAs of pB:'
print pB.get_DNAs()
pB.print_stuff(slim=True)

# --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --
#--- plot routine: solution candidate visualisation
# --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --
"""
Пример #4
0
             ('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))

ps=4   # population size
dim=len(searchspace)  # search space dimension

# now let's create a population to test version A of the objective function implementation
pA=Population(Individual,ps,FMsynthA,searchspace)
pA.new_random_genes()
pA.eval_all()
print 'DNAs of pA:'
print pA.get_DNAs()
pA.print_stuff(slim=True)

# and here the objective function version B and another population to test it
problem_instance=FMsynthB()
objfuncB=problem_instance.call
pB=Population(Individual,ps,objfuncB,searchspace)
pB.copy_otherpop(pA)
pB.eval_all()
print 'DNAs of pB:'
print pB.get_DNAs()
pB.print_stuff(slim=True)


# --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --
#--- plot routine: solution candidate visualisation
# --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --