Ejemplo n.º 1
0
        return True # if it has exited the loop, the genes are valid


if __name__ == '__main__':

    # Test of the GA's performance over CEC2005's F3

    import time
    from optproblems import cec2005

    bounds = [ [-100 for i in range(10)], [100 for i in range(10)] ] # 10-dimensional sphere (optimum: 0)

    start = time.time()

    # Initialization
    es = CMAES(cec2005.F3(10), bounds, crit="min", optimum=-450, tol=1e-08)
    es.execute()
    results = es.results

    print("CMA-ES: for criterion = " + es.crit + ", reached optimum of " + str(results["minFits"][-1]) +
    " (error of " + str(results["errors"][-1]) + ") (points " + str(results["minPoints"][-1]) + ") with " + str(results["generations"][-1]) + " generations" +
    " and " + str(results["FESCounts"][-1]) + " fitness evaluations" )

    end = time.time()
    print("time:" + str(end - start))


    # import sys
    # sys.path.append("../../cec2014/python") # Fedora
    # # sys.path.append("/mnt/c/Users/Lucas/Documents/git/cec2014/python") # Windows
    # import cec2014
Ejemplo n.º 2
0
from models import AdaptiveGA
from optproblems import cec2005
from os import makedirs
import statistics
import csv

if __name__ == '__main__':

    dims = 10
    bounds = [ [-100 for i in range(dims)], [100 for i in range(dims)] ]
    functions = [ cec2005.F1(dims), cec2005.F2(dims), cec2005.F3(dims), cec2005.F4(dims), cec2005.F5(dims)]
    optimums = [-450, -450, -450, -450, -310]
    FESThresholds = [0, 0.001, 0.01, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1]
    numRuns = 25


    # Creating result path
    pathName = "Results/AGA"
    makedirs(pathName, exist_ok=True)

    # Initializing result files

    tableFileName = pathName + "/AGA_" + str(dims) + "D.csv"

    with open(tableFileName, "w") as resultsFile:

        writer = csv.writer(resultsFile, delimiter = ',')

        writer.writerow( ["Fi_10D", "Best", "Worst", "Median", "Mean", "Std_Dev", "Success_Rate"] )

Ejemplo n.º 3
0
from models import ArtificialBeeColony
from optproblems import cec2005
from os import makedirs
import statistics
import csv

if __name__ == '__main__':

    dims = 10
    bounds = [[-100 for i in range(dims)], [100 for i in range(dims)]]
    functions = [
        cec2005.F1(dims),
        cec2005.F2(dims),
        cec2005.F3(dims),
        cec2005.F4(dims),
        cec2005.F5(dims)
    ]
    optimums = [-450, -450, -450, -450, -310]
    FESThresholds = [
        0, 0.001, 0.01, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1
    ]
    numRuns = 25

    # Creating result path
    pathName = "Results/ABC"
    makedirs(pathName, exist_ok=True)

    # Initializing result files

    tableFileName = pathName + "/ABC_" + str(dims) + "D.csv"