Utilities Module

This module implements some basic utilities for use with Grammatical Evolution

def rand_weight(constraint=1.0):

Returns a random weight centered around 0. The constrain limits the value to the maximum that it would return. For example, if .5 is the constraint, then the returned weight would between -.5 and +.5.

def base10tobase2(value, zfill=0):

This function converts from base 10 to base 2 in string format. In addition, it takes a parameter for zero filling to pad out to a specific length.

Note that the incoming number is converted to an int, and that if it is a negative number that the negative sign is added on to the total length, resulting in a string 1 char longer than the zfill specified.

def base2tobase10(value):

This function converts from base 2 to base 10. Unlike base10tobase2, there is no zfill option, and the result is output as an int.