def main(): """ Main program """ args = ArgsCEC05() if args.hasError: args.print_help_exit() fun = args.function dim = args.dimension times = args.times print "Function: %d" % fun print "Dimension: %d" % dim print "Times: %d" % times cec2005.config(fun, dim) domain = cec2005.domain(fun) # domain = [-5, 5] print "Domain: ", domain # dim=10 ea = SSGA(domain=domain, size=60, dim=dim, fitness=cec2005.evaluate) for x in xrange(times): ea.run(maxeval=dim * 10000) [bestsol, bestfit] = ea.getBest() print "BestSol: ", bestsol print "BestFitness: %e" % bestfit ea.reset()
def main(): """ Main program """ args = ArgsCEC05() if args.hasError: args.print_help_exit() fun = args.function dim = args.dimension print "Function: %d" %fun print "Dimension: %d" %dim cec2005.config(fun, dim) domain = cec2005.domain(fun) # domain = [-5, 5] print "Domain: ", domain # dim=10 for x in xrange(25): bestsol,bestfit = ipopcmaes(cec2005.evaluate,domain,dim,maxevals=dim*10000) print "BestSol: ", bestsol print "BestFitness: %e" %bestfit print "%e" %bestfit
#import libhello #print libhello.greet() #planet = libhello.World() #planet.set('howdy') #print planet.greet() import libpycec2005 as cec2005 import numpy as np for f in range(1,26): cec2005.config(f, 30) print cec2005.isBound() x = np.random.uniform(-5.0, 5.0, 30) x = np.zeros(30) print cec2005.evaluate(x)
if len(sys.argv)<=1: sys.exit("Lacking the function value") fun = int(sys.argv[1]) if (fun <= 0 or fun > 25): sys.exit("Function %d non valide" %fun) if len(sys.argv)>2: fname = sys.argv[2] else: fname = 'output' # Init cec2005 dim=2 cec2005.config(fun, dim) domain = cec2005.domain(fun) #domain = [-5,5] #function_fitness = fitness_sphere #function_fitness = fitness_rosenbrock function_fitness = cec2005.evaluate def algorithm_fitness(sol): global eval eval += 1 global function_fitness return function_fitness(sol) ea = SSGA(domain=domain, size=50, dim=dim, fitness=algorithm_fitness) # Initialize variables needed to create and store the example data set.