<jupyter_start><jupyter_text>$\lambda$对CMA性能影响研究   hljs.initHighlightingOnLoad(); $(document).ready(function(){      $("h2,h3,h4,h5,h6").each(function(i,item){        var tag = $(item).get(0).localName;        $(item).attr("id","wow"+i);        $("category").append(''+$(this).text()+'');        $(".newh2").css("margin-left",0);        $(".newh3").css("margin-left",20);        $(".newh4").css("margin-left",40);        $(".newh5").css("margin-left",60);        $(".newh6").css("margin-left",80);      }); }); **摘要**: $\lambda$大小影响单次计算时间，根据文档合理的$\lambda$在[5，2n+10]之间，Hansen给出的推荐值为$4+3\times \lfloor ln(N) \rfloor$,本文固定mu=0.5，sigma=0.3,根据不同的$\lambda$对不同函数绘图分析. 第一阶段测试* 函数：[rosen,bukin,griewank]* 最小值：[0,6.82,0]* 维度：[130]* $\lambda$:[5,18,20,50,80,110,140]<jupyter_code>%pylab inline
import pandas as pd
from pandas import Series, DataFrame
import pickle
plt.rc('figure', figsize=(12, 8))
with open("data.tl",'r') as f:
    result_list=pickle.load(f)
def convertdic(result_list):
    res=[{}]
    for row in result_list:
        for i,d in enumerate(res):
            if row[-1] not in d.keys():
                d[row[-1]]=row[:-1]
                break
            if i==len(res)-1:
                res.append({row[-1]:row[:-1]})
                break
    return  res

def draw(title,tail):
    bs=[row[:tail] for row in result_list if row[tail]==title]
    bs=np.array(bs)
    lmax=max(bs[:,-1])
    bs=bs/bs.max(0)
    bs=bs*[1,1,1,1,lmax]
    bs=convertdic(bs)
    df=DataFrame(bs[0],index=['countiter','countevals','result','time(s)'])
    df=df.stack().unstack(0)
    df.columns.name='values'
    df.index.name='lambda'
    df.plot(kind='bar',stacked=False,colormap='jet',alpha=0.9,title=title,figsize=(12,8));
    df.plot(kind='area',stacked=False,colormap='jet',alpha=0.5,title=title,figsize=(12,8),xticks=np.arange(5,lmax,10));
    
def drawSigmaLines(t,xl):
    sigmas=[[row[-3],row[-1]] for row in result_list if row[-2]==t]
    ss=map(list,zip(*sigmas))[1]
    M=max(map(len,ss))
    for s in sigmas:
        for i in range(M-len(s[1])):
            s[1].append(None)
    df1=DataFrame({s[0]:s[1]  for s in sigmas})
    df1.columns.name='sigma'
    df1.index.name='lambda'
    df1.plot(title=t,fontsize=10,linewidth=2,alpha=0.8,colormap='rainbow',xlim=(0,xl))
#bukin函数
draw('bukin',-1)
#rosen函数 
draw('rosen',-1)
#griwank函数
draw('griewank',-1)<jupyter_output><empty_output><jupyter_text>第二阶段测试* 函数：[sphere,cigar,elli]* 最小值:[0,0,0]* 维度：[208]* $\lambda$:[5,10,14,18,20,22,26,60,100,140,180,220]<jupyter_code>with open("data1.tl",'r') as f:
    result_list=pickle.load(f)
#sphere函数
draw('sphere',-2)
drawSigmaLines('sphere',300)
#cigar函数
draw('cigar',-2)
drawSigmaLines('cigar',300)
#elli函数
draw('elli',-2)
drawSigmaLines('elli',300)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.22915914832190545, 'fraction_numerical': 0.05413208228076507, 'mean_word_length': 4.372093023255814, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '8433', 'license': 'Apache-2.0', 'n_tokens_mistral': 1282, 'n_tokens_neox': 1239, 'n_words': 139, 'path': 'CMA-ES/lambda/lambda.ipynb', 'repo_name': 'luzhijun/-', 'size': '2771'}