Skip to content

Multi-Objective Optimization and parallel_processing #236

@lumy

Description

@lumy

It's seem you can run parrallel processing and multi objective at the same time,
if you run this minimal code


def func(a, b, c):
  return [0.25, 0.75, 0.0, 0.5]

def test():
    ga_instance = pygad.GA(
            num_generations=generation,
            num_parents_mating=180,
            fitness_func=func,
            save_solutions=False,
            allow_duplicate_genes=False,
            parallel_processing=["process", 10],
            parent_selection_type="nsga2",
            num_genes=256, sol_per_pop=256,
    )
    ga_instance.run()

you get this 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 "/home/lumy/.local/lib/python3.9/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()

When you look the type of pop_fitness[sol_idx] it's not anymore an instance of List (as we could except because fitness_func return a list) but an numpy.ndarray
And numpy doesn't allow that

is this a normal behavior ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions