popSize = 30 bounds = [-100, 100] optimum = -310 selection_pressure = .9 archive_size = popSize evaporation_rate = 0.7 nrSample = 10 parameters = {"selection_pressure": selection_pressure, "archive_size":archive_size, "evaporation_rate": evaporation_rate, "nrSample": nrSample} function_name = "F5" savePathParameters = Path("plots/acor_parameters.csv") savePathReporter = Path("plots/acor_statistics_10.csv") savePathEvolution = Path("plots/%s_acor_evolution_error.csv"%(function_name)) f1 = cec2005.F5(dim) n_runs = 25 error_list = [] error_evolution_list = [] fes_list = [] success_count = 0 for i in range(n_runs): ant_colony = ACOR(f1, popSize, dim, bounds, parameters, optimum=optimum) error, success, error_evolution, fes = ant_colony.run(show_info=True) error_list.append(error) error_evolution_list.append(error_evolution) fes_list.append(fes) success_count += success success_rate = success_count/n_runs print(fes_list, error_evolution_list)
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"] )
def evaluate(self, x): f1 = cec2005.F5(self.dim) self.count_fes += 1 return f1(x)