Arie - what is the intent of "p=. 1+?1" since "?1" always returns zero?
Devon
On 12/3/07, Arie Groeneveld <[EMAIL PROTECTED]> wrote:
>
> Dear J-ers,
>
> what kind of program improvements would you
> consider for this simple genetic algorithm?
>
>
> ord=: a. i.]
> chr=: a.{~]
>
> NB. fitness function
> ffit=: [:+/[EMAIL PROTECTED] (**)@:- [EMAIL PROTECTED]
>
> evolueer=: 4 : 0
> s=.x ffit y
> oud=.y
> l=. #y
> g=.0
> pw=.x
> (('gen: '),(":g),'(',(":s),')',oud) (1!:2) 2
> while. 0<s do.
> p=. 1+?l
> tc=. ord (p-1){oud
> vk=. (?3){chr (32+?95), (tc+1), tc-1
> kind=. vk (p-1)} oud
> kinds=. pw ffit kind
> if. kinds < s do.
> s=. kinds
> oud=.kind
> end.
> g=.g+1
> NB. ('gen: ',(":g),'(',(":s),') ',oud) (1!:2) 2
> end.
> 'gen: ',(":g),'(',(":s),') ',oud
> )
>
> (] evolueer [:chr 32+[:?95$~#) 'Perfect creature!'
> gen: 0(597)Qv_l->[EMAIL PROTECTED]
> gen: 1043(0) Perfect creature!
>
>
> Thanks
>
>
> =@@i
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
--
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm