所以,我做了一个比较Pyevolve GP / GA核心的不同Python解释。I’ve used my Pentium Core 2 Duo (E4500 @ 2.20GHz, 1GB RAM), using Ubuntu 9.04 and Windows XP SP3 just for IronPython 2.6.1 (IronPython doesn’t run with Mono, so I used the win xp with .net 2.0).
使用的翻译是:
我试着用2009Q3(当前主干线),但我认为这是不稳定的是,因为它比2009Q2更慢,所以我用2009Q2;我只使用默认的配置参数时(./configure)与GCC 4.3.3编译它。
I used the default CPython package of Ubuntu 9.04.
我使用的Ubuntu 9.04的默认CPython的包也一样,包装的python2.5。
我使用的存储库的最后一个SVN版本,释放68612.我的奔腾酷睿2只有1GB的RAM,和PyPy翻译过程中吃更多的内存比Java(遗憾的笑话),所以我用一个笔记本的3GBRAM创建pypy-C,有什么耗时1小时(我用-opt = 3)和一个美丽的ASCII曼德尔布罗分形!
I used the default installer from the Jython project site. I used the Sun JRE 1.6.0_16.
我已经使用可在IronPython的项目现场与MS .NET 2.0的2.6 RC1。
为了测试我用这个源代码(一个简单的球体功能)的GA芯:
从进口pyevolve存取器pyevolve进口G1DList,从pyevolve进口GSimpleGA Initializators,Consts#这是球函数DEF球(的Xlist):总= 0对于i中的Xlist:总+ = I ** 2返回总DEF run_main():基因组= G1DList.G1DList(140)genome.setParams(rangemin = -5.12,的RangeMax = 5.13)genome.initializator.set(Initializators.G1DListInitializatorReal)genome.mutator.set(Mutators.G1DListMutatorRealGaussian)genome.evaluator.set(球体)GA= GSimpleGA.GSimpleGA(基因组,种子= 666)ga.setMinimax(Consts.minimaxType [ “最小化”])ga.setGenerations(1500)ga.setMutationRate(0.01)ga.evolve(freq_stats = 500)最好= ga.bestIndividual()如果__name__ == “__main__”:run_main()
And to test the GP core, I’ve used this source-code (a simple symbolic regression):
from pyevolve import GTree from pyevolve import Mutators from pyevolve import GSimpleGA, Consts, Util import math rmse_accum = Util.ErrorAccumulator() def gp_add(a, b): return a+b def gp_sub(a, b): return a-b def gp_mul(a, b): return a*b def gp_sqrt(a): return math.sqrt(abs(a)) def eval_func(chromosome): global rmse_accum rmse_accum.reset() code_comp = chromosome.getCompiledCode() for a in xrange(0, 10): for b in xrange(0, 10): evaluated = eval(code_comp) target = math.sqrt((a*a)+(b*b)) rmse_accum += (target, evaluated) return rmse_accum.getRMSE() def main_run(): genome = GTree.GTreeGP() genome.setParams(max_depth=4, method="ramped") genome.evaluator += eval_func genome.mutator.set(Mutators.GTreeGPMutatorSubtree) ga = GSimpleGA.GSimpleGA(genome, seed=666) ga.setParams(gp_terminals = ['a', 'b'], gp_function_prefix = "gp") ga.setMinimax(Consts.minimaxType["minimize"]) ga.setGenerations(40) ga.setCrossoverRate(1.0) ga.setMutationRate(0.08) ga.setPopulationSize(800) ga(freq_stats=10) best = ga.bestIndividual() if __name__ == "__main__": main_run()
更新19/08:the x-axis is measured in “秒“, and the y-axis is the python flavor;
结果列在下面的图表描述:
我们可以看到,空载燕子2009Q2确实与CPython 2.6.2好一点的表现,但Jython和PyPy(实验)被留在那种情况下,力挺IronPython的2.6.1。