Beispiel #1
0
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()
Beispiel #2
0
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
Beispiel #3
0
    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.
numberOfTimeSteps = 100