## 健康和遗传算法

Math and medicine are coming together to help people who have suffered an abdominal aortic aneurysm, which with 15,000 is the 13th-leading cause of death in the United States.

At the heart of the effort are genetic algorithms written by Oak Ridge National Laboratory researchers that allow physicians to more efficiently assess and organize the often vast amounts of information contained in patient reports. Ultimately, with this tool—a sophisticated way to quickly extract key phrases—doctors will be able to characterize features and findings in reports and provide better patient care.

(…)

## Darwin on the track

The Economistarticle:

WHILE watching the finale of the Formula One grand-prix season on television last weekend, your correspondent could not help thinking how Darwinian motor racing has become. Each year, the FIA, the international motor sport’s governing body, sets new design rules in a bid to slow the cars down, so as to increase the amount of overtaking during a race—and thereby make the event more interesting to spectators and television viewers alike. The aim, of course, is to keep the admission and television fees rolling in. Over the course of a season, Formula One racing attracts a bigger audience around the world than any other sport.

## Meanwhile, at the Hall of Justice!

WASHINGTON, Oct. 5 — Criminals are having a harder time hiding their faces, thanks to new software that helps witnesses recreate and recognize suspects using principles borrowed from the fields of optics and genetics.

(…)

“Over a number of generations, the computer can learn what face you’re looking for,” says Solomon.

## N皇后使用Pyevolve问题

Last night I’ve阅读后书签交易马修·罗林斯示出在Python代码来解决Eight Queenspuzzle using EA. So I decided to implement it in Python again but this time using Pyevolve, here is the code:

`从pyevolve进口*从随机导入洗牌BOARD_SIZE = 64 DEF queens_eval（基因组）：碰撞= 0对于i在x范围（0，BOARD_SIZE）：如果我不在基因组：在x范围对于i返回0（0，BOARD_SIZE）：山口=False for j in xrange(0, BOARD_SIZE): if (i != j) and (abs(i-j) == abs(genome[j]-genome[i])): col = True if col == True: collisions +=1 return BOARD_SIZE-collisions def queens_init(genome, **args): genome.genomeList = range(0, BOARD_SIZE) shuffle(genome.genomeList) def run_main(): genome = G1DList.G1DList(BOARD_SIZE) genome.setParams(bestrawscore=BOARD_SIZE, rounddecimal=2) genome.initializator.set(queens_init) genome.mutator.set(Mutators.G1DListMutatorSwap) genome.crossover.set(Crossovers.G1DListCrossoverCutCrossfill) genome.evaluator.set(queens_eval) ga = GSimpleGA.GSimpleGA(genome) ga.terminationCriteria.set(GSimpleGA.RawScoreCriteria) ga.setMinimax(Consts.minimaxType["maximize"]) ga.setPopulationSize(100) ga.setGenerations(5000) ga.setMutationRate(0.02) ga.setCrossoverRate(1.0) # This DBAdapter is to create graphs later, it'll store statistics in # a SQLite db file sqlite_adapter = DBAdapters.DBSQLite(identify="queens") ga.setDBAdapter(sqlite_adapter) ga.evolve(freq_stats=10) best = ga.bestIndividual() print best print "\nBest individual score: %.2f\n" % (best.score,) if __name__ == "__main__": run_main()`

It tooks 49 generations to solve a 64×64 (4.096 chess squares) chessboard, here is the output:

`创0（0.00％）：最大/最小/平均健身（原始）20.83（27.00）/13.63（7.00）/17.36（17.36）]创10（0.20％）：最大/最小/平均健身（RAW）[55.10（50.00）/39.35（43.00）/45.92（45.92）]创20（0.40％）：最大/最小/平均健身（原始）52.51（55.00）/28.37（24.00）/43.76（43.76）]代30（0.60％）：最大/最小/平均健身（原始）67.45（62.00）/51.92（54.00）/56.21（56.21）]创40（0.80％）：最大/最小/平均健身（原始）65.50（62.00）/19.89（31.00）/54.58（54.58）]进化停止的终止条件的功能！创49（0.98％）：最大/最小/平均健身（原始）69.67（64.00）/54.03（56.00）/58.06（58.06）]的总时间经过：39.141秒。`

And here is the plots generated by the Graph Plot Tool of Pyevolve:

## Genetic Programming meets Python

The implementation is still under some tests and optimization, but it’s working nice, here is some details about it:

The implementation has been done inpure Python, so we still have many bonus from this, but unfortunatelly we lost some performance.

Here is a source-code example:

`从进口pyevolve *进口数学error_accum = Util.ErrorAccumulator（）＃这是所使用的GP核心，＃Pyevolve会自动检测到它们＃的功能和它们的数量DEF gp_add（A，B）的参数：返回A + B DEFgp_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 error_accum error_accum.reset() code_comp = chromosome.getCompiledCode() for a in xrange(0, 5): for b in xrange(0, 5): # The eval will execute a pre-compiled syntax tree # as a Python expression, and will automatically use # the "a" and "b" variables (the terminals defined) evaluated = eval(code_comp) target = math.sqrt((a*a)+(b*b)) error_accum += (target, evaluated) return error_accum.getRMSE() def main_run(): genome = GTree.GTreeGP() genome.setParams(max_depth=5, method="ramped") genome.evaluator.set(eval_func) ga = GSimpleGA.GSimpleGA(genome) # This method will catch and use every function that # begins with "gp", but you can also add them manually. # The terminals are Python variables, you can use the # ephemeral random consts too, using ephemeral:random.randint(0,2) # for example. ga.setParams(gp_terminals = ['a', 'b'], gp_function_prefix = "gp") # You can even use a function call as terminal, like "func()" # and Pyevolve will use the result of the call as terminal ga.setMinimax(Consts.minimaxType["minimize"]) ga.setGenerations(1000) ga.setMutationRate(0.08) ga.setCrossoverRate(1.0) ga.setPopulationSize(2000) ga.evolve(freq_stats=5) print ga.bestIndividual() if __name__ == "__main__": main_run()`

And of course, everything in Pyevolve can be visualized any time you want (click to enlarge):

`@ GTree.gpdec（表示= “+”，颜色= “红”）DEF gp_add（A，B）：返回A + B`

## Pyevolve: Genetic Algorithms + Interactive Mode

I’ve made a video of an example using the Pyevolve’s交互模式在遗传算法的进化的中间。视频是在高分辨率，所以你可以看到这里或点击下面的图像上：

(…)