lundi 8 avril 2019

Numpy random - Specify Multiple Bounds & Steps

I need to generate the initial population of a genetic algorithm. Consider the following vector:

[20, 2, 20, 1.5, 5, 20, 5, 0.5, -0.5, 5, 20, 5, 3, 14, 70, 30, 10, 5, 5, 20, 8, 20, 2.5]

I would do this:

new_population = numpy.random.uniform(low=0.1, high=50.0, size=pop_size)

The problem is, some of the chromosomes in the problem space have different steps and different maximum values. Element 0 should be 1-100 with a step of 1 (So int). Element 3 should be 0.1-10 with a step of 0.1 (Float). What is the easiest way to do this randomization?




Aucun commentaire:

Enregistrer un commentaire