While comparing two methods for simulating crossing over I was surprised to 
find that the nice concise amend method below wasn't as fast or as lean as the 
numerical method.

   old=. i.5000 4000
   new=. -old
   5 4{.(old&*@:-. + new&* ) 0.7 > (5000 4000)[EMAIL PROTECTED]
     0      1      2     _3
 _4000  _4001  _4002   4003
  8000  _8001   8002  _8003
 12000 _12001 _12002 _12003
_16000 _16001 _16002 _16003
   5 4{.(0.5 > 5000 [EMAIL PROTECTED])}old,:new
     0     _1      2      3
 _4000   4001  _4002   4003
 _8000   8001  _8002  _8003
 12000 _12001 _12002 _12003
_16000  16001 _16002 _16003

   ts=. 6!:2,7!:[EMAIL PROTECTED]
   10 ts'(old&*@:-. + new&* ) 0.9 > (5000 4000)[EMAIL PROTECTED]'
1.3008018128 704645312
   10 ts'(0.9 > 5000 [EMAIL PROTECTED])}old,:new'
1.5297298050 973080320

Nevertheless I'm inclined towards the amend method for its conciseness and 
because in my mind it mirrors the crossing over process better.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to