Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Enhancing stop_criteria for Multi-Objective Optimization #314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Scyneo opened this issue Jan 23, 2025 · 1 comment
Open

Enhancing stop_criteria for Multi-Objective Optimization #314

Scyneo opened this issue Jan 23, 2025 · 1 comment

Comments

@Scyneo
Copy link

Scyneo commented Jan 23, 2025

In the current PyGAD implementation, the stop_criteria parameter references the fitness function's return value to determine when the desired fitness has been achieved. For example:

def fitness_func(ga_instance, solution, solution_idx):
    output = numpy.sum(solution * equation_inputs)

    fitness = 1.0 / (numpy.abs(output - desired_output) + 0.000001)

    return fitness

ga_instance = pygad.GA(
    num_generations=200,
    sol_per_pop=10,
    num_parents_mating=4,
    num_genes=len(equation_inputs),
    fitness_func=fitness_func,
    stop_criteria=["reach_127.4", "saturate_15"])

In this case, the reach_127.4 is pretty clear with what it does. However, the docs do not specify how stop_criteria works in the context of multi-objective optimization, where the fitness function returns multiple values like here:

def fitness_func(ga_instance, solution, solution_idx):
    ...
    return [fitness1, fitness2, ..., fitnessN]

From a quick look at the code I deduced that pygad actually supports it, but it's just not mentioned in the docs. So if I'm correct something like this works just fine for multi-objective optimization:

ga_instance = pygad.GA(
    num_generations=200,
    sol_per_pop=10,
    num_parents_mating=4,
    num_genes=len(equation_inputs),
    fitness_func=fitness_func,
    stop_criteria=["reach_127.4", "reach_130.1", "saturate_15"])

If that's the case, it would be great to have docs updated to reflect this mechanism

@ahmedfgad
Copy link
Owner

Thanks so much!

The documentation is updated and some more bugs are fixed: fd0e18f

Will be available in the next release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants