#NEWLINE# @ crossover #NEWLINE# def laplace_crossover( random , mom , dad , args ) : #NEWLINE# #INDENT# 'Return the offspring of Laplace crossover on the candidates.\n    \n    This function performs Laplace crosssover (LX), following the \n    implementation specified in (Deep and Thakur, "A new crossover \n    operator for real coded genetic algorithms," Applied Mathematics \n    and Computation, Volume 188, Issue 1, May 2007, pp. 895--911).\n    This function also makes use of the bounder function as specified \n    in the EC\'s ``evolve`` method.    \n \n    .. Arguments:\n       random -- the random number generator object\n       mom -- the first parent candidate\n       dad -- the second parent candidate\n       args -- a dictionary of keyword arguments\n\n    Optional keyword arguments in args:\n    \n    - *crossover_rate* -- the rate at which crossover is performed \n      (default 1.0)\n    - *lx_location* -- the location parameter (default 0)\n    - *lx_scale* -- the scale parameter (default 0.5)\n    \n    In some sense, the *lx_location* and *lx_scale* parameters can be thought \n    of as analogs in a Laplace distribution to the mean and standard \n    deviation of a Gaussian distribution. If *lx_scale* is near zero, offspring \n    will be produced near the parents. If *lx_scale* is farther from zero, \n    offspring will be produced far from the parents.\n    \n    ' #NEWLINE# crossover_rate = args . setdefault ( 'crossover_rate' , 1.0 ) #NEWLINE# if ( random . random ( ) < crossover_rate ) : #NEWLINE# #INDENT# bounder = args [ '_ec' ] . bounder #NEWLINE# a = args . setdefault ( 'lx_location' , 0 ) #NEWLINE# b = args . setdefault ( 'lx_scale' , 0.5 ) #NEWLINE# bro = copy . copy ( dad ) #NEWLINE# sis = copy . copy ( mom ) #NEWLINE# for ( i , ( m , d ) ) in enumerate ( zip ( mom , dad ) ) : #NEWLINE# #INDENT# u = random . random ( ) #NEWLINE# if ( random . random ( ) <= 0.5 ) : #NEWLINE# #INDENT# beta = ( a - ( b * math . log ( u ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# beta = ( a + ( b * math . log ( u ) ) ) #NEWLINE# #UNINDENT# bro [ i ] = ( m + ( beta * abs ( ( m - d ) ) ) ) #NEWLINE# sis [ i ] = ( d + ( beta * abs ( ( m - d ) ) ) ) #NEWLINE# #UNINDENT# bro = bounder ( bro , args ) #NEWLINE# sis = bounder ( sis , args ) #NEWLINE# return [ bro , sis ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return [ mom , dad ]