Pymoo

From mkurman/zorai · View interactive version

Pymoo is an AI agent skill from the GitHub repository mkurman/zorai. Multi-objective optimization framework. NSGA-II, NSGA-III, MOEA/D, Pareto fronts, constraint handling, benchmarks (ZDT, DTLZ), for engineering design and optimization problems.

How to use this skill

Skill file

-------|--------------|

| GA | General-purpose | Flexible, customizable operators |

| DE | Continuous optimization | Good global search |

| PSO | Smooth landscapes | Fast convergence |

| CMA-ES | Difficult/noisy problems | Self-adapting |

Multi-Objective Problems (2-3 objectives)

| Algorithm | Best For | Key Features |

|-----------|----------|--------------|

| NSGA-II | Standard benchmark | Fast, reliable, well-tested |

| R-NSGA-II | Preference regions | Reference point guidance |

| MOEA/D | Decomposable problems | Scalarization approach |

Many-Objective Problems (4+ objectives)

| Algorithm | Best For | Key Features |

|-----------|----------|--------------|

| NSGA-III | 4-15 objectives | Reference direction-based |

| RVEA | Adaptive search | Reference vector evolution |

| AGE-MOEA | Complex landscapes | Adaptive geometry |

Constrained Problems

| Approach | Algorithm | When to Use |

|----------|-----------|-------------|

| Feasibility-first | Any algorithm | Large feasible region |

| Specialized | SRES, ISRES | Heavy constraints |

| Penalty | GA + penalty | Algorithm compatibility |

See: references/algorithms.md for comprehensive algorithm reference

Benchmark Problems

Quick problem access:

from pymoo.problems import get_problem

# Single-objective
problem = get_problem("rastrigin", n_var=10)
problem = get_problem("rosenbrock", n_var=10)

# Multi-objective
problem = get_problem("zdt1")        # Convex front
problem = get_problem("zdt2")        # Non-convex front
problem = get_problem("zdt3")        # Disconnected front

# Many-objective
problem = get_problem("dtlz2", n_obj=5, n_var=12)
problem = get_problem("dtlz7", n_obj=4)

See: references/problems.md for complete test problem reference

Genetic Operator Customization

Standard operator configuration:

from pymoo.algorithms.soo.nonconvex.ga import GA
from pymoo.operators.crossover.sbx import SBX
from pymoo.operators.mutation.pm import PM

algorithm = GA(
    pop_size=100,
    crossover=SBX(prob=0.9, eta=15),
    mutation=PM(eta=20),
    eliminate_duplicates=True
)

Operator selection by variable type:

Continuous variables:

Binary variables:

Permutations (TSP, scheduling):

See: references/operators.md for comprehensive operator reference

Performance and Troubleshooting

Common issues and solutions:

Problem: Algorithm not converging

Problem: Poor Pareto front distribution

Problem: Few feasible solutions

Problem: High computational cost

Best practices:

  1. Normalize objectives when scales differ significantly
  2. Set random seed for reproducibility
  3. Save history to analyze convergence: save_history=True
  4. Visualize results to understand solution quality
  5. Compare with true Pareto front when available
  6. Use appropriate termination criteria (generations, evaluations, tolerance)
  7. Tune operator parameters for problem characteristics

Resources

This skill includes comprehensive reference documentation and executable examples:

references/

Detailed documentation for in-depth understanding:

Search patterns for references:

scripts/

Executable examples demonstrating common workflows:

Run examples:

python3 scripts/single_objective_example.py
python3 scripts/multi_objective_example.py
python3 scripts/many_objective_example.py
python3 scripts/custom_problem_example.py
python3 scripts/decision_making_example.py

Additional Notes

Installation:

uv pip install pymoo

Dependencies: NumPy, SciPy, matplotlib, autograd (optional for gradient-based)

Documentation: https://pymoo.org/

Version: This skill is based on pymoo 0.6.x

Common patterns:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.