Skip to content

Request: attributes of best solution from all generations #107

Open
@Stoops-ML

Description

@Stoops-ML

From PyGAD's documentation the best_solutions attribute saves the best solution of every generation:

save_best_solutions=False: When True, then the best solution after each generation is saved into an attribute named best_solutions. If False (default), then no solutions are saved and the best_solutions attribute will be empty. Supported in PyGAD 2.9.0.

I would like an attribute to exist which would be the single best solution from all generations, rather than the existing best_solutions attribute that is a list of the best solutions from every generation. This would be helpful because the single best solution is not always the best solution of the last generation.

Something on the lines of (untested example):

def get_best_solution(self):
    best_gen = np.argmax(self.best_solutions_fitness)
    return self.best_solutions[best_gen]

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions