def royal_road1(individual, order):
 nelem = (len(individual) / order)
 max_value = int(((2 ** order) - 1))
 total = 0
 for i in xrange(nelem):
  value = int(''.join(map(str, individual[(i * order):((i * order) + order)])), 2)
  total += (int(order) * int((value / max_value)))
 return (total,)

def royal_road1 ( individual , order ) : nelem = ( len ( individual ) / order ) max_value = int ( ( ( 2 ** order ) - 1 ) ) total = 0 for i in xrange ( nelem ) : value = int ( '' . join ( map ( str , individual [ ( i * order ) : ( ( i * order ) + order ) ] ) ) , 2 ) total += ( int ( order ) * int ( ( value / max_value ) ) ) return ( total , )
royal road function r1 as presented by melanie mitchell in : "an introduction to genetic algorithms" .