跳到正文
Skillpedia
机器学习51k · #3544

pymoo

它能做什么

这是一个用于寻找复杂问题最优解的工具,适用于存在多个相互冲突目标的情况。它能帮你找到各种可能的最佳“权衡”方案。

适用场景

  • ✓当你的问题有多个需要同时优化的目标时。
  • ✓当你想在相互竞争的目标之间找到最佳平衡时。
  • ✓当你需要分析不同方案,从而做出更明智的决策时。

技能链接

https://github.com/K-Dense-AI/scientific-agent-skills/blob/main/skills/pymoo/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/K-Dense-AI/scientific-agent-skills/blob/main/skills/pymoo/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“我想优化汽车设计,让油耗最低、生产成本也最低,最好的方案有哪些?”

每周 5 个新技能,1 分钟读完。

工作原理

你先定义问题,再选择一种优化方法(比如 NSGA-II),然后工具会搜索最优解,并返回找到的解及其结果。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Pymoo - Multi-Objective Optimization in Python

Overview

Pymoo is a comprehensive Python framework for optimization with emphasis on multi-objective problems. Solve single and multi-objective optimization using state-of-the-art algorithms (NSGA-II/III, MOEA/D, SPEA2), benchmark problems (ZDT, DTLZ), customizable genetic operators, and multi-criteria decision making methods. Excels at finding trade-off solutions (Pareto fronts) for problems with conflicting objectives. Targets stable pymoo 0.6.2, reviewed 2026-10-01 against current official docs and native toy runs.

Installation

uv pip install "pymoo==0.6.2"

For reproducible environments, pin a version: uv pip install "pymoo==0.6.2".

Dependencies: The released 0.6.2 wheel requires NumPy, SciPy, moocore, autograd, cma, matplotlib, alive_progress, and Deprecated. NumPy 2.x is supported. The current installation prose describes some dependencies as optional; the released package metadata governs installation. Joblib, Optuna and dill are separate dependencies for the corresponding recipes.

Documentation: https://pymoo.org/ — LLM-friendly index: https://pymoo.org/llms.txt

When to Use This Skill

This skill should be used when:

  • Solving optimization problems with one or multiple objectives
  • Finding Pareto-optimal solutions and analyzing trade-offs
  • Implementing evolutionary algorithms (GA, DE, PSO, NSGA-II/III)
  • Working with constrained optimization problems
  • Benchmarking algorithms on standard test problems (ZDT, DTLZ, WFG)
  • Customizing genetic operators (crossover, mutation, selection)
  • Visualizing high-dimensional optimization results
  • Making decisions from multiple competing solutions
  • Handling binary, discrete, continuous, or mixed-variable problems

Core Concepts

The Unified Interface

Pymoo uses a consistent minimize() function for all optimization tasks:

from pymoo.optimize import minimize

result = minimize(
    problem,        # What to optimize
    algorithm,      # How to optimize
    termination,    # When to stop
    seed=1,
    verbose=True
)

Result object contains:

  • result.X: Decision variables of optimal solution(s)
  • result.F: Objective values of optimal solution(s)
  • result.G: Raw inequality values (g(x) <= 0 is feasible)
  • result.H: Raw equality residuals
  • result.CV: Aggregated constraint violation under the configured tolerances
  • result.algorithm: Final algorithm state; history is retained when requested

Check feasibility before plotting or selecting: If no feasible solution was found, result.X and result.F can be None. With return_least_infeasible=True, a returned candidate can still violate constraints; report its CV and residuals instead of calling it feasible. Re-evaluate chosen candidates against the original physical constraints after any normalization or repair. See the result contract.

Problem Definition Styles

Pymoo supports three problem definition styles:

  • Problem: Vectorized — _evaluate receives a batch of solutions (matrix)
  • ElementwiseProblem: One solution per call — recommended for custom problems and parallel evaluation
  • FunctionalProblem: Define objectives and constraints as separate functions without subclassing

Problem Types

Single-objective: One objective to minimize; negate a maximization objective and record the conversion Multi-objective: 2-3 conflicting objectives → Pareto front Many-objective: 4+ objectives → High-dimensional Pareto front Constrained: Objectives + inequality/equality constraints Mixed-variable: Continuous, integer, binary, and categorical variables in one problem Dynamic: Time-varying objectives or constraints

Quick Start Workflows

Nine workflows and context-dependent adaptation snippets are in references/quick_start_workflows.md:

# Workflow Use when
1 Single-objective optimization one objective, GA or DE
2 Multi-objective (2-3 objectives) NSGA-II and a Pareto front
3 Many-objective (4+ objectives) NSGA-III or reference-direction methods
4 Custom problem definition subclassing Problem / ElementwiseProblem
5 Constraint handling inequality and equality constraints
6 Decision making from a Pareto front scalarization and MCDM selection

…

常见问题

什么是“权衡方案”?

它是在相互冲突的目标之间取得较好平衡的方案。例如,一辆车可能不是油耗最低的,但它在里程和成本之间提供了较好的折中。

什么是“帕累托前沿”?

它是一组解,在这些解中,如果不让某个目标变差,就无法让另一个目标变好。它代表了所有最佳的权衡方案。

这个工具能解决哪些类型的问题?

它可以处理单目标或多目标问题,有约束或无约束的问题,也能处理不同变量类型(整数、二元变量等)的问题。

详情

作者的原始描述

Solves and validates single-, multi-, and many-objective optimization with pymoo, including NSGA-II, NSGA-III, MOEA/D, constraints, Pareto approximations, reference directions, and ZDT/DTLZ benchmarks for engineering and research problems.

repo: K-Dense-AI/scientific-agent-skills

热度

GitHub 星标
51k
排名
#3544
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能