{"id":6060,"library":"pymoo","title":"pymoo: Multi-Objective Optimization in Python","description":"Pymoo is an open-source Python library for multi-objective optimization. It provides state-of-the-art single- and multi-objective optimization algorithms, along with features for visualization and decision-making. Currently at version 0.6.1.6, the library maintains an active development cadence with regular updates and bug fixes.","status":"active","version":"0.6.1.6","language":"en","source_language":"en","source_url":"https://github.com/anyoptimization/pymoo","tags":["optimization","multi-objective","evolutionary algorithms","NSGA-II","NSGA-III","MOEA/D","genetic algorithms"],"install":[{"cmd":"pip install -U pymoo","lang":"bash","label":"Install stable version"},{"cmd":"pip install -U pymoo[visualization]","lang":"bash","label":"Install with visualization dependencies"},{"cmd":"pip install -U pymoo[parallelization]","lang":"bash","label":"Install with parallelization dependencies"}],"dependencies":[{"reason":"Progress bar for optimization process","package":"alive_progress"},{"reason":"Automatic differentiation (can be optional since 0.6.1.3)","package":"autograd"},{"reason":"Required for CMA-ES algorithm","package":"cma"},{"reason":"Utility for marking deprecated code","package":"deprecated"},{"reason":"For visualization capabilities","package":"matplotlib"},{"reason":"Core multi-objective optimization utilities","package":"moocore"},{"reason":"Fundamental package for numerical computing","package":"numpy"},{"reason":"Scientific computing tools","package":"scipy"},{"reason":"For parallelization features","package":"joblib","optional":true},{"reason":"For parallelization features","package":"dask","optional":true},{"reason":"For parallelization features","package":"ray","optional":true},{"reason":"For hyperparameter tuning features","package":"optuna","optional":true}],"imports":[{"note":"Module organization changed in 0.5.0; factory methods deprecated in 0.6.0.","wrong":"from pymoo.factory import get_algorithm","symbol":"NSGA2","correct":"from pymoo.algorithms.moo.nsga2 import NSGA2"},{"note":"Factory methods deprecated in 0.6.0. Use direct import or problem definition classes.","wrong":"from pymoo.factory import get_problem","symbol":"get_problem","correct":"from pymoo.problems import get_problem"},{"symbol":"minimize","correct":"from pymoo.optimize import minimize"},{"symbol":"Scatter","correct":"from pymoo.visualization.scatter import Scatter"}],"quickstart":{"code":"import numpy as np\nfrom pymoo.algorithms.moo.nsga2 import NSGA2\nfrom pymoo.core.problem import Problem\nfrom pymoo.optimize import minimize\nfrom pymoo.visualization.scatter import Scatter\n\n# Define your custom problem as an object\nclass MyProblem(Problem):\n    def __init__(self):\n        super().__init__(n_var=2, n_obj=2, n_constr=2, xl=np.array([-2.0, -2.0]), xu=np.array([2.0, 2.0]))\n\n    def _evaluate(self, X, out, *args, **kwargs):\n        f1 = X[:, 0]**2 + X[:, 1]**2\n        f2 = (X[:, 0]-1)**2 + X[:, 1]**2\n\n        g1 = 2 * (X[:, 0]-0.1) * (X[:, 0]-0.9)\n        g2 = 20 * (X[:, 0]-0.4) * (X[:, 0]-0.6)\n\n        out[\"F\"] = np.column_stack([f1, f2])\n        out[\"G\"] = np.column_stack([g1, g2])\n\n# Instantiate the problem\nproblem = MyProblem()\n\n# Choose an algorithm\nalgorithm = NSGA2(pop_size=100)\n\n# Define the termination criterion\ntermination = ('n_gen', 200)\n\n# Optimize\nres = minimize(problem, algorithm, termination, seed=1, verbose=False)\n\n# Plot the results\nplot = Scatter()\nplot.add(res.F, color=\"red\")\nplot.show()","lang":"python","description":"This quickstart defines a custom constrained multi-objective optimization problem, initializes the NSGA-II algorithm, sets a termination criterion based on the number of generations, runs the optimization, and visualizes the resulting Pareto front. Note that custom problems should now inherit from `pymoo.core.problem.Problem` or `ElementwiseProblem`."},"warnings":[{"fix":"Update import paths to reflect the new structure, e.g., `from pymoo.algorithms.moo.nsga2 import NSGA2` instead of `from pymoo.algorithms.nsga2 import NSGA2` (old paths are approximate).","message":"The module organization was entirely changed in version 0.5.0. Many classes, especially algorithms, moved to nested submodules (e.g., `pymoo.algorithms.moo.nsga2.NSGA2`).","severity":"breaking","affected_versions":">=0.5.0"},{"fix":"Directly import and instantiate classes (e.g., `NSGA2(pop_size=100)`) instead of using factory functions (e.g., `get_algorithm(\"nsga2\", pop_size=100)`).","message":"Factory methods (`get_algorithm`, `get_problem`, `get_mutation`, etc.) were deprecated or deactivated in version 0.6.0 to improve clarity and reduce maintenance overhead.","severity":"breaking","affected_versions":">=0.6.0"},{"fix":"Adjust custom termination logic to return a float, or use tuple-based termination criteria (e.g., `('n_gen', 200)`).","message":"The termination criterion interface changed in version 0.6.0. Custom termination objects now need to return a floating-point number (0 for continue, 1 for terminate) instead of a boolean.","severity":"breaking","affected_versions":">=0.6.0"},{"fix":"Upgrade `pymoo` to version 0.6.1.3 or newer, or downgrade `numpy` to a version less than 2.0.0 (e.g., `numpy<2`). `autograd` is now optional in `pymoo >= 0.6.1.3`.","message":"Versions prior to 0.6.1.3 are incompatible with NumPy 2.0.0 due to changes in how `autograd` interacts with NumPy's internal structure.","severity":"breaking","affected_versions":"<0.6.1.3"},{"fix":"Understand the differences and select the appropriate problem definition for your use case. `Problem` is generally preferred for population-based algorithms due to vectorized evaluation efficiency, while `ElementwiseProblem` simplifies custom parallelization.","message":"Pymoo offers three ways to define an optimization problem: `Problem` (vectorized evaluation), `ElementwiseProblem` (single-solution evaluation), and `FunctionalProblem` (using functions). Choosing the wrong type can impact performance and parallelization.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}