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"
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"] )
} if __name__ == '__main__': # Test of the PSO's performance over CEC2005's F1 (shifted sphere) import time from optproblems import cec2005 np.seterr("raise") # any calculation error immediately stops the execution bounds = [[-100 for i in range(10)], [100 for i in range(10)]] # 10-dimensional sphere (optimum: 0) start = time.time() # Initialization SSO = SocialSpiderOptimization(cec2005.F2(10), bounds, popSize=30, PF=0.7) SSO.execute() results = SSO.results print("SSO: for criterion = " + SSO.crit + ", reached optimum of " + str(results["bestFits"][-1]) + " (error of " + str(results["errors"][-1]) + ") (points " + str(results["bestPoints"][-1]) + ") with " + str(results["generations"][-1]) + " generations" + " and " + str(results["FESCounts"][-1]) + " fitness evaluations") end = time.time() print("time:" + str(end - start))