Skip to content

Conversation

MBradbury
Copy link
Contributor

@MBradbury MBradbury commented Oct 18, 2023

When using parallel processing and multiple objectives are returned from the fitness function, then the following exception will be raised. This PR fixes the issue by avoiding comparisons between the undefined string and a numpy array. This would fix #236.

ERROR: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Traceback (most recent call last):
  File ".venv/lib/python3.10/site-packages/pygad/pygad.py", line 1790, in cal_pop_fitness
    if pop_fitness[sol_idx] == "undefined":
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Version information:

$ python
Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygad
>>> pygad.__version__
'3.2.0'

@ahmedfgad ahmedfgad merged commit 263cb49 into ahmedfgad:master Nov 2, 2023
@ahmedfgad ahmedfgad added the bug Something isn't working label Jan 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multi-Objective Optimization and parallel_processing
2 participants