mirror of
https://github.com/ejeanboris/MDAF.git
synced 2025-07-30 15:08:37 +00:00
Reorganised the code into a PyPI package format
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -15,3 +15,4 @@ pkg/
|
||||
src/
|
||||
snippets/
|
||||
|
||||
PackageCode/setup.py
|
||||
|
@ -42,7 +42,7 @@ class counter:
|
||||
self.count += 1
|
||||
return self.func(*args, **kwargs)
|
||||
|
||||
def simulate(algName, algPath, funcname, funcpath, objs, args, initpoint):
|
||||
def simulate(algName, algPath, funcname, funcpath, args, initpoint):
|
||||
# loading the heuristic object into the namespace and memory
|
||||
spec = importlib.util.spec_from_file_location(algName, algPath)
|
||||
heuristic = importlib.util.module_from_spec(spec)
|
||||
@ -63,7 +63,7 @@ def simulate(algName, algPath, funcname, funcpath, objs, args, initpoint):
|
||||
#This timer calculates directly the CPU time of the process (Nanoseconds)
|
||||
tic = time.process_time_ns()
|
||||
# running the test by calling the heuritic script with the test function as argument
|
||||
quality = heuristic.main(testfunc, objs, initpoint, args)
|
||||
quality = heuristic.main(testfunc, initpoint, args)
|
||||
toc = time.process_time_ns()
|
||||
# ^^ The timer ends right above this; the CPU time is then calculated below by simple difference ^^
|
||||
|
||||
@ -78,34 +78,61 @@ def simulate(algName, algPath, funcname, funcpath, objs, args, initpoint):
|
||||
converged = 0
|
||||
return cpuTime, quality, numCalls, converged
|
||||
|
||||
def measure(heuristicpath, heuristic_name, funcpath, funcname, objs, args, scale, connection):
|
||||
def measure(heuristicpath, funcpath, args, connection):
|
||||
'''
|
||||
This function runs each optimization process of the heuristic with one test function
|
||||
This function runs a set of optimization flows for each test function. it returns the mean and standard deviation of the performance results
|
||||
'''
|
||||
|
||||
#defining the heuristic's name
|
||||
heuristic_name = path.splitext(path.basename(heuristicpath))[0]
|
||||
|
||||
#defining the test function's name
|
||||
funcname = path.splitext(path.basename(funcpath))[0]
|
||||
|
||||
# Seeding the random module for generating the initial point of the optimizer: Utilising random starting point for experimental validity
|
||||
r.seed(int(time.time()))
|
||||
|
||||
# guetting the representation of the function
|
||||
funcChars = representfunc(funcpath)
|
||||
|
||||
n = funcChars['dimmensions']
|
||||
upper = funcChars['upper']
|
||||
lower = funcChars['lower']
|
||||
|
||||
if upper is not list: upper = [upper for i in range(n)]
|
||||
if lower is not list: lower = [lower for i in range(n)]
|
||||
|
||||
|
||||
scale = list()
|
||||
for i in range(n):
|
||||
scale.append(upper[i] - lower[i])
|
||||
|
||||
|
||||
# Defining random initial points to start testing the algorithms
|
||||
initpoints = [[r.random() * scale, r.random() * scale] for run in range(30)] #update the inner as [r.random() * scale for i in range(testfuncDimmensions)]
|
||||
initpoints = [[r.random() * scale[i] + lower[i] for i in range(n)] for run in range(30)] #update the inner as [r.random() * scale for i in range(testfuncDimmensions)]
|
||||
# building the iterable arguments
|
||||
partfunc = partial(simulate, heuristic_name, heuristicpath, funcname, funcpath, objs, args)
|
||||
|
||||
with multiprocessing.Pool(processes = 3) as pool:
|
||||
partfunc = partial(simulate, heuristic_name, heuristicpath, funcname, funcpath, args)
|
||||
|
||||
n_proc = multiprocessing.cpu_count() # Guetting the number of cpus
|
||||
with multiprocessing.Pool(processes = n_proc) as pool:
|
||||
# running the simulations
|
||||
newRun = pool.map(partfunc,initpoints)
|
||||
|
||||
cpuTime = [resl[0] for resl in newRun]
|
||||
quality = [resl[1] for resl in newRun]
|
||||
numCalls = [resl[2] for resl in newRun]
|
||||
converged = [resl[3] for resl in newRun]
|
||||
cpuTime = array([resl[0] for resl in newRun])
|
||||
quality = array([resl[1] for resl in newRun])
|
||||
numCalls = array([resl[2] for resl in newRun])
|
||||
converged = array([resl[3] for resl in newRun])
|
||||
|
||||
cpuTime = cpuTime[~(isnan(cpuTime))]
|
||||
quality = quality[~(isnan(quality))]
|
||||
numCalls = numCalls[~(isnan(numCalls))]
|
||||
converged = converged[~(isnan(converged))]
|
||||
|
||||
results = dict()
|
||||
results['cpuTime'] = array([statistics.mean(cpuTime), statistics.stdev(cpuTime)])
|
||||
results['quality'] = array([statistics.mean(quality), statistics.stdev(quality)])
|
||||
results['numCalls'] = array([statistics.mean(numCalls), statistics.stdev(numCalls)])
|
||||
results['convRate'] = array([statistics.mean(converged), statistics.stdev(converged)])
|
||||
results['cpuTime'] = array([statistics.fmean(cpuTime), statistics.stdev(cpuTime)])
|
||||
results['quality'] = array([statistics.fmean(quality), statistics.stdev(quality)])
|
||||
results['numCalls'] = array([statistics.fmean(numCalls), statistics.stdev(numCalls)])
|
||||
results['convRate'] = array([statistics.fmean(converged), statistics.stdev(converged)])
|
||||
|
||||
connection.send((results,newRun))
|
||||
|
||||
@ -133,7 +160,7 @@ def writerepresentation(funcpath, charas):
|
||||
with open(funcpath,"w") as file:
|
||||
file.write(newContent)
|
||||
|
||||
def representfunc(funcpath):
|
||||
def representfunc(funcpath, forced = False):
|
||||
#defining the function name
|
||||
funcname = path.splitext(path.basename(funcpath))[0]
|
||||
# loading the function to be represented
|
||||
@ -153,6 +180,8 @@ def representfunc(funcpath):
|
||||
if not ('Represented' in results):
|
||||
print("Warning, the Representation of the Test Function has not been specified\n===\n******Calculating the Characteristics******")
|
||||
n = int(results['dimmensions'])
|
||||
blocks = int(1+10/n)
|
||||
if blocks< 3: blocks=3
|
||||
|
||||
# Importing FLACCO using rpy2
|
||||
flacco = importr('flacco')
|
||||
@ -164,12 +193,17 @@ def representfunc(funcpath):
|
||||
r_unlist = robjs.r['unlist']
|
||||
rtestfunc = rinterface.rternalize(funcmodule.main)
|
||||
|
||||
###
|
||||
lower = r_unlist(rvector(results['lower']))
|
||||
upper = r_unlist(rvector(results['upper']))
|
||||
X = flacco.createInitialSample(n_obs = 500, dim = n, control = rlist(**{'init_sample.type' : 'lhs', 'init_sample.lower' : lower, 'init_sample.upper' : upper}))
|
||||
# Verify if a list of limits has been specified for all dimensions or if all dimensions will use the same boundaries
|
||||
if (type(results['lower']) is list):
|
||||
lowerval = r_unlist(rvector(results['lower']))
|
||||
upperval = r_unlist(rvector(results['upper']))
|
||||
else:
|
||||
lowerval = results['lower']
|
||||
upperval = results['upper']
|
||||
|
||||
X = flacco.createInitialSample(n_obs = 500, dim = n, control = rlist(**{'init_sample.type' : 'lhs', 'init_sample.lower' : lowerval, 'init_sample.upper' : upperval}))
|
||||
y = rapply(X, 1, rtestfunc)
|
||||
testfuncobj = flacco.createFeatureObject(X = X, y = y, fun = rtestfunc, lower = lower, upper = upper, blocks = 10)
|
||||
testfuncobj = flacco.createFeatureObject(**{'X': X, 'y': y, 'fun': rtestfunc, 'lower': lowerval, 'upper': upperval, 'blocks': blocks, 'force': forced})
|
||||
|
||||
# these are the retained features. Note that some features are being excluded for being problematic and to avoid overcomplicating the neural network.... the feature sets are redundant and the most relevant ones have been retained
|
||||
# the excluded feature sets are: 'bt', 'ela_level'
|
||||
@ -186,7 +220,13 @@ def representfunc(funcpath):
|
||||
|
||||
|
||||
|
||||
def doe(heuristicpath, heuristic_name, testfunctionpaths, funcnames, objs, args, scale):
|
||||
def doe(heuristicpath, testfunctionpaths, args):
|
||||
|
||||
#defining the function's name
|
||||
funcnames = [path.splitext(path.basename(funcpath))[0] for funcpath in testfunctionpaths]
|
||||
|
||||
#defining the heuristic's name
|
||||
heuristic_name = path.splitext(path.basename(heuristicpath))[0]
|
||||
|
||||
# logic variables to deal with the processes
|
||||
proc = []
|
||||
@ -197,20 +237,18 @@ def doe(heuristicpath, heuristic_name, testfunctionpaths, funcnames, objs, args,
|
||||
funcname = funcnames[idx]
|
||||
# Creating the connection objects for communication between the heuristic and this module
|
||||
connections[funcname] = multiprocessing.Pipe(duplex=False)
|
||||
proc.append(multiprocessing.Process(target=measure, name=funcname, args=(heuristicpath, heuristic_name, funcpath, funcname, objs, args, scale, connections[funcname][1])))
|
||||
proc.append(multiprocessing.Process(target=measure, name=funcname, args=(heuristicpath, funcpath, args, connections[funcname][1])))
|
||||
|
||||
# defining the response variables
|
||||
responses = {}
|
||||
failedfunctions = {}
|
||||
processtiming = {}
|
||||
|
||||
# defining some logic variables
|
||||
|
||||
# Starting the subprocesses for each testfunction
|
||||
for idx,process in enumerate(proc):
|
||||
process.start()
|
||||
|
||||
# Waiting for all the runs to be
|
||||
# multiprocessing.connection.wait([process.sentinel for process in proc])
|
||||
# Waiting for all the runs to be done
|
||||
for process in proc: process.join()
|
||||
|
||||
for process in proc:
|
||||
@ -227,26 +265,8 @@ def doe(heuristicpath, heuristic_name, testfunctionpaths, funcnames, objs, args,
|
||||
print("\n\n||||| Responses: [mean,stdDev] |||||")
|
||||
for process in proc: print(process.name + "____\n" + str(responses[process.name][0]) + "\n_________________")
|
||||
|
||||
#return output
|
||||
#return the performance values
|
||||
return responses
|
||||
|
||||
if __name__ == '__main__':
|
||||
heuristicpath = "SampleAlgorithms/SimmulatedAnnealing.py"
|
||||
heuristic_name = "SimmulatedAnnealing"
|
||||
testfunctionpaths = ["TestFunctions/Bukin2.py", "TestFunctions/Bukin4.py", "TestFunctions/Brown.py"]
|
||||
funcnames = ["Bukin2", "Bukin4", "Brown"]
|
||||
# testfunctionpaths = ["/home/remi/Documents/MDAF-GitLAB/SourceCode/TestFunctions/Bukin4.py"]
|
||||
# funcnames = ["Bukin4"]
|
||||
|
||||
|
||||
|
||||
objs = 0
|
||||
args = {"high": 200, "low": -200, "t": 1000, "p": 0.95}
|
||||
scale = 1
|
||||
|
||||
# data = doe (heuristicpath, heuristic_name, testfunctionpaths, funcnames, objs, args, scale)
|
||||
# print([point[2] for point in data['Bukin2'][1]])
|
||||
representfunc("TestFunctions/Bukin2.py")
|
||||
|
||||
|
||||
# %%
|
@ -31,15 +31,15 @@ def Quality(Sc,objective,func):
|
||||
print("Error is: "+str(error))
|
||||
return 1/abs(error)
|
||||
|
||||
def main(func, obj, S, args):
|
||||
def main(func, S, args):
|
||||
r.seed(int(time.time()))
|
||||
route = list()
|
||||
#Parsing arguments
|
||||
y = obj
|
||||
high = args["high"]
|
||||
low = args["low"]
|
||||
y = args["objs"]
|
||||
t = args["t"]
|
||||
p = args["p"]
|
||||
high = 20
|
||||
low = -20
|
||||
|
||||
Best = list()
|
||||
Best[:] = cp.deepcopy(S)
|
||||
@ -47,7 +47,7 @@ def main(func, obj, S, args):
|
||||
route.append(Best[:])
|
||||
while True:
|
||||
print('\n\n\n')
|
||||
R = tweak(cp.deepcopy(S),p,sigma,high,low)
|
||||
R = tweak(cp.deepcopy(S),p,sigma,high, low)
|
||||
print(R)
|
||||
print(S)
|
||||
Qr = Quality(R,y,func)
|
Binary file not shown.
33
PackageCode/MDAF/TestFunctions/Brown.py
Normal file
33
PackageCode/MDAF/TestFunctions/Brown.py
Normal file
@ -0,0 +1,33 @@
|
||||
def main(args):
|
||||
'''
|
||||
|
||||
#_# dimmensions: 6
|
||||
#_# upper: 4
|
||||
#_# lower: -1
|
||||
#_# minimum: 0
|
||||
|
||||
|
||||
#_# cm_angle: array([[4.38674589e+00], [1.19556006e+00], [4.47966360e+00], [1.19983352e+00], [5.60286032e+00], [1.07792176e+01], [2.25826784e-03], [2.51639450e-02], [0.00000000e+00], [2.62000000e-01]])
|
||||
#_# cm_conv: array([[0.33635988], [0.16095749], [0.76392901], [0.23607099], [0. ], [0.57 ]])
|
||||
#_# cm_grad: array([[0.74319842], [0.11137735], [0. ], [0.095 ]])
|
||||
#_# ela_conv: array([[ 9.80000000e-01], [ 0.00000000e+00], [-2.06944119e+18], [ 2.06944119e+18], [ 1.00000000e+03], [ 1.12000000e-01]])
|
||||
#_# ela_curv: array([[4.79755856e+00], [1.34573105e+03], [5.12834662e+19], [3.70342074e+07], [3.86444487e+12], [8.88644003e+21], [5.30415946e+20], [0.00000000e+00], [3.81373465e+00], [4.90886432e+02], [5.97651830e+14], [1.97651206e+05], [9.10648718e+08], [7.52108388e+16], [5.45247010e+15], [1.94000000e-01], [4.54265125e+00], [3.29125394e+03], [9.25189949e+46], [2.18081469e+07], [9.89777937e+09], [2.74236176e+49], [1.35682556e+48], [5.00000000e-02], [1.07656000e+05], [1.04290000e+01]])
|
||||
#_# ela_distr: array([[1.33769544e+01], [1.94701124e+02], [1.80000000e+01], [0.00000000e+00], [2.90000000e-02]])
|
||||
#_# ela_local: array([[2.70000000e+02], [9.00000000e-01], [2.35864648e-04], [4.89568303e-02], [8.33333333e-02], [3.40768278e-03], [3.33333333e-03], [1.17000000e+02], [2.08000000e+02], [2.95273333e+02], [2.73000000e+02], [3.77000000e+02], [7.28000000e+02], [1.02839577e+02], [8.88520000e+04], [7.16600000e+00]])
|
||||
#_# ela_meta: array([[ 2.12758964e-02], [-6.21915065e+18], [ 1.35144338e+16], [ 2.24256868e+18], [ 1.65938782e+02], [ 6.15453221e-02], [ 5.94927163e-02], [ 6.24028558e+00], [ 2.43822411e-01], [ 0.00000000e+00], [ 1.50000000e-02]])
|
||||
#_# basic: array([[ 6.00000000e+00], [ 5.00000000e+02], [-1.00000000e+00], [-1.00000000e+00], [ 4.00000000e+00], [ 4.00000000e+00], [ 2.88961528e+00], [ 4.10691709e+20], [ 3.00000000e+00], [ 3.00000000e+00], [ 7.29000000e+02], [ 3.96000000e+02], [ 1.00000000e+00], [ 0.00000000e+00], [ 0.00000000e+00]])
|
||||
#_# disp: array([[ 0.54940333], [ 0.63595834], [ 0.77089952], [ 0.89491857], [ 0.53989005], [ 0.63417083], [ 0.7646051 ], [ 0.88560301], [-2.18734742], [-1.76718039], [-1.1121306 ], [-0.5101005 ], [-2.24631371], [-1.78602329], [-1.14922704], [-0.55850027], [ 0. ], [ 0.01 ]])
|
||||
#_# limo: array([[ nan], [ nan], [ nan], [ nan], [ nan], [ nan], [ nan], [ nan], [ nan], [ nan], [ nan], [ nan], [0. ], [0.033]])
|
||||
#_# nbc: array([[ 0.47974042], [ 0.96061989], [ 0.34786143], [ 0.0693798 ], [-0.0889751 ], [ 0. ], [ 0.04 ]])
|
||||
#_# pca: array([[1. ], [1. ], [0.14285714], [1. ], [0.18943524], [0.18942493], [1. ], [0.17000728], [0. ], [0.003 ]])
|
||||
#_# gcm: array([[1.00000000e+00], [1.37174211e-03], [5.41838134e-01], [0.00000000e+00], [5.43209877e-01], [5.43209877e-01], [5.43209877e-01], [5.43209877e-01], [ nan], [5.43209877e-01], [5.43209877e-01], [5.43209877e-01], [5.43209877e-01], [ nan], [5.43209877e-01], [5.43209877e-01], [5.43209877e-01], [5.43209877e-01], [5.43209877e-01], [ nan], [5.43209877e-01], [5.43209877e-01], [1.37174211e-03], [0.00000000e+00], [7.93900000e+00], [1.00000000e+00], [1.37174211e-03], [5.41838134e-01], [0.00000000e+00], [5.43209877e-01], [5.43209877e-01], [5.43209877e-01], [5.43209877e-01], [ nan], [5.43209877e-01], [5.43209877e-01], [5.43209877e-01], [5.43209877e-01], [ nan], [5.43209877e-01], [5.43209877e-01], [5.43209877e-01], [5.43209877e-01], [5.43209877e-01], [ nan], [5.43209877e-01], [5.43209877e-01], [1.37174211e-03], [0.00000000e+00], [7.53700000e+00], [2.00000000e+00], [2.74348422e-03], [9.97256516e-01], [1.00000000e+00], [5.00000000e-01], [5.00000000e-01], [5.00000000e-01], [5.00000000e-01], [0.00000000e+00], [0.00000000e+00], [0.00000000e+00], [0.00000000e+00], [0.00000000e+00], [0.00000000e+00], [0.00000000e+00], [4.88340192e-01], [5.00000000e-01], [5.00000000e-01], [5.11659808e-01], [1.64894585e-02], [1.00000000e+00], [1.00000000e+00], [2.74348422e-03], [0.00000000e+00], [1.21150000e+01]])
|
||||
#_# ic: array([[ 0.57808329], [ nan], [68.69928016], [10.73573574], [ 0.53413655], [ 0. ], [ 0.281 ]])
|
||||
|
||||
#_# Represented: 1
|
||||
|
||||
'''
|
||||
result = 0
|
||||
for i,x in enumerate(args[0:-1]):
|
||||
result += (x**2)**(args[i+1]**2+1) + (args[i+1]**2)**(x**2 + 1)
|
||||
|
||||
return result
|
28
PackageCode/MDAF/TestFunctions/Bukin4.py
Normal file
28
PackageCode/MDAF/TestFunctions/Bukin4.py
Normal file
@ -0,0 +1,28 @@
|
||||
def main(args):
|
||||
'''
|
||||
#_# dimmensions: 2
|
||||
#_# upper: [-5, 3]
|
||||
#_# lower: [-15, -3]
|
||||
#_# minimum: [-10,0]
|
||||
|
||||
|
||||
#_# cm_angle: array([[3.46336319e-01], [1.11596448e-01], [3.32688632e-01], [1.10567852e-01], [1.26709762e+02], [3.96040507e+01], [1.47616482e-01], [9.06041269e-02], [0.00000000e+00], [7.90000000e-02]])
|
||||
#_# cm_conv: array([[0.23809524], [0.19642857], [0.67857143], [0.32142857], [0. ], [0.033 ]])
|
||||
#_# cm_grad: array([[0.81854428], [0.1192788 ], [0. ], [0.052 ]])
|
||||
#_# ela_conv: array([[ 1.00000000e+00], [ 0.00000000e+00], [-1.06441804e+02], [ 1.06441804e+02], [ 1.00000000e+03], [ 1.04000000e-01]])
|
||||
#_# ela_curv: array([[3.20384285e+00], [1.59352986e+02], [3.11716056e+02], [3.16753438e+02], [4.75852875e+02], [5.98482830e+02], [1.80339798e+02], [0.00000000e+00], [3.20382725e+02], [1.59352986e+04], [3.11716055e+04], [3.16753436e+04], [4.75852869e+04], [5.98482828e+04], [1.80339798e+04], [0.00000000e+00], [5.31778742e+06], [4.94191117e+07], [1.07037935e+36], [3.96591773e+08], [6.61335123e+12], [1.60389805e+38], [1.16318553e+37], [0.00000000e+00], [8.40000000e+03], [9.98000000e-01]])
|
||||
#_# ela_distr: array([[ 0.63700187], [-0.86671884], [ 2. ], [ 0. ], [ 0.024 ]])
|
||||
#_# ela_local: array([[9.00000000e+01], [9.00000000e-01], [1.00000000e+00], [1.64410646e-01], [1.00000000e-01], [1.01123596e-02], [1.00000000e-02], [4.50000000e+01], [8.00000000e+01], [8.93000000e+01], [9.00000000e+01], [1.00000000e+02], [1.35000000e+02], [1.65758130e+01], [9.02000000e+03], [7.07000000e-01]])
|
||||
#_# ela_meta: array([[-6.03426790e-03], [ 3.06569525e+02], [ 2.05064239e-02], [ 6.61146864e-01], [ 3.22409635e+01], [-7.94339775e-03], [ 1.00000000e+00], [ 5.33390671e+04], [ 1.00000000e+00], [ 0.00000000e+00], [ 1.40000000e-02]])
|
||||
#_# basic: array([[ 2.00000000e+00], [ 5.00000000e+02], [-1.50000000e+01], [-3.00000000e+00], [-5.00000000e+00], [ 3.00000000e+00], [ 8.36446791e-03], [ 8.95463288e+02], [ 1.00000000e+01], [ 1.00000000e+01], [ 1.00000000e+02], [ 1.00000000e+02], [ 1.00000000e+00], [ 0.00000000e+00], [ 1.00000000e-03]])
|
||||
#_# disp: array([[ 0.90387646], [ 0.87562005], [ 0.80237804], [ 0.81384686], [ 0.90019544], [ 0.85330973], [ 0.74450389], [ 0.74867028], [-0.40830656], [-0.52833206], [-0.83944411], [-0.79072771], [-0.40329912], [-0.59275905], [-1.03243135], [-1.01559546], [ 0. ], [ 0.011 ]])
|
||||
#_# limo: array([[4.17880614e-01], [4.99806181e-03], [2.99599766e+02], [1.70588576e+02], [6.54778826e-02], [5.20933692e-03], [9.01491863e+02], [3.18988622e+03], [9.03063909e+01], [3.88297785e+01], [1.74942209e+02], [5.15283205e-01], [0.00000000e+00], [1.12000000e-01]])
|
||||
#_# nbc: array([[ 0.19285636], [ 0.84080448], [ 0.11842373], [ 0.17016598], [-0.30584099], [ 0. ], [ 0.034 ]])
|
||||
#_# pca: array([[1. ], [1. ], [0.33333333], [1. ], [0.73538694], [0.50398941], [0.99984257], [0.33688393], [0. ], [0.003 ]])
|
||||
#_# gcm: array([[5. ], [0.05 ], [0.95 ], [0.93 ], [0.16376097], [0.2 ], [0.18658697], [0.26119064], [0.03940216], [0.01 ], [0.014 ], [0.01 ], [0.02 ], [0.00547723], [0.07 ], [0.08 ], [0.2 ], [0.21 ], [0.32 ], [0.10024969], [1. ], [0.21551545], [0.01 ], [0. ], [0.091 ], [4. ], [0.04 ], [0.96 ], [0.9 ], [0.10082007], [0.25 ], [0.19083529], [0.51750934], [0.18364899], [0.01 ], [0.025 ], [0.015 ], [0.06 ], [0.02380476], [0.1 ], [0.05 ], [0.25 ], [0.18 ], [0.59 ], [0.23537205], [1. ], [0.17734396], [0.01 ], [0. ], [0.094 ], [4. ], [0.04 ], [0.96 ], [0.88 ], [0.15058257], [0.25 ], [0.22415964], [0.40109815], [0.10875386], [0.01 ], [0.03 ], [0.025 ], [0.06 ], [0.0244949 ], [0.12 ], [0.14 ], [0.25 ], [0.22 ], [0.42 ], [0.13241349], [1. ], [0.40109815], [0.01 ], [0. ], [0.095 ]])
|
||||
#_# ic: array([[ 0.56692136], [ 2.74774775], [116.69898186], [ 2.36736737], [ 0.27710843], [ 0. ], [ 0.228 ]])
|
||||
|
||||
#_# Represented: 1
|
||||
|
||||
'''
|
||||
return 100*args[1]**2+0.01*abs(args[0]+10)
|
@ -4,6 +4,9 @@ from math import sqrt, fabs
|
||||
def main(args):
|
||||
'''
|
||||
#_# dimmensions: 2
|
||||
#_# upper: [-5, 3]
|
||||
#_# lower: [-15, -3]
|
||||
#_# minimum: [-10,1]
|
||||
|
||||
'''
|
||||
return 100*sqrt(fabs(args[1]-0.01*args[0]**2))+0.01*fabs(args[0]+10)
|
BIN
PackageCode/MDAF/TestFunctions/__pycache__/Brown.cpython-39.pyc
Normal file
BIN
PackageCode/MDAF/TestFunctions/__pycache__/Brown.cpython-39.pyc
Normal file
Binary file not shown.
BIN
PackageCode/MDAF/TestFunctions/__pycache__/Bukin4.cpython-39.pyc
Normal file
BIN
PackageCode/MDAF/TestFunctions/__pycache__/Bukin4.cpython-39.pyc
Normal file
Binary file not shown.
0
PackageCode/MDAF/__init__.py
Normal file
0
PackageCode/MDAF/__init__.py
Normal file
BIN
PackageCode/MDAF/__pycache__/__init__.cpython-39.pyc
Normal file
BIN
PackageCode/MDAF/__pycache__/__init__.cpython-39.pyc
Normal file
Binary file not shown.
2
PackageCode/README.md
Normal file
2
PackageCode/README.md
Normal file
@ -0,0 +1,2 @@
|
||||
# MDAF
|
||||
THe desc will go here
|
3
PackageCode/pyproject.toml
Normal file
3
PackageCode/pyproject.toml
Normal file
@ -0,0 +1,3 @@
|
||||
[build-system]
|
||||
requires = ["setuptools>=42", "wheel"]
|
||||
build-backend = "setuptools.build_meta"
|
26
PackageCode/setup.cfg
Normal file
26
PackageCode/setup.cfg
Normal file
@ -0,0 +1,26 @@
|
||||
[metadata]
|
||||
name = MDAF
|
||||
version = 0.1
|
||||
description =A Framework for the Analysis and Benchmarking of Metaheuristics
|
||||
url = https://git.rehounou.ca/remi/MDAF
|
||||
author = Remi Ehounou
|
||||
author_email = remi.ehounou@outlook.com
|
||||
license = MIT
|
||||
long_description = file: README.md
|
||||
long_description_content_type = text/markdown
|
||||
classifiers =
|
||||
Programming Language :: Python :: 3
|
||||
License :: OSI Approved :: MIT License
|
||||
Operating System :: OS Independent
|
||||
|
||||
|
||||
[options]
|
||||
package_dir =
|
||||
= .
|
||||
include_package_data = True
|
||||
packages = find:
|
||||
python_requires = >=3.6
|
||||
install_requires =
|
||||
numpy
|
||||
importlib
|
||||
rpy2 == 3.4.4
|
Binary file not shown.
Binary file not shown.
@ -1 +0,0 @@
|
||||
|
@ -1,10 +0,0 @@
|
||||
def main(args):
|
||||
'''
|
||||
|
||||
#_# dimmensions: 0
|
||||
'''
|
||||
result = 0
|
||||
for i,x in enumerate(args[0:-1]):
|
||||
result += (x**2)**(args[i+1]**2+1) + (args[i+1]**2)**(x**2 + 1)
|
||||
|
||||
return result
|
@ -1,7 +0,0 @@
|
||||
def main(args):
|
||||
'''
|
||||
#_# dimmensions: 2
|
||||
|
||||
#_# dimmensions: 2.0
|
||||
'''
|
||||
return 100*args[1]**2+0.01*abs(args[0]+10)
|
@ -1,89 +0,0 @@
|
||||
from math import sqrt, fabs
|
||||
|
||||
|
||||
def main(args):
|
||||
'''
|
||||
#_# dimmensions: 2
|
||||
|
||||
#_# dimmensions: 2.0
|
||||
|
||||
#_# dimmensions: 2.0
|
||||
|
||||
#_# dimmensions: 2.0
|
||||
|
||||
#_# dimmensions: 2.0
|
||||
|
||||
#_# dimmensions: 2.0
|
||||
|
||||
#_# dimmensions: 2.0
|
||||
|
||||
#_# dimmensions: 2.0
|
||||
|
||||
#_# dimmensions: 2.0
|
||||
|
||||
#_# dimmensions: 2.0
|
||||
|
||||
#_# dimmensions: 2.0
|
||||
|
||||
#_# dimmensions: 2.0
|
||||
|
||||
#_# dimmensions: 2.0
|
||||
|
||||
#_# dimmensions: 2.0
|
||||
|
||||
#_# dimmensions: 2.0
|
||||
|
||||
#_# dimmensions: 2.0
|
||||
|
||||
#_# dimmensions: 2.0
|
||||
|
||||
#_# dimmensions: 2.0
|
||||
|
||||
#_# dimmensions: 2.0
|
||||
|
||||
#_# dimmensions: 2.0
|
||||
|
||||
#_# dimmensions: 2.0
|
||||
|
||||
#_# dimmensions: 2.0
|
||||
|
||||
#_# dimmensions: 2.0
|
||||
|
||||
#_# dimmensions: 2.0
|
||||
|
||||
#_# dimmensions: 2.0
|
||||
|
||||
#_# dimmensions: 2.0
|
||||
|
||||
#_# dimmensions: 2.0
|
||||
|
||||
#_# dimmensions: 2.0
|
||||
|
||||
#_# dimmensions: 2.0
|
||||
#_# Valleys: True
|
||||
|
||||
#_# dimmensions: 2.0
|
||||
#_# Valleys: True
|
||||
|
||||
#_# dimmensions: 2.0
|
||||
#_# Valleys: True
|
||||
|
||||
#_# dimmensions: 2.0
|
||||
#_# Valleys: True
|
||||
|
||||
#_# dimmensions: 2.0
|
||||
#_# Valleys: True
|
||||
|
||||
#_# dimmensions: 2.0
|
||||
#_# Valleys: True
|
||||
|
||||
#_# dimmensions: 2.0
|
||||
#_# Valleys: True
|
||||
|
||||
#_# dimmensions: 2.0
|
||||
#_# Valleys: True
|
||||
|
||||
#_# dimmensions: 2.0
|
||||
#_# Valleys: True
|
||||
'''
|
||||
return 100*sqrt(fabs(args[1]-0.01*args[0]**2))+0.01*fabs(args[0]+10)
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
13
work.py
Normal file
13
work.py
Normal file
@ -0,0 +1,13 @@
|
||||
if __name__ == '__main__':
|
||||
heuristicpath = "SampleAlgorithms/SimmulatedAnnealing.py"
|
||||
heuristic_name = "SimmulatedAnnealing"
|
||||
#testfunctionpaths = ["TestFunctions/Bukin2.py", "TestFunctions/Bukin4.py", "TestFunctions/Brown.py"]
|
||||
funcnames = ["Bukin2", "Bukin4", "Brown"]
|
||||
testfunctionpaths = ["/home/remi/Documents/MDAF-GitLAB/SourceCode/TestFunctions/Brown.py"]
|
||||
# funcnames = ["Bukin4"]
|
||||
|
||||
args = {"t": 1000, "p": 0.95, "objs": 0}
|
||||
|
||||
#data = doe (heuristicpath, testfunctionpaths, args)
|
||||
#print(data['Brown'])
|
||||
representfunc("TestFunctions/Brown.py", forced = True)
|
Reference in New Issue
Block a user