anyoptimization / pymoo

NSGA2, NSGA3, R-NSGA3, MOEAD, Genetic Algorithms (GA), Differential Evolution (DE), CMAES, PSO
https://pymoo.org
Apache License 2.0
2.23k stars 381 forks source link

Handling crashes in PSO #597

Closed oarcelus closed 2 months ago

oarcelus commented 4 months ago

I am trying to implement a PSO for a model. Sometimes, depending on the combination of input parameters, the model crashes and returns None. How should I handle this case with pymoo? Maybe postprocessing the _evaluate function to give a default value to those cases that crashed?

blankjul commented 4 months ago

Yes, I would sorround the third-party code with a try-catch and then set the objective to a large value (or introduce a inequality constraint to be 1 if failed and 0 if it succeeded. both will work)