From 816ee3639f516cef11e94d78bc48b3db1a320caf Mon Sep 17 00:00:00 2001 From: Remi Ehounou Date: Wed, 9 Jun 2021 20:40:44 -0400 Subject: [PATCH] plotfuncsv1 --- MDAF/MDAF.py | 42 ++++++++++++++++-- MDAF/TestFunctions/Bukin6.py | 19 ++++++++ .../__pycache__/Bukin6.cpython-39.pyc | Bin 483 -> 5783 bytes 3 files changed, 57 insertions(+), 4 deletions(-) diff --git a/MDAF/MDAF.py b/MDAF/MDAF.py index bd16981..98284d7 100644 --- a/MDAF/MDAF.py +++ b/MDAF/MDAF.py @@ -11,7 +11,8 @@ import statistics from functools import partial import shutil -# Surrogate modelling +# Surrogate modelling and plotting +import matplotlib.pyplot as plt # Test function representation from rpy2 import robjects as robjs @@ -269,8 +270,8 @@ def doe(heuristicpath, testfunctionpaths, args): #return the performance values return responses -def plotfuncs(funcpaths, features): - print ('help') +def plotfuncs(funcpaths, feature): + pi = 3.141592653589793 for i,funpath in enumerate(funcpaths): if funpath.find('@') == 0: funcpaths[i] = path.dirname(__file__) + '/TestFunctions/' + funpath[1:] @@ -279,9 +280,42 @@ def plotfuncs(funcpaths, features): representations = {} for idx,funpath in enumerate(funcpaths): - representations[funcnames[idx]] = representfunc(funpath) + representations[funcnames[idx]] = representfunc(funpath)[feature] + + # generate a list of the categories of the plot + elements = list(representations.values()) + categories = [str(i) for i in list(range(len(elements[0])))] + # creating the plot figure + fig = plt.figure(figsize = (12,8)) + ax = plt.subplot(polar = "True") + for idx, func in enumerate(representations): + vals = representations[func] + vals = [float(v) for v in vals] + # get the number of dims of the plot + N = len(vals) + # repeat the first value to close the circle + vals += vals[:1] + #calculate the angles for each category + angles = [n/float(N)*2*pi for n in range(N)] + angles += angles[:1] + #creating the polar plot + ax.plot(angles,vals) + + # X ticks + plt.xticks(angles[:-1], categories) + + #ax.set_rlabel_position(0) + + # y ticks + # set dynamic scaling for each dimension + plt.ylim(0,200) + + plt.title("Radar Plot of the "+feature+ " feature for the following Functions") + plt.legend() + plt.show(block=True) + return representations # %% diff --git a/MDAF/TestFunctions/Bukin6.py b/MDAF/TestFunctions/Bukin6.py index f440ed7..c34abbf 100644 --- a/MDAF/TestFunctions/Bukin6.py +++ b/MDAF/TestFunctions/Bukin6.py @@ -8,5 +8,24 @@ def main(args): #_# lower: [-15, -3] #_# minimum: [-10,1] + + #_# cm_angle: array([[6.66400060e-01], [1.57197492e-01], [6.33211887e-01], [1.78907191e-01], [1.44244246e+02], [3.10372115e+01], [2.04871341e-01], [7.98873206e-02], [0.00000000e+00], [4.70000000e-02]]) + #_# cm_conv: array([[0.17307692], [0.09615385], [0.53846154], [0.46153846], [0. ], [0.015 ]]) + #_# cm_grad: array([[0.748637 ], [0.18732133], [0. ], [0.033 ]]) + #_# ela_conv: array([[ 5.59000000e-01], [ 0.00000000e+00], [-9.93512960e+00], [ 1.40517786e+01], [ 1.00000000e+03], [ 1.19000000e-01]]) + #_# ela_curv: array([[2.35290361e+01], [3.25866731e+01], [5.34145553e+01], [4.24019080e+01], [6.03282394e+01], [2.44344134e+02], [3.49426877e+01], [0.00000000e+00], [3.32978294e+00], [3.94526823e+00], [5.47746980e+00], [4.97327244e+00], [6.76368399e+00], [9.90620749e+00], [1.81308137e+00], [0.00000000e+00], [5.82313234e+00], [1.08167038e+01], [4.23447456e+01], [1.87734274e+01], [3.81238982e+01], [6.49883654e+02], [7.88648872e+01], [0.00000000e+00], [8.40000000e+03], [1.01800000e+00]]) + #_# ela_distr: array([[-0.1580354 ], [-0.75125793], [ 1. ], [ 0. ], [ 0.031 ]]) + #_# ela_local: array([[1.00000000e+00], [1.00000000e-02], [1.00000000e+00], [ nan], [1.00000000e+00], [0.00000000e+00], [1.00000000e+00], [1.00000000e+01], [1.00000000e+01], [1.30500000e+01], [1.50000000e+01], [1.50000000e+01], [1.50000000e+01], [2.45103565e+00], [1.30600000e+03], [1.20000000e-01]]) + #_# ela_meta: array([[4.43726129e-01], [1.03457432e+02], [2.03061212e+00], [1.84369067e+01], [9.07948224e+00], [5.57966283e-01], [6.75912004e-01], [1.97815159e+01], [9.09087990e-01], [0.00000000e+00], [9.00000000e-03]]) + #_# basic: array([[ 2.00000000e+00], [ 5.00000000e+02], [-1.50000000e+01], [-3.00000000e+00], [-5.00000000e+00], [ 3.00000000e+00], [ 2.77942324e+00], [ 2.26293823e+02], [ 6.00000000e+00], [ 6.00000000e+00], [ 3.60000000e+01], [ 3.60000000e+01], [ 1.00000000e+00], [ 0.00000000e+00], [ 1.00000000e-03]]) + #_# disp: array([[ 0.9437388 ], [ 0.84900264], [ 0.81147919], [ 0.82037666], [ 0.99730628], [ 0.79772263], [ 0.74883067], [ 0.74919161], [-0.23897957], [-0.64138846], [-0.80077605], [-0.76298243], [-0.01088726], [-0.81754857], [-1.01515617], [-1.01369734], [ 0. ], [ 0.01 ]]) + #_# limo: array([[1.19640615e+01], [3.77717321e-01], [4.31621681e+01], [1.76236793e+01], [9.32994956e-01], [7.34512758e-01], [1.06087444e+01], [3.22623285e+01], [4.46141915e+00], [4.07690838e+00], [2.72360722e+01], [5.67862195e-01], [0.00000000e+00], [3.50000000e-02]]) + #_# nbc: array([[ 0.19289655], [ 0.84266125], [ 0.20129043], [ 0.16243626], [-0.30378927], [ 0. ], [ 0.043 ]]) + #_# pca: array([[1. ], [1. ], [0.33333333], [1. ], [0.73572473], [0.51519025], [0.99587696], [0.55976219], [0. ], [0.003 ]]) + #_# gcm: array([[2. ], [0.05555556], [0.94444444], [0.72222222], [0.23300034], [0.5 ], [0.5 ], [0.76699966], [0.37759454], [0.02777778], [0.13888889], [0.13888889], [0.25 ], [0.15713484], [0.27777778], [0.22222222], [0.5 ], [0.5 ], [0.77777778], [0.3928371 ], [1. ], [0.76699966], [0.02777778], [0. ], [0.024 ], [2. ], [0.05555556], [0.94444444], [0.77777778], [0.46754278], [0.5 ], [0.5 ], [0.53245722], [0.04590144], [0.08333333], [0.11111111], [0.11111111], [0.13888889], [0.03928371], [0.22222222], [0.44444444], [0.5 ], [0.5 ], [0.55555556], [0.07856742], [1. ], [0.53245722], [0.02777778], [0. ], [0.029 ], [2. ], [0.05555556], [0.94444444], [0.69444444], [0.40534181], [0.5 ], [0.5 ], [0.59465819], [0.13386689], [0.08333333], [0.15277778], [0.15277778], [0.22222222], [0.09820928], [0.30555556], [0.38888889], [0.5 ], [0.5 ], [0.61111111], [0.15713484], [1. ], [0.40534181], [0.02777778], [0. ], [0.031 ]]) + #_# ic: array([[ 0.66268098], [ 2.08708709], [20.2444651 ], [ 1.46646647], [ 0.29718876], [ 0. ], [ 0.243 ]]) + + #_# Represented: 1 + ''' return 100*sqrt(fabs(args[1]-0.01*args[0]**2))+0.01*fabs(args[0]+10) diff --git a/MDAF/TestFunctions/__pycache__/Bukin6.cpython-39.pyc b/MDAF/TestFunctions/__pycache__/Bukin6.cpython-39.pyc index 6bcb2414adf870debfde469b972a44c559a413ae..76ff0f9237decd351adca183fd570302040efc0f 100644 GIT binary patch literal 5783 zcmb_g&5j#I5FYPt2w8|gVo^YFu#^ic;@{C%Ae<7df@7PF#oD{rUQmEr z@&Y_YF1!P;u?Hl?XE~_!t($&S5d>-0Ms>?rn66;l^o6JxOKPKy>JGK;@QUO*8IEK;&khq z{=@m8ld#oFzc1qbDciTf$t9gIRybg4oJctnwe8;kh(ug!Bk;&(8M z^)goMLbvS>NabNnO?6}9f_6I6vi35mx@ZQ?dbD03v5cpB#6qf;3t3KZJ=%Q0n`jSF zyN*tjsbl5?iH1U+LSR)2wI>+#S?$=Al0c=5k1AG`Ab}bKm~(7)0T|JB&__Z>>7(~r zJC;D8#JCbb>T^niU6f-Hh{Bo5y^oer0(5A#A)A~4qCk7^BpbU@-G%RhHf(o*Qpwa4 znDFU#<*fxF$U&|M~Fp_ z$x_$GSR+U|tz4*$F&LknCWrQt^NDGkh$f=FW<#6D*n@uLZOCz`=8*8F92=M$Fg_s% zF!|KvM1gb4z-P6}X;7F@uR_`GS=1uOAf`k(SwMiY+4rV4RUZ#nZ%_?4HDMA@ zOv_aTRx_O^i-FIxNXJtL!Z%8;Y)Voa;2jqHptBJX#8bRUspO8DP6q=#E3RiB-Jlch z!FY|8?H3VZX;nHQQ}uFjOcSBR@=SxQD{FJQCJfanMzldrM;;x}T=vIoH^CLt%dBqBPOPn;=rO5{8gBrfn zri3ef|D(?v^e_%}Sm(Mm`L_{6`$iUIHkAfXt}2f;l%{f3dceP{^^aIX9LSaN`Mpj4 zT}FK_OQRl5G2W0z(g*9jVfr@v+&0;zA?}-f9{*RLyH)aYTj4+e58{EfoEOgpB($?3 zuU$Cwz~g?Nzl}b(r4jPnZ@`*-DKS?_{+*>G+_QAbJ4?TI zJEvRy*}?o-F-zEAAMQOmnvC{lqse&h*3sYuC#j41-siV&-0s~OFFw0*v;4jH)o8xB zeKH*^(kbiS&697(QzwoepKeY1ekP1_0z{3~c}a