I do not understand the shape that the algorithm is expecting for the init
parameter.
In the help, it says :
init
str or array-like, optionalSpecify which type of population initialization is performed. Should be one of:
‘latinhypercube’ ‘random’ array specifying the initial population.
The array should have shape (M, len(x)), where len(x) is the number of parameters. init is clipped to bounds before use.
I am passing in something (an array of array) with a shape of (1,17) as the initial value ( = the init
parameter). So a numpy array of 17 values representing my 17 parameters and am getting the following error message :
ValueError: The population supplied needs to have shape (M, len(x)), where M > 4.
Trying to dig into it I get this line in the source code :
if (np.size(popn, 0) < 5 or
popn.shape[1] != self.parameter_count or
len(popn.shape) != 2):
raise ValueError("The population supplied needs to have shape"
" (M, len(x)), where M > 4.")
The last 2 out of 3 statements in the if
I understand. You want to make sure that it is an array of array and that the arrays all have the correct size (i.e the number of parameters).
But why does the algo expect the user to give it at least 4 possible starting values ?
The reason why M
has to be greater than 4 is that the Rand2
evolution strategy needs at least 5 population members. You can read more about that here.