facebookresearch / nevergrad

A Python toolbox for performing gradient-free optimization
https://facebookresearch.github.io/nevergrad/
MIT License
3.95k stars 353 forks source link

hvRecursive: boolean comparison of np.array to None #346

Closed Corwinpro closed 4 years ago

Corwinpro commented 4 years ago

Steps to reproduce

Please see the following snippet:

import nevergrad as ng
from nevergrad.functions import MultiobjectiveFunction

SIZE = 2

def multiobjective(*args, **kwargs):
    return [1] * SIZE

f = MultiobjectiveFunction(
    multiobjective_function=multiobjective, upper_bounds=[5] * SIZE
)

optimizer = ng.optimizers.OnePlusOne(instrumentation=1, budget=100)
recommendation = optimizer.minimize(f)
print(recommendation)

Change SIZE from 2 to 3 to observe the problem.

Observed Results

This apparently should be

            while q.cargo is not None:

Expected Results

It is up to the developers to decide what comparison it should be there, element-wise or array to None.

Relevant Code

Please see above.

Suggestions

Change the comparison in while loop to while q.cargo is not None:. This fixed the problem to me, although I don't know whether we want to do .any() or .all() instead.

Thank you.

Corwinpro commented 4 years ago

This issue is approached by #356

Corwinpro commented 4 years ago

Fixed in #356.