1

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, optional

Specify 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 ?

Community
  • 1
  • 1
Chapo
  • 2,563
  • 3
  • 30
  • 60
  • You could make the context of this question clearer, with links, and fuller description. I had to do some digging to figure what you were asking about. What initially threw me was your description of a (1,17) 'seed'. Why 'seed'? Why 17? – hpaulj Aug 05 '19 at 04:14
  • I am talking about the 'init' parameter of the algorithm so assumed seed made sense in that case : the inital value you are feeding to the algo. It's in the question title only though so will put it in the question. – Chapo Aug 05 '19 at 07:14
  • edited it to make it clearer hopefully – Chapo Aug 05 '19 at 07:19
  • Did it not help @hpaulj ? – Chapo Aug 06 '19 at 03:39
  • @Chapo can you select the answer as approved? – Himanshu Bansal Sep 18 '19 at 04:53

1 Answers1

2

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.

Himanshu Bansal
  • 2,003
  • 1
  • 23
  • 46