Пример #1
0
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)
for dude in pD:
    dude.plot_FMsynth_solution()


"""
An interesting next step  would be inplementing the option of more than 6
problem dimensions ... probably one might also be able to convince oneself that
the problem complexity grows very nonlinearily with problem dimension
"""

Пример #2
0
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
# --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --
"""
The really good thing about this FM synthesis test problem is that it is a
difficult six-dimensional test problem, but it is easy to plot a solution
candidate and judge at the first glance whether a solution is good or not. I
think, how essential the combination of these two properties is, cannot be
stressed enough.
Пример #3
0
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
# --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --
"""
The really good thing about this FM synthesis test problem is that it is a
difficult six-dimensional test problem, but it is easy to plot a solution
candidate and judge at the first glance whether a solution is good or not. I
think, how essential the combination of these two properties is, cannot be
stressed enough.