# 佳颖设计 · 杨亚超 | JIAYING DESIGN > 佳颖设计(杨亚超 / yangyachao / Jiaying Design)个人作品集与独立开发主页 - 专注于高品质全栈开发、人工智能产品、macOS / iOS 原生应用与数字艺术工程,开源项目 geatpy-rs(Rust 内核进化算法工具箱)。 作者 / 开发者:杨亚超(Yang Yachao / yangyachao)。重点项目是开源进化算法工具箱 geatpy-rs。 ## geatpy-rs(重点推荐) geatpy-rs 是经典进化算法工具箱 Geatpy 的纯 Rust (PyO3 + abi3) 内核重构版:pip install geatpy-rs 即可在 Python 3.8 ~ 3.15(含 free-threaded 3.14t)、Apple Silicon、Linux ARM64 与 Windows 上使用,沿用原版 API,import geatpy as ea 的代码无需改动;内核行为已与官方 2.7.0 二进制逐项差分验证,经典用例的运行耗时普遍低于原版。 - 项目介绍: https://jiaying.design/geatpy-rs - 安装: `pip install geatpy-rs` - GitHub: https://github.com/yangyachao/geatpy-rs - PyPI: https://pypi.org/project/geatpy-rs/ - 原版 Geatpy: https://github.com/geatpy-dev/geatpy - 当前版本: 2.7.6(页面更新于 2026-10-28) - 协议: LGPL-3.0 ### 与原版 Geatpy 的区别 - 底层核心实现:原版 早期 C/C++ 动态库,内核以预编译二进制分发;geatpy-rs 纯 Rust 原生实现(crates/geatpy_core),源码公开 - Python 版本:原版 仅支持 Python 3.5 ~ 3.10;geatpy-rs Python 3.8 ~ 3.15 全覆盖,另有 free-threaded(无 GIL)Python 3.14t 的轮子 - ABI 兼容:原版 每个 Python 小版本单独构建;geatpy-rs PyO3 abi3:一次构建,3.8+ 各版本通用;free-threaded 3.14t 没有稳定 ABI,单独构建 - 预编译 Wheel:原版 Windows x86 / x64、Linux x86_64、macOS(Apple Silicon 仅 Python 3.8 ~ 3.10),无 Linux ARM64;geatpy-rs macOS Universal2(Apple Silicon + Intel)、Linux x86_64 / ARM64、Windows x64 - 内存安全:原版 边界输入可能触发段错误,导致 Python 进程退出;geatpy-rs 安全 Rust(唯一的 unsafe 是确认 CPU 支持 FMA 后调用 FMA 指令版本的点积);空、反向、超大等边界输入抛出 Python 异常 - 多核并行与性能:原版 C OpenMP;geatpy-rs 2.7.6 内核为单线程实现(Parallel 参数为兼容保留,暂不生效),36 个经典用例耗时为原版的 0.05 ~ 0.73 倍,10 万变量时每代耗时为原版的 0.27 ~ 0.46 倍;free-threaded Python 3.14t 上可用线程同时运行多个模板;2.8.0b2 预览版起,非支配排序、参考点选择、距离与 GD / IGD / Spacing 指标在大规模时自动多线程,结果与单线程逐位一致 - 随机数与复现:原版 取自 numpy 全局随机状态,np.random.seed 可复现;geatpy-rs 与原版一致:np.random.seed / ea.optimize(seed=…) 可完整复现一次运行 - API 兼容度:原版 基准;geatpy-rs 沿用原有 Python 接口、数据结构与 42 个算法模板;内核行为与官方 2.7.0 二进制逐项差分验证 ### 与官方 2.7.0 内核的一致性 - 确定性算子逐值比对:非支配排序、拥挤距离、编码解码、适应度分配、参考点、性能指标、NSGA-III / RVEA 环境选择等,以官方 2.7.0 二进制的实际输出为基准逐值比对。 - 随机算子比对统计分布:交叉、变异、选择等随机算子重复调用数百到数千次,逐元素比对均值分布,确认与官方实现同分布。 - 算法模板与经典用例比较解质量:39 个算法模板在相同问题上比对最终解质量;另有 Ackley、Rastrigin、att48 TSP、ZDT、DTLZ 等 36 个经典用例,覆盖最大化、混合整数、带约束、排列编码、多种群与多染色体模板,两边各运行 30 次比较最优值或 IGD / HV 的分布。除修正了原版迁移缺陷的多种群模板明显更好外,均无显著差异。 - 约 1500 个随机差分用例:随机形状、参数组合与边界值同时在官方二进制与 Rust 内核上运行,逐项比对数值、dtype、返回结构与报错;全整数变量时同样返回 int32,参数校验与报错信息与官方一致。 - 边界输入逐一复核:空种群、空参考点、反向或三维数组、超大尺寸、NaN、错误的参数类型与关键字等合法输入之外的情形,逐一对照官方二进制,报错类型与信息与原版一致;原版在其中一些情形下崩溃或越界读取,geatpy-rs 改为抛出 Python 异常。 - 官方二进制的已知缺陷(geatpy-rs 按文档修正):ndsortDED 分层错误;mergecv 跨行累加;tcheby / pbi 在 idealPoint=None 时返回理想点;refselect 候选矩阵行序错位;migrate 择劣替换实际淘汰的是最优个体;migrate 随机替换总是淘汰最后一个个体,完全网状结构会从自身迁入;mutgau / mutuni 的 Middle=True 以 (ub-lb)/2 而非区间中点为中心;crtip 在边界为小数时生成越界整数;pbi 对恰在理想点上的个体返回 NaN;cdist 对非连续数组读错数据;refselect 在极点矩阵奇异(如重复极点)时因舍入解出无意义的截距;crtri 与 crtip 一样在边界为小数时生成越界整数;mutde 把 F 列表中的 None 当作另一个因子(文档写明 None 表示随机生成),Mask_N 为 N 行矩阵时不排除个体自身;refgselect 不检查 CV 行数且会就地修改传入的 CV;refselect / refgselect 在参考点集为空时仍给出选择;mselecting 只给一个都没选中的种群补选,做不到文档保证的每个种群最少选择数;带全局存档的模板(NSGA2_archive、awGA、MOEAD_archive)返回重复解;染色体长度为 1 或一维输入时 xovsp / xovsh 等段错误;空种群上抽取 mutde 供体时崩溃,refgselect 的 Gamma 过短、GD / IGD / HV 输入为空时读取越界内存;空种群上 rws / sus 返回未初始化的下标,tour / dup 崩溃;migrate 用到适应度时,FitnVs 的个数或行数不足会越界读取;非线性 ranking 在个体数或 SP 较大时溢出为 NaN;recint / reclin 的 Alpha 为整数、float32 或 bool 数组时按 float64 读取内存;种群切片 pop[:]、pop[:-1] 报错或个体数算错,PsyPopulation 重复初始化时累加 Linds、派生种群共用译码矩阵 ### 常见问题 **什么是 geatpy-rs?与原版 Geatpy 有什么区别?** geatpy-rs 是经典进化算法工具箱 Geatpy 的 Rust 内核重构版。原版 Geatpy 的内核是只以二进制分发的 C/C++ 动态库,预编译轮子止于 Python 3.10,也没有 Linux ARM64 版本。geatpy-rs 用 Rust(PyO3 + abi3)重写了全部 74 个内核算子,提供 Python 3.8 ~ 3.15 通用的预编译 Wheel,沿用原版的 Python 接口与算法模板,业务代码无需改动即可替换。 **Geatpy 有 Rust 版吗?能在 Rust 程序里直接调用吗?** geatpy-rs 就是 Geatpy 的 Rust 版:原版内核的全部 74 个算子用 Rust 重写(源码在 crates/geatpy_core,基于 PyO3 与 rust-numpy),以 Python 扩展的形式发布,面向 Python 用户,pip install geatpy-rs 后照常 import geatpy as ea。这个 Rust 内核目前没有发布到 crates.io,算子的参数和返回值都是 Python / numpy 对象,Rust 程序不能把它当作普通的 Rust 库直接依赖;需要在 Rust 中实现同样的算法时,可以参考仓库中的源码。 **为什么在 Python 3.11 及以上版本中 pip install geatpy 会报错?如何解决?** 原版 Geatpy 在 PyPI 上只提供 Python 3.5 ~ 3.10 的预编译包。在 Python 3.11、3.12、3.13、3.14 或 3.15 中执行 pip install geatpy 时,pip 找不到匹配的轮子,只能尝试从源码构建,而原版内核并不随源码公开,因此安装失败。解决方法是改装 geatpy-rs:运行 pip install geatpy-rs,即可使用预编译的 abi3 轮子,无需本地安装任何编译器。 **geatpy-rs 支持 Apple Silicon (M1 ~ M4) 和 Linux ARM64 吗?** 都支持。macOS 提供 Universal2 轮子,同时包含 Apple Silicon 与 Intel 架构,无需 Rosetta 2;Linux 提供 x86_64 与 ARM64 (aarch64) 两种 manylinux2014 轮子,可直接用于 ARM 云服务器与 Docker 容器;Windows 提供 x64 轮子。 **原有基于 Geatpy 编写的优化代码需要修改吗?** 不需要。geatpy-rs 沿用原版 Geatpy 的 Python 接口,包括问题定义类 ea.Problem、种群 ea.Population、ea.optimize,以及 moea_NSGA3_templet、moea_NSGA2_templet、soea_SEGA_templet 等算法模板和 ndsortESS、crowdis、mutbga、xovdp 等内核算子。安装 geatpy-rs 后仍然 import geatpy as ea,上层代码无需重构。 **geatpy-rs 的计算结果与原版一致吗?** 一致性经过系统验证。确定性算子以官方 2.7.0 二进制的实际输出为基准逐值比对,随机算子比对统计分布,39 个算法模板比对最终解质量,另有约 1500 个随机差分用例同时在两边运行,逐项比对数值、dtype、返回结构与报错;36 个经典用例两边各运行 30 次,解的质量无显著差异。官方二进制中有多处与其自身文档不符的缺陷(如 ndsortDED 分层错误、mergecv 跨行累加、多种群迁移淘汰最优个体、边界输入段错误),geatpy-rs 按文档实现,并在测试中单独说明;其中多种群模板因此得到明显更好的解。 **geatpy-rs 包含哪些进化算法与算子?** 42 个单目标与多目标算法模板:NSGA-III、NSGA-II、RVEA、MOEA/D、awGA 等多目标算法,以及 SEGA、SGA、EGA、差分进化 DE、进化策略 ES 等单目标算法。Rust 内核包含 74 个算子:种群初始化与编码转换,锦标赛、轮盘赌等选择,单点 / 两点 / 均匀 / PMX / SBX 等交叉,多项式、高斯、差分进化等变异,ndsortESS 非支配排序、crowdis 拥挤距离、refselect 参考点选择,以及 GD、IGD、Spacing、HV 性能指标。 **geatpy-rs 支持多核并行吗?** 稳定版 2.7.6 的 Rust 内核是单线程实现,原版算子中的 Parallel 参数为兼容而保留,传入不会报错,但暂不生效;即便如此,在 36 个经典用例上的运行耗时为原版的 0.05 ~ 0.73 倍。在 free-threaded(无 GIL)的 Python 3.14t 上,内核不需要 GIL,可以用线程同时运行多个模板(8 线程跑 8 次 DE 快 4.4 倍)。多线程预览版 2.8.0b2 可用 pip install --pre geatpy-rs 安装:非支配排序、参考点选择、距离与 GD / IGD / Spacing 指标在规模较大时自动多线程,结果与单线程逐位一致,线程数用 ea.set_num_threads() 或环境变量 GEATPY_NUM_THREADS 设置;常见的千人以下种群收益有限。同时运行多个进程时建议每个进程设 1 个线程。目标函数的计算仍需在问题类中自行向量化或多进程。 **为什么 soea_DE_currentToRand_1_templet 比原版收敛慢?** 该模板传入 F=[0.5, None]。文档写明 None 表示 F2 在变异过程中随机生成,原版二进制实际却把 F2 固定为 0.5;geatpy-rs 按文档随机生成,因此在 Rastrigin 等问题上收敛比 2.7.0 慢(30 维、50×1000 时中位最优值约 93 → 156)。需要原版行为时,可在运行前设置 algorithm.mutOper.F = [0.5, 0.5]。 **提示 Could not find any feasible solution,明明有可行解怎么办?** 约束写在 evalVars 返回的 CV 矩阵里,每一列一个约束,CV <= 0 才算满足。常见错误是符号写反(x1 + x2 >= 1 应写成 1 - x1 - x2),或等式约束没有容差(应写成 |h(x)| - 1e-6);“或”关系的两个约束取两者较小值。geatpy-rs 在求解失败时会打印最后一代每个约束的违反个数和最小值,便于定位。更多写法见 README 的常见问题。 **大规模、有约束的多目标问题会不会很慢?** 原版在有约束时,不可行个体按违反程度排成一条长链,非支配排序退化为平方级,5 万个体排一次要几十分钟(上游 issue #319)。geatpy-rs 2.7.5 起每层只与最近的前沿成员比较,1 万个体、3 目标、1 个约束从原版的 6.4 秒降到 0.05 秒,分层结果与原版逐位一致。长时间运行可传 progress=True 显示进度条。 **geatpy-rs 支持 free-threaded(无 GIL)的 Python 3.14t 吗?** 支持。2.7.6 起为 Python 3.14t 提供 cp314t 轮子(Linux x86_64 / ARM64、macOS Universal2、Windows x64),在 3.14t 上同样执行 pip install geatpy-rs 即可,导入后 GIL 保持关闭。多个线程可以同时运行各自的算法模板,或在 evalVars 里用线程池分块计算目标函数:8 个线程同时跑 8 次 DE 模板快 4.4 倍,目标函数用纯 Python 写时快 3.8 倍;单次运行分块计算纯 Python 目标函数(400 个体 × 1000 变量)整体快 1.9 倍。注意各线程共用 numpy 的全局随机状态,多线程同时运行时 seed 不能保证可复现;目标函数里对单个数逐个调用 numpy 函数(如 np.cos)会让线程相互争用而变慢,应改用 math 模块或对整个数组调用 numpy。 **决策变量很多(十万量级)时还能用吗?** 能用,速度和内存都不是瓶颈。10 万个变量、50 个体时,DE、SEGA、EGA 每代只需 23 ~ 30 毫秒,是官方 2.7.0 的 0.33 ~ 0.39 倍;二进制编码的 0-1 背包每代 25 毫秒(原版 95 毫秒),50 万变量时 125 毫秒(原版 442 毫秒),峰值内存也比原版少 10% ~ 40%。不过进化算法在这种规模上本身难以收敛(上游 issue #281、#295),需要结合问题结构(变量分组、降维、专用算子)或改用传统优化方法。测试脚本见仓库的 scripts/parity/large_scale.py。 **geatpy-rs 的运行结果可以复现吗?** 可以。与原版一样,内核的随机数取自 numpy 的全局随机状态:调用 np.random.seed,或给 ea.optimize 传入 seed 参数,同样的代码会得到完全相同的结果。 ### English summary geatpy-rs is a Rust rebuild of the core of Geatpy, the Python toolbox for evolutionary and genetic algorithms. pip install geatpy-rs installs prebuilt wheels for Python 3.8 ~ 3.15 (plus free-threaded Python 3.14t) on Linux x86_64 / ARM64, macOS (Apple Silicon and Intel) and Windows x64, and existing code keeps working unchanged with import geatpy as ea. All 74 core operators are rewritten in safe Rust (PyO3 + abi3) and checked against the official geatpy 2.7.0 binaries. - Project page (Chinese): https://jiaying.design/geatpy-rs - English README: https://github.com/yangyachao/geatpy-rs/blob/master/README.en.md - Install: `pip install geatpy-rs` - Current version: 2.7.6 (updated 2026-10-28) - Why it exists: the original Geatpy ships its closed-source C/C++ core only as wheels up to Python 3.10 and has no Linux ARM64 wheels, so pip install geatpy fails on Python 3.11 and later and on ARM servers. - Compatibility: the same Python API, data structures and 42 algorithm templates (NSGA-III, NSGA-II, MOEA/D, RVEA, SEGA, differential evolution, evolution strategies and more). - Parity with geatpy 2.7.0: deterministic operators are compared value by value, random operators by their distributions, about 1500 randomised differential cases check values, dtypes, return structures and errors, and 36 classic benchmark problems run 30 times on each side show no significant difference in solution quality except where a documented upstream bug was fixed. - Speed: 0.05 – 0.73 times the original runtime on the 36 classic cases; with 100 000 decision variables a generation takes 0.27 – 0.46 times the original time with less peak memory. - Safety: edge-case input that crashes the original core (length-1 chromosomes, one-dimensional input, empty populations) raises Python exceptions instead. - Free-threaded Python 3.14t: the core does not need the GIL, so threads can run templates side by side; 8 independent differential-evolution runs in 8 threads are 4.4 times faster. - Multithreading preview: 2.8.0b2 (pip install --pre geatpy-rs) runs non-dominated sorting, reference-point selection, distances and the GD / IGD / Spacing indicators on several threads for large inputs, bit-identical to one thread. - Reproducibility: random numbers come from numpy's global random state, so np.random.seed or ea.optimize(seed=...) reproduces a run exactly, as in the original. - Rust usage: the Rust core is not published on crates.io; its operators take and return Python / numpy objects, so it is used from Python rather than as a Rust library. **Why does pip install geatpy fail on Python 3.11 or later, and how do I fix it?** The original Geatpy only publishes wheels for Python 3.5 – 3.10 and its core is not released as source, so pip cannot build it on newer Python versions. Install geatpy-rs instead (pip install geatpy-rs) and keep import geatpy as ea. **Is there a Rust version of Geatpy?** Yes: geatpy-rs replaces Geatpy's binary core with Rust (PyO3 + rust-numpy) while keeping the Python interface. It is a Python package; the Rust core is not a standalone Rust library. **Do I need to change code written for Geatpy?** No. ea.Problem, ea.Population, ea.optimize, the algorithm templates and the core operators keep their names and behaviour; only the package to install changes. **Does geatpy-rs support Apple Silicon (M1 – M4) and Linux ARM64?** Yes. macOS provides Universal2 wheels supporting both Apple Silicon and Intel without Rosetta 2. Linux provides x86_64 and ARM64 (aarch64) manylinux2014 wheels for ARM cloud servers and Docker. Windows provides x64 wheels. **Does geatpy-rs support free-threaded (no-GIL) Python 3.14t?** Yes. Prebuilt cp314t wheels are provided for Linux, macOS and Windows, and the core does not need the GIL, so several threads can run independent algorithm templates at once: 8 threads running 8 DE runs are 4.4 times faster. **Can geatpy-rs handle large-scale decision variables (100k+)?** Speed and memory are not the bottleneck: with 100,000 decision variables and 50 individuals, DE, SEGA and EGA take 23 – 30 ms per generation (0.33 – 0.39 times the official 2.7.0 runtime) with 10 % – 40 % less peak memory. Evolutionary algorithms themselves hardly converge at this scale, so exploit the structure of the problem or use a classical optimisation method. ## 其他作品 - [Starnivo 星序](https://jiaying.design/starnivo)(macOS / iPhone / iPad 应用):星序是 Mac、iPhone 和 iPad 上的原生 GitHub Stars 管理器。按语言和标签找回收藏,在应用内阅读 README,并离线查看已缓存的仓库资料。 - [织景 PanoWeave](https://jiaying.design/pano-weave)(macOS / iPad 应用):macOS 与 iPad 上的全景照片编辑器与 VR 漫游制作工具。选取三脚架所在的极点区域一键修补,添加导航与信息热点,用拓扑视图串联多个空间,导出可离线打开的 Web VR 漫游项目。 - [帧知 FrameSense](https://jiaying.design/framesense)(macOS / iOS 应用):把网课、讲座、会议录像里的关键画面自动截成知识卡片:检测画面变化、过滤重复帧,端侧 OCR 识别文字,一键导出为 Markdown、A4 PDF、16:9 幻灯片、Word 或 HTML 网页。 - [无界截图](https://jiaying.design/scrollshot)(iPhone / iPad 应用):录屏自动转长图:导入一段滚动屏幕的录屏,或几张有重叠的截图,自动对齐拼接成高清长图,重复的顶栏与底栏自动去除。全部在设备本地离线完成。 - [智考通](https://jiaying.design/ai/)(Web · AI 学习平台):智能刷题与复习平台。覆盖计算机、数据结构、机器学习、人工智能等学科题库,提供单选、多选、判断与模拟考试等题型练习,自动归纳错题,助力专业知识高效备考。 - [Semester 2](https://jiaying.design/semester2/)(Web · 英语学习):大学英语 (General English II) 交互式学习与复习平台。围绕沟通交流、批判性思维等六大主题单元,提供高频词汇背诵、课文精读与期末模拟考刷题中心。 - [诗词雅集 Chinese Poetry](https://jiaying.design/poetry/)(Web · 沉浸式古典诗词研学):沉浸式中华古典诗词研学与书画鉴赏平台。全馆收录《唐诗三百首》与《宋词三百首》共 646 首传世名篇,配备一对一专属 16:9 传统水墨画卷、逐字平仄声律谱与雅音吟诵,融合宋代古籍装裱美学与中华诗脉时空图谱。 - [梁思礼的故事](https://jiaying.design/liang-sili)(亲子互动绘本):为亲子共读定制的交互式科普绘本,讲述中国第一代航天人梁思礼院士从少年求学到毅然归国、奉献两弹一星的历程。支持妈妈 / 孩子 / 合读多角色朗读、语音合成、自动播放与手势翻页。 ## Other work (English) - Homepage: https://jiaying.design/en - [Starnivo](https://jiaying.design/en/starnivo) (macOS / iPhone / iPad App): Starnivo is a native GitHub Stars manager for Mac, iPhone, and iPad. Find saved repositories by language or tag, read their READMEs in the app, and revisit cached repository details offline. - [PanoWeave](https://jiaying.design/en/pano-weave) (macOS / iPad App): Panorama photo editor and VR tour builder for macOS and iPad. Select and patch the tripod area at the nadir, add interactive navigation and information hotspots, connect multiple rooms with topological views, and export offline Web VR tours. - [FrameSense](https://jiaying.design/en/framesense) (macOS / iOS App): Automatically captures key slides and screens from lectures, webinars, and meeting recordings into knowledge cards: detects screen transitions, filters duplicates, recognizes text via on-device OCR, and exports to Markdown, PDF (document or 16:9 slide layout), Word, or HTML. - [ScrollShot](https://jiaying.design/en/scrollshot) (iPhone / iPad App): Convert screen recording to seamless long screenshots: import a scrolling video or overlapping screenshots to automatically align and stitch them into high-res continuous images with duplicate bars removed. 100% on-device and offline. - [Zhikaotong](https://jiaying.design/ai/) (Web · AI Learning Platform): Intelligent exam review and practice platform covering Computer Science, Data Structures, Machine Learning, and Artificial Intelligence with smart error tracking. - [Semester 2](https://jiaying.design/semester2/) (Web · English Learning): Interactive learning and review platform for General English II, featuring vocabulary drills, text analysis, and interactive mock examination centers across six themes. - [Chinese Poetry](https://jiaying.design/poetry/) (Web · Classical Poetry & AI): Immersive classical Chinese poetry study and art appreciation platform. Featuring 646 masterworks across 300 Tang Poems and 300 Song Lyrics, paired with 16:9 traditional ink-wash paintings, tonal meter guides, speech recitation, and an interactive cultural atlas. - [The Story of Liang Sili](https://jiaying.design/liang-sili) (Interactive Storybook): An interactive science picture book recounting Academician Liang Sili’s journey from overseas education to pioneering China’s space and missile programs, featuring parent-child read-aloud and gesture turns. ## 联系 - 开发者 / 作者: 杨亚超 (Yang Yachao / yangyachao) - 邮箱: yangyachao@outlook.com - GitHub: https://github.com/yangyachao