# This is the code that calculates ranking and percentage quality measure of optimization algorithms, which was described in: # Rafał Biedrzycki: Revisiting CEC 2022 ranking: A new ranking method and influence of parameter tuning # https://www.sciencedirect.com/science/article/pii/S2210650224001615 # author: Rafał Biedrzycki # license: MIT # input data format: https://github.com/P-N-Suganthan/2022-SO-BO/blob/main/CEC2022%20TR.pdf # According to the rules of the CEC 2022 SOBC competition, all values below 1e-8 are set here to 1e-8 # As I believe that: # “a difference is a difference only if it makes a difference.” # ― Darrell Huff, How to Lie with Statistics # the error values are rounded to 5 significant digits, and the FES (objective functions evaluations) are rounded to tenths # exemplary results to analyze globalAlgRanks = list( "simplifiedTuned/onlyIDEcorrItMaxWithoutSortsNoIDEbdmutNoRandxr3_3per"=0, "CEC2022_EA4eig_CORRECTED/CEC2022_EA4eig_CORRECTED"=0 ) algNames=names(globalAlgRanks) NUM_OF_ALGS=length(globalAlgRanks) #values for CEC2022 MAX_FUN_NMBR = 12 NMBR_OF_RUNS = 30 DIMS=c(10,20) MaxFEStab = c(2e5,1e6) STOP_FIT = 1e-8 NEXT_LEVEL_WEIGHT = 0.01 #weight for less important criterion SINIF_DIGITS = 5 #for rounding error. signif(12345,3)==12300; signif(0.000000012345,3)==0.0000000123 SINIF_DIGITS4FES = -1 #for rounding FES. round(12345, -1)==12340; NUM_OF_THRES=51 #create thresholds thresholds<- 10^seq( log10( 1e3), log10( 10^-8 ), length.out= NUM_OF_THRES) globAlgMarks = list() globAlgMarks2Disp = list() algMarks4dim= list() algMarks4dim2Disp= list() algMarks4fun= list("10"=list("1"=0.0), "20"=list("1"=0.0)) algMarks4fun2Disp= list("10"=list("1"=0.0), "20"=list("1"=0.0)) for( ALG_NR in 1:length(globalAlgRanks)){ algName=algNames[ALG_NR] numOfGlobOptFound4alg = 0 numOfThresAcchieved4alg = 0 numOfUsedEvals4alg = 0 perOfFreeEvals4alg = 0 for( DIM in DIMS ){ if(DIM==10){ MaxFES = MaxFEStab[1] }else{ MaxFES = MaxFEStab[2] } numOfGlobOptFound4dim = 0 numOfThresAcchieved4dim = 0 numOfUsedEvals4dim = 0 for( funNmbr in 1:MAX_FUN_NMBR ){ bests4runs =vector( mode="numeric", length=NMBR_OF_RUNS ) stops4runs =vector( mode="numeric", length=NMBR_OF_RUNS ) res=read.table(paste0(names(globalAlgRanks)[ALG_NR], "_",funNmbr, "_", DIM, ".txt")) res[resMaxFES]=MaxFES bests4runs = signif(res[16,], SINIF_DIGITS) stops4runs[bests4runs>STOP_FIT] = MaxFES numOfGlobOptFound4fun = length(bests4runs[bests4runs==STOP_FIT]) res4fun = numOfGlobOptFound4fun/NMBR_OF_RUNS*100 numOfThresAcchieved4fun=0 for( thresh in thresholds){ numOfThresAcchieved4fun=numOfThresAcchieved4fun + sum(bests4runs<=thresh) } perOfAchThres4fun = numOfThresAcchieved4fun/(NMBR_OF_RUNS*length(thresholds))*100 res4fun = res4fun+perOfAchThres4fun*NEXT_LEVEL_WEIGHT numOfUsedEvals4fun = sum(stops4runs) perOfFreeEvals4fun = 100-numOfUsedEvals4fun/(MaxFES*NMBR_OF_RUNS)*100 res4fun = res4fun+perOfFreeEvals4fun*NEXT_LEVEL_WEIGHT*NEXT_LEVEL_WEIGHT numOfGlobOptFound4dim = numOfGlobOptFound4dim + numOfGlobOptFound4fun numOfThresAcchieved4dim = numOfThresAcchieved4dim + numOfThresAcchieved4fun numOfUsedEvals4dim = numOfUsedEvals4dim + numOfUsedEvals4fun algMarks4fun[[as.character(DIM)]][[as.character(funNmbr)]][algName] = res4fun algMarks4fun2Disp[[as.character(DIM)]][[as.character(funNmbr)]][algName] = paste(round(numOfGlobOptFound4fun/NMBR_OF_RUNS*100), round(perOfAchThres4fun), round(perOfFreeEvals4fun)) }#for( funNmbr res4dim = numOfGlobOptFound4dim/(NMBR_OF_RUNS*MAX_FUN_NMBR)*100 perOfAchThres4dim = numOfThresAcchieved4dim/(NMBR_OF_RUNS*MAX_FUN_NMBR*length(thresholds))*100 res4dim = res4dim+perOfAchThres4dim*NEXT_LEVEL_WEIGHT perOfFreeEvals4dim = 100-numOfUsedEvals4dim/(MaxFES*NMBR_OF_RUNS*MAX_FUN_NMBR)*100 res4dim = res4dim+perOfFreeEvals4dim*NEXT_LEVEL_WEIGHT*NEXT_LEVEL_WEIGHT numOfGlobOptFound4alg = numOfGlobOptFound4alg + numOfGlobOptFound4dim numOfThresAcchieved4alg = numOfThresAcchieved4alg + numOfThresAcchieved4dim numOfUsedEvals4alg = numOfUsedEvals4alg + numOfUsedEvals4dim algMarks4dim[[as.character(DIM)]][algName] = res4dim algMarks4dim2Disp[[as.character(DIM)]][algName] = paste(round(numOfGlobOptFound4dim/(NMBR_OF_RUNS*MAX_FUN_NMBR)*100), round(perOfAchThres4dim), round(perOfFreeEvals4dim)) perOfFreeEvals4alg=perOfFreeEvals4alg+perOfFreeEvals4dim }#for( DIM res4alg = numOfGlobOptFound4alg/(NMBR_OF_RUNS*MAX_FUN_NMBR*length(DIMS))*100 perOfAchThres4alg = numOfThresAcchieved4alg/(NMBR_OF_RUNS*MAX_FUN_NMBR*length(DIMS)*length(thresholds))*100 res4alg = res4alg+perOfAchThres4alg*NEXT_LEVEL_WEIGHT perOfFreeEvals4alg = perOfFreeEvals4alg/length(DIMS) res4alg = res4alg+perOfFreeEvals4alg*NEXT_LEVEL_WEIGHT*NEXT_LEVEL_WEIGHT globAlgMarks[algName] = res4alg globAlgMarks2Disp[algName] = paste(round(numOfGlobOptFound4alg/(NMBR_OF_RUNS*MAX_FUN_NMBR*length(DIMS))*100), round(perOfAchThres4alg), round(perOfFreeEvals4alg)) }#for alg print("Results for each function") for( DIM in DIMS ){ for( funNmbr in 1:MAX_FUN_NMBR ){ algMarks4funTmp = algMarks4fun[[as.character(DIM)]][[as.character(funNmbr)]] algMarks4fun2DispTmp = algMarks4fun2Disp[[as.character(DIM)]][[as.character(funNmbr)]] ord=order(unlist(algMarks4funTmp), decreasing = T) print( paste( "DIM:",DIM," fun:", funNmbr, paste(names(algMarks4fun2DispTmp[ord]), algMarks4fun2DispTmp[ord], sep = " = ", collapse = ", "))) } } print("Results for each dimensionality") for( DIM in DIMS ){ algMarks4dimTmp = algMarks4dim[[as.character(DIM)]] algMarks4dim2DispTmp = algMarks4dim2Disp[[as.character(DIM)]] ord=order(unlist(algMarks4dimTmp), decreasing = T) print( paste( "DIM:",DIM,paste(names(algMarks4dim2DispTmp[ord]), algMarks4dim2DispTmp[ord], sep = " = ", collapse = ", "))) } print("Final, aggregated results") ord=order(unlist(globAlgMarks), decreasing = T) print( paste(names(globAlgMarks2Disp[ord]), globAlgMarks2Disp[ord], sep = " = ", collapse = ", "))