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
The example above results in ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all().
The problem is in nevergrad/functions/multiobjective/pyhv.py:127:
while q.cargo != None:
This apparently should be
while q.cargo is not None:
It feels that with SIZE == 2 the _HyperVolume().hvRecursive is never called. With SIZE > 2 it is called, and therefore throws the error.
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.
Steps to reproduce
Please see the following snippet:
Change
SIZE
from2
to3
to observe the problem.Observed Results
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
.nevergrad/functions/multiobjective/pyhv.py:127
:This apparently should be
SIZE == 2
the_HyperVolume().hvRecursive
is never called. WithSIZE > 2
it is called, and therefore throws the error.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 towhile 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.