In [1]:
from __future__ import division
from numpy.random import randn
import matplotlib
import matplotlib.pylab as plt
import numpy as np
import matplotlib.cm as cm
import matplotlib.mlab as mlab
from matplotlib.patches import Ellipse
import math
matplotlib.rcParams['xtick.direction'] = 'out'
matplotlib.rcParams['ytick.direction'] = 'out'
plt.rc('figure', figsize=(8,8))

加中文图


In [7]:
#-*- coding: utf-8 -*-
from matplotlib.font_manager import FontProperties
import matplotlib.pyplot as plt
font = FontProperties(fname=r"c:\windows\fonts\simsun.ttc", size=14) 
plt.figure(figsize=(6,6))


x = [1,2,3,4,5,6,7,8]
y = []
for i in x:
    y.append(-(i*i)+i+3)


plt.plot(x, y)
plt.title(u'测试程序', fontproperties=font)
plt.xlabel(u'x轴', fontproperties=font)
plt.ylabel(u'y轴', fontproperties=font)
plt.grid(True)
plt.show()


figure1~6


In [5]:
def f(x):
    X=x[0]
    Y=x[1]
    return -(100-X**2-Y**2+1.5*X*Y)**0.5
delta = 0.05
x = np.arange(-5,0, delta)
y = np.arange(-5,0, delta)
X, Y = np.meshgrid(x, y)
Z = f((X,Y))

In [6]:
matplotlib.rcParams['contour.negative_linestyle'] = 'solid'
fig=plt.figure()
ax=fig.add_subplot(1,1,1)
plt.scatter([-2.5],[-2.5],c='k',linewidths=6,marker='.')
circ1=plt.Circle((-2.5,-2.5), radius=1, color='k', fill=False,linestyle='dashed')
circ2=plt.Circle((-2.5,-2.5), radius=1.5, color='k', fill=False,linestyle='solid')
ax.add_patch(circ1)
ax.add_patch(circ2)
CS = plt.contour(X, Y, Z, 6,
                 colors='k', # negative contours will be dashed by default
                levels=[-9.98,-9.9,-9.80,-9.70,-9.6,-9.5],
                 hold='on',
                 origin = 'lower',
                 alpha=0.5
                 )
plt.clabel(CS, fontsize=9, inline=1)
plt.xlim(-5,0)
plt.ylim(-5,0)
plt.xlabel('$x$',fontsize=15)
plt.ylabel('$y$',fontsize=15)
plt.show()

In [7]:
matplotlib.rcParams['contour.negative_linestyle'] = 'solid'
fig=plt.figure()
ax=fig.add_subplot(1,1,1)
plt.scatter([-2.5],[-2.5],c='k',linewidths=6,marker='.')
circ1=Ellipse(xy=(-2.5,-2.5), width=3, height=1, 
                        edgecolor='k', fc='None', lw=1,ls='dashed')
circ2=Ellipse(xy=(-2.5,-2.5), width=1, height=3.5, 
                        edgecolor='k', fc='None', lw=1,ls='solid')
ax.add_patch(circ1)
ax.add_patch(circ2)
CS = plt.contour(X, Y, Z, 6,
                 colors='k', # negative contours will be dashed by default
                levels=[-9.98,-9.9,-9.80,-9.70,-9.6,-9.5],
                 hold='on',
                 origin = 'lower',
                 alpha=0.5
                 )
plt.clabel(CS, fontsize=9, inline=1)
plt.xlim(-5,0)
plt.ylim(-5,0)
plt.xlabel('$x$',fontsize=15)
plt.ylabel('$y$',fontsize=15)
plt.show()

In [ ]:
max(list(map(max,Z)))

In [111]:
min(list(map(min,Z)))


Out[111]:
-9.9999374998046857

In [9]:
x


Out[9]:
array([], dtype=float64)

In [169]:
fig = plt.figure()
ax = fig.add_subplot(111)
cir1 = Circle(xy = (0.0, 1.0), radius=3, alpha=0.4) #第一个参数为圆心坐标,第二个为半径 #第三个为透明度(0-1)
ax.add_patch(cir1)
plt.axis('scaled')
plt.axis('equal') 
plt.show()



In [2]:
a=np.random.normal(0,1,100)
b=np.random.normal(0,1,100)
def f(x):
    X=x[0]
    Y=x[1]
    return -(X+Y)
delta = 0.05
x = np.arange(-3,3, delta)
y = np.arange(-3,3, delta)
X, Y = np.meshgrid(x, y)
Z = f((X,Y))

In [3]:
matplotlib.rcParams['contour.negative_linestyle'] = 'solid'
fig=plt.figure()
ax=fig.add_subplot(1,1,1)
plt.plot([0],[0],color='k', linestyle='dashed', marker='+',
      markersize=15,markeredgewidth=5)
plt.plot(a,b,'k.')
circ2=plt.Circle((0,0), radius=1, color='k', fill=False,linestyle='solid')
ax.add_patch(circ2)
CS = plt.contour(X, Y, Z, 6,
                 colors='k', # negative contours will be dashed by default
                levels=np.linspace(min(list(map(min,Z))),max(list(map(max,Z))),10),
                 hold='on',
                 origin = 'lower',
                 alpha=0.4
                 )
plt.clabel(CS, fontsize=9, inline=1)
plt.xlim(-3,3)
plt.ylim(-3,3)
plt.xlabel('$x$',fontsize=20)
plt.ylabel('$y$',fontsize=20)
plt.show()

In [4]:
coord=list(zip(a,b))
value=list(map(f,coord))
index=np.argsort(value)
sortCoord=map(lambda x:coord[x],index[:30])
sortCoord=list(sortCoord)
a1,b1=zip(*sortCoord)
meanx=np.mean(a1)
meany=np.mean(b1)

In [5]:
sortCoord=np.array(sortCoord)
mean=np.array(meanx,meany)
s=np.zeros((2,2))
for i in range(len(sortCoord)):
    aa=np.matrix(sortCoord[i]-mean)
    s+=aa.T*aa
ma=s/30
eigV,eigM=np.linalg.eig(ma)
ang=180*math.acos(eigM[0][0])/math.pi

In [6]:
matplotlib.rcParams['contour.negative_linestyle'] = 'solid'
fig=plt.figure()
ax=fig.add_subplot(1,1,1)
plt.plot([meanx],[meany],color='k', linestyle='dashed', marker='+',
      markersize=15,markeredgewidth=5)
plt.plot(a1,b1,'k.')
for i in range(len(a1)):
    plt.plot([meanx,a1[i]],[meany,b1[i]],'k-')
circ1=Ellipse(xy=(meanx,meany), width=2*eigV[1], height=2*eigV[0], angle=ang,
                        edgecolor='k', fc='None', lw=1,ls='dashed')
circ2=plt.Circle((0,0), radius=1, color='k', fill=False,linestyle='solid')
ax.add_patch(circ1)
ax.add_patch(circ2)
CS = plt.contour(X, Y, Z, 6,
                 colors='k', 
                levels=np.linspace(min(list(map(min,Z))),max(list(map(max,Z))),10),
                 hold='on',
                 origin = 'lower',
                 alpha=0.5
                 )
plt.clabel(CS, fontsize=9, inline=1)
plt.xlim(-3,3)
plt.ylim(-3,3)
plt.xlabel('$x$',fontsize=20)
plt.ylabel('$y$',fontsize=20)
plt.show()

In [7]:
matplotlib.rcParams['contour.negative_linestyle'] = 'solid'
fig=plt.figure()
ax=fig.add_subplot(1,1,1)
plt.plot([meanx],[meany],color='k', linestyle='dashed', marker='+',
      markersize=15,markeredgewidth=5)
mean = [meanx,meany]
cov = ma 
aa,bb = np.random.multivariate_normal(mean,cov,100).T
plt.plot(aa,bb,'k.')
circ1=Ellipse(xy=(meanx,meany), width=2*eigV[1], height=2*eigV[0], angle=ang,
                        edgecolor='k', fc='None', lw=1,ls='solid')
ax.add_patch(circ1)
CS = plt.contour(X, Y, Z, 6,
                 colors='k', 
                levels=np.linspace(min(list(map(min,Z))),max(list(map(max,Z))),10),
                 hold='on',
                 origin = 'lower',
                 alpha=0.5
                 )
plt.clabel(CS, fontsize=9, inline=1)
plt.xlim(-3,3)
plt.ylim(-3,3)
plt.xlabel('$x$',fontsize=20)
plt.ylabel('$y$',fontsize=20)
plt.show()


E:\Python34\lib\site-packages\matplotlib\collections.py:650: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  if self._edgecolors_original != str('face'):
E:\Python34\lib\site-packages\matplotlib\collections.py:590: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  if self._edgecolors == str('face'):

In [4]:
#C_qho
s=np.zeros((2,2))
for i in range(len(sortCoord)):
    aa=np.matrix(sortCoord[i])
    s+=aa.T*aa
ma=s/30
eigV,eigM=np.linalg.eig(ma)
ang=180*math.acos(eigM[0][0])/math.pi


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-4-0fee9d3aa79e> in <module>()
      1 #C_qho
      2 s=np.zeros((2,2))
----> 3 for i in range(len(sortCoord)):
      4     aa=np.matrix(sortCoord[i])
      5     s+=aa.T*aa

NameError: name 'sortCoord' is not defined

In [8]:
matplotlib.rcParams['contour.negative_linestyle'] = 'solid'
fig=plt.figure()
ax=fig.add_subplot(1,1,1)
plt.plot([meanx],[meany],color='k', linestyle='dashed', marker='+',
      markersize=15,markeredgewidth=5)
plt.plot(a1,b1,'k.')
for i in range(len(a1)):
    plt.plot([0,a1[i]],[0,b1[i]],'k-')
circ1=Ellipse(xy=(0,0), width=2*eigV[0], height=2*eigV[1], angle=ang,
                        edgecolor='k', fc='None', lw=1,ls='dashed')
circ2=plt.Circle((0,0), radius=1, color='k', fill=False,linestyle='solid')
ax.add_patch(circ1)
ax.add_patch(circ2)
CS = plt.contour(X, Y, Z, 6,
                 colors='k', # negative contours will be dashed by default
                levels=np.linspace(min(list(map(min,Z))),max(list(map(max,Z))),10),
                 hold='on',
                 origin = 'lower',
                 alpha=0.5
                 )
plt.clabel(CS, fontsize=9, inline=1)
plt.xlim(-3,3)
plt.ylim(-3,3)
plt.xlabel('$x$',fontsize=20)
plt.ylabel('$y$',fontsize=20)
plt.show()

In [9]:
matplotlib.rcParams['contour.negative_linestyle'] = 'solid'
fig=plt.figure()
ax=fig.add_subplot(1,1,1)
plt.plot([meanx],[meany],color='k', linestyle='dashed', marker='+',
      markersize=15,markeredgewidth=5)
mean = [meanx,meany]
cov = ma # diagonal covariance, points lie on x or y-axis
aa,bb = np.random.multivariate_normal(mean,cov,100).T
plt.plot(aa,bb,'k.')
circ1=Ellipse(xy=(meanx,meany), width=2*eigV[0], height=2*eigV[1], angle=ang,
                        edgecolor='k', fc='None', lw=1,ls='solid')
ax.add_patch(circ1)
CS = plt.contour(X, Y, Z, 6,
                 colors='k', # negative contours will be dashed by default
                levels=np.linspace(min(list(map(min,Z))),max(list(map(max,Z))),10),
                 hold='on',
                 origin = 'lower',
                 alpha=0.5
                 )
plt.clabel(CS, fontsize=9, inline=1)
plt.xlim(-3,3)
plt.ylim(-3,3)
plt.xlabel('$x$',fontsize=20)
plt.ylabel('$y$',fontsize=20)
plt.show()

In [8]:
ma


Out[8]:
array([[ 0.70853286, -0.33774197],
       [-0.33774197,  0.63453656]])

In [14]:



Out[14]:
0.7446120409595316

In [13]:
eigV


Out[13]:
array([ 1.01129713,  0.33177229])

In [12]:
np.linalg.det(eigM)


Out[12]:
1.0

In [25]:
ang


Out[25]:
41.87421299793277

In [32]:
mean = [0,0]
cov = [[1,0],[0,100]] # diagonal covariance, points lie on x or y-axis
x,y = np.random.multivariate_normal(mean,cov,5000).T
plt.plot(x,y,'x'); plt.axis('equal'); plt.show()

In [21]:
cc=np.random.multivariate_normal([0,0],[[1,0],[0,1]],5)

In [22]:
cc.mean(axis=0)


Out[22]:
array([-0.08991566, -0.26594248])

In [23]:
cc.mean(axis=1)


Out[23]:
array([ 1.18683222, -0.40604086, -0.56139341, -0.92542119, -0.18362211])

In [24]:
cc


Out[24]:
array([[ 1.70029026,  0.67337419],
       [ 0.76807424, -1.58015595],
       [-1.38699469,  0.26420787],
       [-0.92854484, -0.92229755],
       [-0.60240325,  0.23515903]])

In [30]:
cc[[1,2]]


Out[30]:
array([[ 0.76807424, -1.58015595],
       [-1.38699469,  0.26420787]])

In [33]:
l=[1,2]

In [34]:
cc[[l]]


Out[34]:
array([[ 0.76807424, -1.58015595],
       [-1.38699469,  0.26420787]])

In [35]:
cc.shape


Out[35]:
(5, 2)

In [37]:
e=1
e/=2.0
e


Out[37]:
0.5

In [38]:
cc.size


Out[38]:
10

In [39]:
cc.ndim


Out[39]:
2

实验部分图


In [5]:
import datac1
import pickle
with open('imqhoa.tl', 'rb') as f:
    x = pickle.load(f)

In [6]:
mqhoa=np.array(datac1.mqhoa).T
imqhoa=np.array(x).T

In [17]:
from __future__ import unicode_literals
from matplotlib.font_manager import FontProperties
import matplotlib.pyplot as plt
font = FontProperties(fname=r"/Library/Fonts/Songti.ttc", size=14) 
fig=plt.figure()
for i in range(5):
    plt.plot(mqhoa[i],'k-')
plt.annotate("第一维",xy=(1000,mqhoa[0][1000]),xytext=(3000,4),
arrowprops=dict(facecolor='black', shrink=0.005,width=0.3,headwidth=5,frac=0.05),fontproperties=font,fontsize=18)
plt.annotate("第二维",xy=(800,mqhoa[1][800]),xytext=(3500,3),
arrowprops=dict(facecolor='black', shrink=0.005,width=0.3,headwidth=5,frac=0.05),fontproperties=font,fontsize=18)
plt.annotate("第三维",xy=(1700,mqhoa[2][1700]),xytext=(3155,-0.5),
arrowprops=dict(facecolor='black', shrink=0.005,width=0.3,headwidth=5,frac=0.05),fontproperties=font,fontsize=18)
plt.annotate("第四维",xy=(1125,mqhoa[3][1125]),xytext=(3548,1.4),
arrowprops=dict(facecolor='black', shrink=0.005,width=0.3,headwidth=5,frac=0.05),fontproperties=font,fontsize=18)
plt.annotate("第五维",xy=(1786,mqhoa[4][1786]),xytext=(3000,-1.5),
arrowprops=dict(facecolor='black', shrink=0.005,width=0.3,headwidth=5,frac=0.05),fontproperties=font,fontsize=18)
plt.xlabel(u'NFFEs$\\times$100', fontsize=18,fontproperties=font)
plt.ylabel(u'各维度值', fontsize=18,fontproperties=font) 
plt.ylim(-2,5)
plt.show()


/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/matplotlib/text.py:2158: UserWarning: 'frac' option in 'arrowstyle' is no longer supported; use 'headlength' to set the head length in points.
  "'frac' option in 'arrowstyle' is no longer supported;"

In [18]:
fig=plt.figure()
for i in range(5):
    plt.plot(imqhoa[i],'k-')
plt.annotate("第一维",xy=(1.3,3.4),xytext=(15,4),
arrowprops=dict(facecolor='black', shrink=0.0005,width=0.3,headwidth=5,frac=0.05),fontproperties=font,fontsize=18)
plt.annotate("第二维",xy=(3,0.4),xytext=(13.6,1.6),
arrowprops=dict(facecolor='black', shrink=0.005,width=0.3,headwidth=5,frac=0.05),fontproperties=font,fontsize=18)
plt.annotate("第三维",xy=(0.64,0.83),xytext=(15,2.2),
arrowprops=dict(facecolor='black', shrink=0.005,width=0.3,headwidth=5,frac=0.05),fontproperties=font,fontsize=18)
plt.annotate("第四维",xy=(4,imqhoa[3][4]),xytext=(10,-1.2),
arrowprops=dict(facecolor='black', shrink=0.005,width=0.3,headwidth=5,frac=0.05),fontproperties=font,fontsize=18)
plt.annotate("第五维",xy=(3.2,0.16),xytext=(20,1.2),
arrowprops=dict(facecolor='black', shrink=0.005,width=0.3,headwidth=5,frac=0.05),fontproperties=font,fontsize=18)
plt.xlabel(u'NFFEs$\\times$100', fontsize=18,fontproperties=font)
plt.ylabel(u'各维度值', fontsize=18,fontproperties=font) 
plt.ylim(-2,5)
plt.show()


/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/matplotlib/text.py:2158: UserWarning: 'frac' option in 'arrowstyle' is no longer supported; use 'headlength' to set the head length in points.
  "'frac' option in 'arrowstyle' is no longer supported;"

In [15]:
fig=plt.figure()
for i in range(5):
    plt.plot(imqhoa[i],'k-')
plt.show()

In [22]:
#x=np.linspace(0.05,0.85,17)
x=[ 0.05,  0.1 ,  0.15,  0.2 ,  0.25,  0.3 ,  0.35,  0.4 ,  0.45,
        0.5 ,  0.55,  0.6 ,  0.65,  0.7 ,  0.75,  0.8 ,  0.85]
griwank=np.array([0,22,25,32,45,50,50,46,41,37,33,30,23,17,5,0,0])*2
rast=np.array([0,23,29,36,48,50,50,50,50,49,45,40,33,19,3,0,0])*2

In [7]:
from __future__ import unicode_literals
from matplotlib.font_manager import FontProperties
import matplotlib.pyplot as plt
font = FontProperties(fname=r"/Library/Fonts/Songti.ttc", size=14) 
fig=plt.figure()
plt.plot(x,griwank,'k',label="Griewank")
plt.plot(x,rast,'k-.',label="Rastrigin")
plt.legend()
plt.xlabel(u'$u$值', fontsize=18,fontproperties=font)
plt.ylabel(u'命中比率(%)', fontsize=18,fontproperties=font) 
plt.show()

In [25]:
from __future__ import unicode_literals
from matplotlib.font_manager import FontProperties
import matplotlib.pyplot as plt
font = FontProperties(fname=r"/Library/Fonts/Songti.ttc", size=14) 
fig=plt.figure()
plt.bar(x,griwank,width=0.04,align="center",color='k')
plt.xticks(x)
plt.xlabel(u'$\\alpha $值', fontsize=18,fontproperties=font)
plt.ylabel(u'对Griewank函数的命中概率(%)', fontsize=18,fontproperties=font) 
plt.show()

In [26]:
from __future__ import unicode_literals
from matplotlib.font_manager import FontProperties
import matplotlib.pyplot as plt
font = FontProperties(fname=r"/Library/Fonts/Songti.ttc", size=20) 
fig=plt.figure()
plt.bar(x,rast,width=0.04,align="center",color='k')
plt.xticks(x)
plt.xlabel(u'$\\alpha$值', fontsize=20,fontproperties=font)
plt.ylabel(u'对Rastrigin函数的命中概率(%)', fontsize=20,fontproperties=font) 
plt.show()

In [29]:
len(rast)


Out[29]:
18

4.3图


In [3]:
import pickle
with open('shiyan2.tl', 'rb') as f:
    data1 = pickle.load(f)

In [108]:
ax = plt.subplot(1,1,1)
ax.semilogy(range(1,len(data1['qho'])*50,50),data1['qho'],'co-',label='MQHOA')
ax.semilogy(range(1,len(data1['pso'])*50,50),data1['pso'],'mv-',label='PSO')
ax.semilogy(range(1,len(data1['fa'])*50,50),np.abs(data1['fa']),'k*-',label='FA')
ax.semilogy(range(1,(len(data1['dea'])+1)*50,50),np.abs(data1['dea']+[1e-16]),'ys-',label='DEA')
ax.semilogy(range(1,len(data1['esa'])*50,50),np.abs(data1['esa']),'gd-',label='ESA')
ax.legend('lower right'  )
ax.set_xlabel(u'NFFEs', fontsize=28)
ax.set_ylabel(u'Error(log)', fontsize=28)
ax.set_title(r"$f_2$",fontsize=28)
ax.set_ylim(1e-15,1e5)
ax.set_xlim(0,1e3)
ax.legend(loc='best')
plt.show()

In [9]:
with open('shiyan1.tl', 'rb') as f:
    data1 = pickle.load(f)
ax = plt.subplot(1,1,1)
ax.semilogy(range(1,len(data1['qho'])*50,50),data1['qho'],'co-',label='MQHOA')
ax.semilogy(range(1,len(data1['pso'])*50,50),data1['pso'],'mv-',label='PSO')
ax.semilogy(range(1,len(data1['abc'])*50,50),np.abs(data1['abc']),'k*-',label='ABC')
ax.semilogy(range(1,(len(data1['dea'])+1)*50,50),np.abs(data1['dea']+[1e-16]),'ys-',label='DE')
ax.semilogy(range(1,len(data1['esa'])*50,50),np.abs(data1['esa']),'gd-',label='FES')
ax.legend('lower right'  )
ax.set_xlabel(u'NFFEs', fontsize=28)
ax.set_ylabel(u'Error(log)', fontsize=28)
ax.set_title(r"$f_1$",fontsize=28)
ax.set_ylim(1e-15,1e5)
ax.set_xlim(0,1e3)
ax.legend(loc='best')
plt.show()

In [13]:
with open('shiyan2.tl', 'rb') as f:
    data1 = pickle.load(f)
ax = plt.subplot(1,1,1)
ax.semilogy(range(1,len(data1['qho'])*50,50),data1['qho'],'co-',label='MQHOA')
ax.semilogy(range(1,len(data1['pso'])*50,50),data1['pso'],'mv-',label='PSO')
ax.semilogy(range(1,len(data1['abc'])*50,50),np.abs(data1['abc']),'k*-',label='ABC')
ax.semilogy(range(1,(len(data1['dea'])+1)*50,50),np.abs(data1['dea']+[1e-16]),'ys-',label='DE')
ax.semilogy(range(1,len(data1['esa'])*50,50),np.abs(data1['esa']),'gd-',label='FES')
ax.legend('lower right'  )
ax.set_xlabel(u'NFFEs', fontsize=28)
ax.set_ylabel(u'Error(log)', fontsize=28)
ax.set_title(r"$f_2$",fontsize=28)
ax.set_ylim(1e-15,1e5)
ax.set_xlim(0,1e3)
ax.legend(loc='best')
plt.show()

In [82]:
x=[2744.161420324338, 8.2037767168585455e-10, 2.134621283669278e-22]
with open('shiyan3.tl', 'rb') as f:
    data1 = pickle.load(f)
ax = plt.subplot(1,1,1)
ax.semilogy(range(1,len(x)*50,50),x,'co-',label='MQHOA')
ax.semilogy(range(1,len(data1['pso'])*50,50),data1['pso'],'mv-',label='PSO')
ax.semilogy(range(1,len(data1['abc'])*50,50),np.abs(data1['abc']),'k*-',label='ABC')
ax.semilogy(range(1,(len(data1['dea'])+1)*50,50),np.abs(data1['dea']+[1e-16]),'ys-',label='DE')
ax.semilogy(range(1,len(data1['esa'])*50,50),np.abs(data1['esa']),'gd-',label='FES')
ax.legend('lower right'  )
ax.set_xlabel(u'NFFEs', fontsize=28)
ax.set_ylabel(u'Error(log)', fontsize=28)
ax.set_title(r"$f_3$",fontsize=28)
ax.set_ylim(1e-15,1e5)
ax.set_xlim(0,1e3)
ax.legend(loc='best')
plt.show()

In [87]:
x=[978.74285568453, 2.2539955596642184e-09, 7.6908358036683871e-15, 6.7124031058895338e-16, 1.6011236451252268e-16, 4.3857660831044929e-17, 4.2997082618810585e-17, 4.2252362084287629e-17, 4.197984750161106e-17, 4.1968673086165123e-17, 4.1937710214531391e-17]
with open('shiyan4.tl', 'rb') as f:
    data1 = pickle.load(f)
ax = plt.subplot(1,1,1)
ax.semilogy(range(1,len(x)*50,50),x,'co-',label='MQHOA')
ax.semilogy(range(1,len(data1['pso'])*50,50),data1['pso'],'mv-',label='PSO')
ax.semilogy(range(1,len(data1['abc'])*50,50),np.abs(data1['abc']),'k*-',label='ABC')
ax.semilogy(range(1,(len(data1['dea'])+1)*50,50),np.abs(data1['dea']+[1e-16]),'ys-',label='DE')
ax.semilogy(range(1,len(data1['esa'])*50,50),np.abs(data1['esa']),'gd-',label='FES')
ax.legend('lower right'  )
ax.set_xlabel(u'NFFEs', fontsize=28)
ax.set_ylabel(u'Error(log)', fontsize=28)
ax.set_title(r"$f_4$",fontsize=28)
ax.set_ylim(1e-15,1e5)
ax.set_xlim(0,1e3)
ax.legend(loc='best')
plt.show()

In [90]:
x=[2572.360748, 6.9768297026162411, 2.427299228832744, 0.13373876740634416, 0.0034725796317321353, 5.1429770379156906e-09, 1.4669952613590358e-22, 9.4731101360563847e-28]
with open('shiyan5.tl', 'rb') as f:
    data1 = pickle.load(f)
ax = plt.subplot(1,1,1)
ax.semilogy(range(1,len(x)*50,50),x,'co-',label='MQHOA')
ax.semilogy(range(1,len(data1['pso'])*50,50),data1['pso'],'mv-',label='PSO')
ax.semilogy(range(1,len(data1['abc'])*50,50),np.abs(data1['abc']),'k*-',label='ABC')
ax.semilogy(range(1,(len(data1['dea'])+1)*50,50),np.abs(data1['dea']+[1e-16]),'ys-',label='DE')
ax.semilogy(range(1,len(data1['esa'])*50,50),np.abs(data1['esa']),'gd-',label='FES')
ax.legend('lower right'  )
ax.set_xlabel(u'NFFEs', fontsize=28)
ax.set_ylabel(u'Error(log)', fontsize=28)
ax.set_title(r"$f_5$",fontsize=28)
ax.set_ylim(1e-15,1e5)
ax.set_xlim(0,1e3)
ax.legend(loc='best')
plt.show()

In [19]:
with open('shiyan6.tl', 'rb') as f:
    data1 = pickle.load(f)
ax = plt.subplot(1,1,1)
ax.semilogy(range(1,len(data1['qho'])*50,50),data1['qho'],'co-',label='MQHOA')
ax.semilogy(range(1,len(data1['pso'])*50,50),data1['pso'],'mv-',label='PSO')
ax.semilogy(range(1,len(data1['abc'])*50,50),np.abs(data1['abc']),'k*-',label='ABC')
ax.semilogy(range(1,(len(data1['dea'])+1)*50,50),np.abs(data1['dea']+[1e-16]),'ys-',label='DE')
ax.semilogy(range(1,len(data1['esa'])*50,50),np.abs(data1['esa']),'gd-',label='FES')
ax.legend('lower right'  )
ax.set_xlabel(u'NFFEs', fontsize=28)
ax.set_ylabel(u'Error(log)', fontsize=28)
ax.set_title(r"$f_6$",fontsize=28)
ax.set_ylim(1e-15,1e5)
ax.set_xlim(0,1e3)
ax.legend(loc='best')
plt.show()

In [30]:
with open('shiyan7.tl', 'rb') as f:
    data1 = pickle.load(f)
ax = plt.subplot(1,1,1)
ax.semilogy(range(1,len(data1['qho'])*50,50),data1['qho'],'co-',label='MQHOA')
ax.semilogy(range(1,len(data1['pso'])*50,50),data1['pso'],'mv-',label='PSO')
ax.semilogy(range(1,len(data1['abc'])*50,50),np.abs(data1['abc']),'k*-',label='ABC')
ax.semilogy(range(1,(len(data1['dea'])+1)*50,50),np.abs(data1['dea']+[1e-16]),'ys-',label='DE')
ax.semilogy(range(1,len(data1['esa'])*50,50),np.abs(data1['esa']),'gd-',label='FES')
ax.legend('lower right'  )
ax.set_xlabel(u'NFFEs', fontsize=28)
ax.set_ylabel(u'Error(log)', fontsize=28)
ax.set_title(r"$f_7$",fontsize=28)
ax.set_ylim(1e-3,1e7)
ax.set_xlim(0,1e3)
ax.legend(loc='best')
plt.show()

In [67]:
#改
x=[13.997512760030347, 0.005180837163418772, 2.699688295138003e-08, 1e-16]
with open('shiyan8.tl', 'rb') as f:
    data1 = pickle.load(f)
ax = plt.subplot(1,1,1)
ax.semilogy([1,51,101,151],x,'co-',label='MQHOA')
ax.semilogy(range(1,(10)*50,50),[13.878770184368564,0.8899363769532336,0.14338215624572825,0.015045931930515621,0.0011088152059031131,9.54696435542246e-05,3.1447173931553607e-06,2.965450107694778e-10,1.2434497875801753e-13,1e-16],'mv-',label='PSO')
ax.semilogy([1,51,101,151,201],[10.169748154765069,0.061174719479026862,0.000371244472301413, 5.1099178222102637e-09,1e-16],'k*-',label='ABC')
ax.semilogy(range(1,(len(data1['dea']))*50,50),np.abs(data1['dea']),'ys-',label='DE')
ax.semilogy(range(1,len(data1['esa'])*50,50),np.abs(data1['esa']),'gd-',label='FES')
ax.legend('lower right'  )
ax.set_xlabel(u'NFFEs', fontsize=28)
ax.set_ylabel(u'Error(log)', fontsize=28)
ax.set_title(r"$f_8$",fontsize=28)
ax.set_ylim(1e-15,1e5)
ax.set_xlim(0,1e3)
ax.legend(loc='best')
plt.show()

In [138]:
#改
x=[94.732080956181818, 1.989969788989157,  0.99495914392790041]
x=x+[0.99495914392790041]*18
with open('shiyan9.tl', 'rb') as f:
    data1 = pickle.load(f)
ax = plt.subplot(1,1,1)
ax.semilogy(range(1,len(x)*50,50),x,'co-',label='MQHOA')
ax.semilogy(range(1,len(data1['pso'])*50,50),data1['pso'],'mv-',label='PSO')
ax.semilogy(range(1,len(data1['abc'])*50,50),np.abs(data1['abc']),'k*-',label='ABC')
ax.semilogy(range(1,(len(data1['dea'])+1)*50,50),np.abs(data1['dea']+[1e-16]),'ys-',label='DE')
ax.semilogy(range(1,len(data1['esa'])*50,50),np.abs(data1['esa']),'gd-',label='FES')
ax.legend('lower right'  )
ax.set_xlabel(u'NFFEs', fontsize=28)
ax.set_ylabel(u'Error(log)', fontsize=28)
ax.set_title(r"$f_9$",fontsize=28)
ax.set_ylim(0.1,1e3)
ax.set_xlim(0,1e3)
ax.legend(loc='best')
plt.show()

In [143]:
with open('shiyan10.tl', 'rb') as f:
    data1 = pickle.load(f)
ax = plt.subplot(1,1,1)
ax.semilogy(range(1,len(data1['qho'])*50,50),data1['qho'],'co-',label='MQHOA')
ax.semilogy(range(1,len(data1['pso'])*50,50),data1['pso'],'mv-',label='PSO')
ax.semilogy(range(1,len(data1['abc'])*50,50),np.abs(data1['abc']),'k*-',label='ABC')
ax.semilogy(range(1,(len(data1['dea'])+1)*50,50),np.abs(data1['dea']+[1e-16]),'ys-',label='DE')
ax.semilogy(range(1,len(data1['esa'])*50,50),np.abs(data1['esa']),'gd-',label='FES')
ax.legend('lower right'  )
ax.set_xlabel(u'NFFEs', fontsize=28)
ax.set_ylabel(u'Error(log)', fontsize=28)
ax.set_title(r"$f_{10}$",fontsize=28)
ax.set_ylim(1e-15,1e5)
ax.set_xlim(0,1e3)
ax.legend(loc='best')
plt.show()

In [53]:
with open('shiyan11.tl', 'rb') as f:
    data1 = pickle.load(f)
ax = plt.subplot(1,1,1)
ax.semilogy(range(1,len(data1['qho'])*50,50),data1['qho'],'co-',label='MQHOA')
ax.semilogy(range(1,len(data1['pso'])*50,50),data1['pso'],'mv-',label='PSO')
ax.semilogy(range(1,len(data1['abc'])*50,50),np.abs(data1['abc']),'k*-',label='ABC')
ax.semilogy(range(1,(len(data1['dea'])+1)*50,50),np.abs(data1['dea']+[1e-16]),'ys-',label='DE')
ax.semilogy(range(1,len(data1['esa'])*50,50),np.abs(data1['esa']),'gd-',label='FES')
ax.legend('lower right'  )
ax.set_xlabel(u'NFFEs', fontsize=28)
ax.set_ylabel(u'Error(log)', fontsize=28)
ax.set_title(r"$f_{11}$",fontsize=28)
ax.set_ylim(1e-15,1e10)
ax.set_xlim(0,1e3)
ax.legend(loc='best')
plt.show()

In [55]:
with open('shiyan12.tl', 'rb') as f:
    data1 = pickle.load(f)
ax = plt.subplot(1,1,1)
ax.semilogy(range(1,len(data1['qho'])*50,50),data1['qho'],'co-',label='MQHOA')
ax.semilogy(range(1,len(data1['pso'])*50,50),data1['pso'],'mv-',label='PSO')
ax.semilogy(range(1,len(data1['abc'])*50,50),np.abs(data1['abc']),'k*-',label='ABC')
ax.semilogy(range(1,(len(data1['dea'])+1)*50,50),np.abs(data1['dea']+[1e-16]),'ys-',label='DE')
ax.semilogy(range(1,len(data1['esa'])*50,50),np.abs(data1['esa']),'gd-',label='FES')
ax.legend('lower right'  )
ax.set_xlabel(u'NFFEs', fontsize=28)
ax.set_ylabel(u'Error(log)', fontsize=28)
ax.set_title(r"$f_{12}$",fontsize=28)
ax.set_ylim(1e-15,1e5)
ax.set_xlim(0,1e3)
ax.legend(loc='best')
plt.show()

In [125]:
#改
x=[21.232557029998013, 0.0026136838792325534, 0.00011351595274433635, 4.93160998580322e-05, 3.623223427950961e-05, 3.554380771575438e-05, 2.8287597746867732e-05, 2.7484031591029634e-05, 2.662306784628754e-05, 2.6244402185682247e-05, 2.5873026494593887e-05, 2.5130631762237954e-05, 2.509685159779451e-05, 2.5096818347947192e-05, 2.5096817751091294e-05, 2.5096817751091294e-05, 2.5096817751091294e-05, 2.5096817751091294e-05, 2.5096817751091294e-05, 2.5096817751091294e-05, 2.5096817751091294e-05]
with open('shiyan13.tl', 'rb') as f:
    data1 = pickle.load(f)
ax = plt.subplot(1,1,1)
ax.semilogy(range(1,len(x)*50,50),x,'co-',label='MQHOA')
ax.semilogy(range(1,len(data1['pso'])*50,50),data1['pso'],'mv-',label='PSO')
ax.semilogy(range(1,len(data1['abc'])*50,50),np.abs(data1['abc']),'k*-',label='ABC')
ax.semilogy(range(1,(len(data1['dea'])+1)*50,50),np.abs(data1['dea']+[1e-16]),'ys-',label='DE')
ax.semilogy(range(1,len(data1['esa'])*50,50),np.abs(data1['esa']),'gd-',label='FES')
ax.legend('lower right'  )
ax.set_xlabel(u'NFFEs', fontsize=28)
ax.set_ylabel(u'Error(log)', fontsize=28)
ax.set_title(r"$f_{13}$",fontsize=28)
ax.set_ylim(1e-5,1e3)
ax.set_xlim(0,1e3)
ax.legend(loc='best')
plt.show()

In [146]:
aa=[27704855.277940851, 0.79582705178091895, 0.038330310225556094, 0.017172041786873166, 0.017136494020526364, 0.017110077959097351, 0.017081171489124795, 0.017008248101975935, 0.016866531000214763, 0.01568601688878158, 0.014412698705687487, 0.013145101649331381, 0.012572818244435806, 0.012320988877030849, 0.012320988875106652, 0.012320988875106624, 0.012320988875106629, 0.012320988875106641, 0.012320988875106662, 0.012320988875106641, 0.012320988875106621]
with open('shiyan14.tl', 'rb') as f:
    data1 = pickle.load(f)
ax = plt.subplot(1,1,1)
ax.semilogy(range(1,len(aa)*50,50),aa,'co-',label='MQHOA')
ax.semilogy(range(1,len(data1['pso'])*50,50),data1['pso'],'mv-',label='PSO')
ax.semilogy(range(1,len(data1['abc'])*50,50),np.abs(data1['abc']),'k*-',label='ABC')
ax.semilogy(range(1,(len(data1['dea'])+1)*50,50),np.abs(data1['dea']+[1e-16]),'ys-',label='DE')
ax.semilogy(range(1,len(data1['esa'])*50,50),np.abs(data1['esa']),'gd-',label='FES')
ax.legend('lower right'  )
ax.set_xlabel(u'NFFEs', fontsize=28)
ax.set_ylabel(u'Error(log)', fontsize=28)
ax.set_title(r"$f_{14}$",fontsize=28)
ax.set_ylim(1e-3,1e8)
ax.set_xlim(0,1e3)
ax.legend(loc='best')
plt.show()

In [145]:
with open('shiyan15.tl', 'rb') as f:
    data1 = pickle.load(f)
x=[13.80421931537961, 0.3944104791062131, 0.26586666008827464, 0.2645308051608346, 0.2645308019267496, 0.26453080192675316, 0.26453080192675316, 0.2645308019267638, 0.2645308019267496, 0.26453080192675316, 0.26453080192675316, 0.2645308019267425, 0.26453080192675316, 0.26453080192675316, 0.26453080192675316, 0.26453080192675316, 0.26453080192675316, 0.26453080192676026, 0.26453080192675316, 0.26453080192674605, 0.26453080192674605]
ax = plt.subplot(1,1,1)
ax.semilogy(range(1,len(x)*50,50),x,'co-',label='MQHOA')
ax.semilogy(range(1,len(data1['pso'])*50,50),data1['pso'],'mv-',label='PSO')
ax.semilogy(range(1,len(data1['abc'])*50,50),np.abs(data1['abc']),'k*-',label='ABC')
ax.semilogy(range(1,(len(data1['dea'])+1)*50,50),np.abs(data1['dea']+[1e-16]),'ys-',label='DE')
ax.semilogy(range(1,len(data1['esa'])*50,50),np.abs(data1['esa']),'gd-',label='FES')
ax.legend('lower right'  )
ax.set_xlabel(u'NFFEs', fontsize=28)
ax.set_ylabel(u'Error(log)', fontsize=28)
ax.set_title(r"$f_{15}$",fontsize=28)
ax.set_ylim(0.1,20)
ax.set_xlim(0,1e3)
ax.legend(loc='best')
plt.show()

In [72]:
with open('shiyan16.tl', 'rb') as f:
    data1 = pickle.load(f)
ax = plt.subplot(1,1,1)
ax.semilogy(range(1,len(data1['qho'])*50,50),data1['qho'],'co-',label='MQHOA')
ax.semilogy(range(1,len(data1['pso'])*50,50),data1['pso'],'mv-',label='PSO')
ax.semilogy(range(1,len(data1['abc'])*50,50),np.abs(data1['abc']),'k*-',label='ABC')
ax.semilogy(range(1,(len(data1['dea'])+1)*50,50),np.abs(data1['dea']+[1e-16]),'ys-',label='DE')
ax.semilogy(range(1,len(data1['esa'])*50,50),np.abs(data1['esa']),'gd-',label='FES')
ax.legend('lower right'  )
ax.set_xlabel(u'NFFEs', fontsize=28)
ax.set_ylabel(u'Error(log)', fontsize=28)
ax.set_title(r"$f_{16}$",fontsize=28)
ax.set_ylim(5,500)
ax.set_xlim(0,1e3)
ax.legend(loc='best')
plt.show()

In [142]:
with open('shiyan17.tl', 'rb') as f:
    data1 = pickle.load(f)
x=[254.17581523825356, 1.5122429303315286e-05, 2.863291839654816e-06, 2.066528629496087e-06, 1.384672135676696e-06, 1.0266389918167824e-06, 8.481567721054902e-07, 8.455014724253207e-07, 8.345440275270578e-07, 7.924549163140274e-07, 7.896557485687647e-07, 7.895681027974825e-07, 7.89551129992274e-07, 7.895212083375137e-07, 7.892607016292615e-07, 7.891640806023958e-07, 7.891640554438956e-07, 7.89164046076711e-07, 7.891640455920543e-07, 7.891640421229099e-07, 7.891640386859892e-07]
ax = plt.subplot(1,1,1)
ax.semilogy(range(1,len(x)*50,50),x,'co-',label='MQHOA')
ax.semilogy(range(1,len(data1['pso'])*50,50),data1['pso'],'mv-',label='PSO')
ax.semilogy(range(1,len(data1['abc'])*50,50),np.abs(data1['abc']),'k*-',label='ABC')
ax.semilogy(range(1,(len(data1['dea'])+1)*50,50),np.abs(data1['dea']+[1e-16]),'ys-',label='DE')
ax.semilogy(range(1,len(data1['esa'])*50,50),np.abs(data1['esa']),'gd-',label='FES')
ax.legend('lower right'  )
ax.set_xlabel(u'NFFEs', fontsize=28)
ax.set_ylabel(u'Error(log)', fontsize=28)
ax.set_title(r"$f_{17}$",fontsize=28)
ax.set_ylim(1e-15,1e5)
ax.set_xlim(0,1e3)
ax.legend(loc='best')
plt.show()

In [76]:
with open('shiyan18.tl', 'rb') as f:
    data1 = pickle.load(f)
ax = plt.subplot(1,1,1)
ax.semilogy(range(1,len(data1['qho'])*50,50),data1['qho'],'co-',label='MQHOA')
ax.semilogy(range(1,len(data1['pso'])*50,50),data1['pso'],'mv-',label='PSO')
ax.semilogy(range(1,len(data1['abc'])*50,50),np.abs(data1['abc']),'k*-',label='ABC')
ax.semilogy(range(1,(len(data1['dea'])+1)*50,50),np.abs(data1['dea']+[1e-16]),'ys-',label='DE')
ax.semilogy(range(1,len(data1['esa'])*50,50),np.abs(data1['esa']),'gd-',label='FES')
ax.legend('lower right'  )
ax.set_xlabel(u'NFFEs', fontsize=28)
ax.set_ylabel(u'Error(log)', fontsize=28)
ax.set_title(r"$f_{18}$",fontsize=28)
ax.set_ylim(1e-15,1e10)
ax.set_xlim(0,1e3)
ax.legend(loc='best')
plt.show()

实验统计


In [13]:
import pickle
import csv
with open('shiyanr301.tl', 'rb') as f:
    res = pickle.load(f)
def countfunc(func):
    aa=np.asarray(res[func]).reshape(2,18)
    return np.mean(aa,axis=0),np.std(aa,axis=0)

In [14]:
pso=countfunc('pso')
esa=countfunc('esa')
abc=countfunc('abc')
#qho=countfunc('qho')
dea=countfunc('dea')
strm='{0:.2E}|{1:.2E}'
with open('res301.csv','w', newline='') as f:
    writer=csv.writer(f)
    writer.writerow(["PSO","FES","ABC","DE"])
    for i in range(18):
        data=[strm.format(pso[0][i],pso[1][i]),strm.format(esa[0][i],esa[1][i]),
              strm.format(abc[0][i],abc[1][i]),strm.format(dea[0][i],dea[1][i])]
        writer.writerow(data)        

#for it in res.items():
#   print(it[0])
#  countfunc(it[0])

In [44]:
res={
'pso': [1.7723133597978313e-29, 2.2103370362428834e-28, 6.4924028756391731e-29, 1.8810460214172404e-28, 0.71592112934484309, 3.552713678800501e-15, 0.093471086705084402, 0.0, 0.0, 5.93997601293544e-30, 5.0229248863299552e-29, 4.2801743061735689, 20.109581195148202, 0.29546078821161348, 6.491271585099291, 9.949585533113833, 11.621898383343844, 0.014058071884619243, 1.3978344835236042e-29, 1.0202948408957846e-28, 1.6462086043667288e-29, 5.5941172714196224e-29, 1.1069536335480092, 3.552713678800501e-15, 0.017241020915713973, 0.0, 2.9848771712798623, 8.142995297930292e-30, 2.1657576763556423e-28, 76.507039496101925, 20.416258934467272, 0.17223093333667938, 5.416555073306482, 20.894099850968331, 0.45432401859077387, 3.5472634103261064e-05, 1.8007006499644223e-29, 1.1023201608456421e-29, 1.7836287840672981e-29, 7.3270909875446722e-29, 0.79991506825841041, 3.552713678800501e-15, 0.044270645908614667, 0.0, 2.9848771712798623, 4.2645892657833004e-30, 6.9654179580679416e-29, 4.5890459873851732, 3.552713678800501e-15, 0.28320614748402573, 3.5201422387201724, 25.868885060796657, 1.3351441179859729, 0.0018987752648056413, 3.1765753176779911e-29, 3.1294623036187468e-28, 3.0206412429775586e-29, 1.1210242613683551e-29, 0.69807846573466847, 3.552713678800501e-15, 0.046746576927733693, 0.0, 0.99495905709329691, 2.824461087204112e-28, 5.1556844181223659e-28, 4.2534225192931565, 20.014365818279654, 0.23866286125081163, 5.968236398260544, 18.904186774600859, 0.9981762875979935, 257705.10348312242, 2.015767312531393e-27, 1.4679626600000533e-29, 1.2443507988978779e-28, 4.3790643581609286e-29, 0.9873703996960056, 3.552713678800501e-15, 0.051634756056579301, 0.0, 1.9979523895052296, 2.166259842730574e-29, 5.3225894366667774e-29, 5.1959918981957074, 20.06743019849755, 0.034457509806480394, 8.627338416588286, 75.635665072118726, 28.724575366846732, 133333.57078630503] 
,'esa': [0.00010463902191198163, 7.6554784304845898, 0.00042331172924187977, 0.030452081242559565, 0.26909906297829611, 0.013227835765032836, 1600.8588844816666, 1.6537595690918963, 4.7202190213507293, 6.899356599695512e-05, 6031.7223100442707, 10.037244732009142, 3.968203258444369, 154945.48479089307, 4.879167976813562, 22.771851460512195, 4.063967298862485, 65588.848394508983, 0.00010009241298695911, 8.5712474399075429, 0.00048609293918294537, 0.052909171599324838, 0.52961379333432124, 0.01667435884970203, 0.49553923023780855, 1.1974864871306075, 6.0381045280437462, 0.00014638866080140075, 24033.635417896927, 10.735703116373609, 6.453972574275451, 1765.9364795819661, 4.4875635750519045, 21.048404267493922, 2.158963798831836, 41265.223623260099, 5.4858408122015162e-05, 5.0259976532762565, 0.00015550946335413481, 0.04277292696678877, 3.0735380356436277, 0.013646364672180056, 12825.68578409962, 1.5487857775310232, 5.0551446661167887, 2.8350382538394534e-05, 16688.097821371921, 7.4936646820883297, 3.5961738047265612, 405118.47839764343, 3.9765442371228126, 17.894330568997773, 5.449642184668615, 47955.732730326206, 1.1255785594978206e-05, 14.340259623654951, 0.0002664239014954041, 0.078247926068450505, 0.075989949906084486, 0.015202361681080134, 18631.848003672425, 1.7449187691544168, 7.089979282791063, 1.3786069729265313e-05, 3831.4000267576553, 11.27262790828658, 6.115415972664383, 163225.23330611366, 4.475924187443269, 18.245560005226295, 4.177242996933994, 55336.046518252027, 9.8549627914855902e-05, 16.174076038801839, 0.00034451957284434341, 0.089684660335193303, 0.18814717984327639, 0.013440261920536045, 0.39829691843736775, 1.515941861927196, 5.0145163442943215, 1.4912384349296993e-05, 19497.465110000998, 9.0665726627381442, 19.455110277653485, 168476.97907779046, 5.179532768852804, 22.501439615557331, 2.4668553572322116, 48183.255651885083]
,'abc': [1.8411853485573707e-148, 2.0743713975340926e-48, 6.2339203112297146e-149, 5.3470655028192809e-51, 0.1125878411753746, 21.219344995803436, 0.027063560388613888, 0.0, 0.0, 1.4997597826618576e-32, 2.1969018996896319e-46, 4.2853381017345713, 2.316848791847587, 0.16984381093250056, 0.6525612679160098, 858.97294160890874, 0.4543240185907755, 0.00014132986645464478, 4.4355674258558395e-149, 5.3181159647818092e-47, 8.1688008128333251e-152, 4.9482471347520102e-52, 0.21290862734383398, 21.425576925456586, 0.066363039160339699, 0.0, 1.9899181141865796, 120.37236258020803, 10155524.132677641, 4.5903487662901252, 2.8135969802339496, 0.041831455808124147, 1.3509263962205935, 3.9798362283731592, 0.089528250416441, 3.6934134372682875e-06, 1.3697497125826108e-149, 4.0885098259511402e-46, 2.6240099334632596e-152, 3.2289860876059947e-52, 0.28235564673936564, 3.552713678800501e-15, 0.066434107933606393, 0.0, 0.99495905709329691, 1.4997597826618576e-32, 6.6094373200882037e-48, 9.6325066209198642, 1.1551485027098245, 0.088519125150244599, 13.16532443642169, 388.48389031974114, 0.08952825041644105, 6.1807637845537934e-08, 1.1612835804677849e-151, 1.5190406330018179e-48, 7.6943723306174501e-152, 5.169917272355496e-52, 0.17867938801042249, 0.0, 0.061497030122951123, 0.0, 1.9899181141865938, 1.4997597826618576e-32, 1.3694103767414444e-46, 4.2333182419237296, 1.1551485027098316, 0.13528032270149057, 1.7494706213931401, 402.05967600703991, 0.4543240185907751, 3.62623547640521e-06, 4.0460649088782951e-149, 4.3634210587134971e-49, 6.8718385120273298e-151, 2.5459987420833688e-51, 0.26074372502426713, 3.552713678800501e-15, 0.2425889306340008, 0.0, 0.0, 1.4997597826618576e-32, 3.5133489301278815e-46, 4.727221688457572, 1.1551485027098245, 0.71689562212322933, 9.234629685641123, 23.06011251624146, 0.17905650083288224, 4.2292164632171307e-05]
,'qho': [1.6873806410747526e-32, 1.12181872305661e-32, 6.9271454270282773e-32, 2.440523070516276e-32, 0.11101120161451256, 3.552713678800501e-15, 0.029517804518140772, 0.26247351276177966, 2.9848771712798907, 1.4008480722960765e-31, 1.3460485016978905e-32, 1.4227599463726711e-27, 3.552713678800501e-15, 0.012320988875106692, 3.960623083518616, 2.9848771712798623, 1.4998758055927386e-30, 1.3932351428457642e-32, 2.9053620134119976e-32, 1.658302477109841e-32, 8.0845871211072715e-32, 2.8044295420001693e-32, 6.3225968958299688e-28, 7.105427357601002e-15, 1.4242037003316209e-31, 0.017019883487233045, 2.9848771712798623, 4.371897213266078e-31, 3.7208694076386033e-32, 9.8698455416243333e-27, 3.552713678800501e-15, 0.012320988875106735, 2.4772764127420253, 13.929416723667913, 0.08952825041644093, 2.6631207926601617e-32, 3.7600711688332473e-32, 9.0268269827233239e-33, 4.6418332891932528e-32, 1.9299487969231142e-32, 0.01712475181645964, 3.552713678800501e-15, 8.872743149593442e-32, 0.9701584484466501, 7.9596674189272534, 0.08952825041644098, 1.0502839474239842e-32, 3.8375371329640527e-27, 3.552713678800501e-15, 0.027093396087305991, 1.5658261685269181, 3.9798362283731592, 0.4543240185907735, 1.2790101156226867e-32, 8.3876021748026232e-33, 1.6761012409549294e-32, 5.0884617916310121e-32, 3.4095738293757013e-32, 0.021743746356089638, 3.552713678800501e-15, 8.584171472405711e-32, 0.1602835970413885, 6.9647083618339707, 1.9001056732618623e-31, 1.2125381517626039e-32, 5.4859852539397977e-27, 3.552713678800501e-15, 1.857789934491184e-31, 2.5250584698374396, 37.808205195404483, 5.7344097015443994e-30, 9.0523760911923604e-32, 3.8870641675716686e-32, 2.2880853591461645e-32, 1.7611539916769526e-31, 3.006450393628424e-32, 7.6233545728295528e-28, 0.0, 9.3691767064011868e-13, 0.004688059439846626, 5.9698566482852016, 2.0748034140644267e-31, 4.6797346970514068e-33, 2.5987050370243181e-27, 3.552713678800501e-15, 0.0098646720610061599, 2.279581499324994, 1.9899181141865938, 9.562674344958063e-30, 2.1842160359209832e-32]
,'dea': [2.6390116849842212e-25, 9.5594252375349778e-26, 5.0058607355124592e-27, 3.1703475529518518e-27, 8.649853449533609e-23, 1.1297629498585593e-12, 0.43190601763071601, 1.3246830462776416e-05, 26.854072064724122, 1.469171870841272e-26, 1.4185397381006668e-24, 2.796912169636225e-24, 2.919183325181674, 0.40528426614644386, 1.5874302273153411, 26.93956941486104, 5.345180105839266e-26, 9.2333023320626854e-24, 3.7705685881607445e-25, 3.7501868893306479e-25, 1.0861588343086569e-27, 6.1916381856611361e-28, 1.2251147752201141e-22, 2.1671553440683056e-13, 0.3360633558199323, 5.403602152398435e-07, 21.510918057385595, 2.824762571859024e-27, 9.8333533385075461e-25, 3.8439457366526696e-23, 1.9757802581743142, 0.24374595714280883, 0.464872157134824, 29.873834255562798, 2.875124314337633e-26, 1.6876513986789028e-23, 4.1380867928262163e-25, 1.7486415658493429e-25, 1.8590475089698427e-27, 3.1386764508127821e-27, 1.6370580837703822e-23, 2.5579538487363607e-13, 0.076407125193562811, 1.0862725673632667e-05, 33.858458838749883, 1.6513217305800233e-26, 1.7701268061444937e-24, 2.2902242291584949e-23, 18.628706989115596, 0.47865740672352708, 3.149110832045338, 31.292579332053833, 2.1468407059586606e-24, 3.9644730294687634e-24, 4.0985575943290618e-26, 2.0690280023159838e-25, 8.1235618118601144e-27, 2.7611573404078169e-27, 7.23327329909985e-22, 2.2026824808563106e-13, 0.3004718016318158, 7.415390470555394e-07, 31.899678149792109, 4.7481412969957116e-27, 2.4915605420612828e-24, 1.2269184292590018e-22, 0.00013094315706396742, 0.46409079505756468, 1.8809568606914766, 23.616738452397811, 2.325986404059324e-25, 2.2261916055475658e-23, 6.500482493616523e-25, 1.757748300969656e-25, 1.1574699897515922e-26, 1.0571579610237937e-27, 1.0602106662971869e-23, 3.694822225952521e-13, 0.44014462658936515, 2.286948623719809e-05, 33.79974944906445, 2.688693524257319e-26, 2.4314804154864626e-24, 2.6989881439010178e-23, 1.4306330342606088e-08, 0.52560470244144819, 3.3019831767285055, 29.202114124216294, 4.2301136204141034e-26, 8.7760465398498777e-24]
}
with open('shiyanr10.tl', 'wb') as f:
    pickle.dump(res, f, pickle.DEFAULT_PROTOCOL)

In [57]:
strm='{0:.2E}'
strm.format(0.11)


Out[57]:
'1.10E-01'

In [5]:
pso=countfunc('pso')


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-5-f79415a6d73b> in <module>()
----> 1 pso=countfunc('pso')

<ipython-input-2-a63d5c5ff4bc> in countfunc(func)
      4     res = pickle.load(f)
      5 def countfunc(func):
----> 6     aa=np.asarray(res[func]).reshape(1,18)
      7     return np.mean(aa,axis=0),np.std(aa,axis=0)

ValueError: total size of new array must be unchanged

In [9]:
aa=np.asarray(res['pso']).reshape(2,18)

In [10]:
aa


Out[10]:
array([[  1.24762584e-28,   1.00000000e+04,   3.00000000e+02,
          2.18263885e-09,   1.31069731e+01,   7.10542736e-15,
          1.29600020e+06,   0.00000000e+00,   1.15556937e+02,
          4.54324019e-01,   8.33333333e+05,   5.98824649e+02,
          2.06737982e+01,   4.23246449e+06,   2.84523682e+01,
          2.10544377e+02,   1.83718727e+02,   8.56971869e+05],
       [  2.04722621e-28,   5.00000001e+03,   3.00000000e+02,
          1.77853399e-09,   1.81924039e+01,   7.10542736e-15,
          3.44551091e-02,   0.00000000e+00,   1.27567204e+02,
          2.81791159e+00,   5.83333333e+05,   7.24433622e+03,
          2.06868121e+01,   1.14532220e+07,   2.57770751e+01,
          3.12372350e+02,   8.68046136e+01,   4.50448483e+05]])

In [12]:
np.mean(aa,axis=0)


Out[12]:
array([  1.64742603e-28,   7.50000000e+03,   3.00000000e+02,
         1.98058642e-09,   1.56496885e+01,   7.10542736e-15,
         6.48000115e+05,   0.00000000e+00,   1.21562070e+02,
         1.63611780e+00,   7.08333333e+05,   3.92158043e+03,
         2.06803051e+01,   7.84284325e+06,   2.71147216e+01,
         2.61458364e+02,   1.35261670e+02,   6.53710176e+05])

In [21]:
np.linspace(0.05,0.85,17)


Out[21]:
array([ 0.05,  0.1 ,  0.15,  0.2 ,  0.25,  0.3 ,  0.35,  0.4 ,  0.45,
        0.5 ,  0.55,  0.6 ,  0.65,  0.7 ,  0.75,  0.8 ,  0.85])

In [ ]: