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 """ domain = [-5, 5] dim=2 ea = SSGA(domain=domain, size=60, dim=dim, fitness=fitness_sphere) ea.run(maxeval=dim*10000) [bestsol, bestfit] = ea.getBest() print "Best: %f\n" %bestfit
def main(): """ Main program """ parser = OptionParser() parser.add_option("-f", "--function", action="store", type="int", dest="function", help="set the function to optimise", metavar="FUNCTION") domain = [-5, 5] dim=10 ea = SSGA(domain=domain, size=60, dim=dim, fitness=fitness_sphere) ea.run(maxeval=dim*10000) [bestsol, bestfit] = ea.getBest() print "Best: %e\n" %bestfit