Algorithm Design

作者 lingzhi2279e6c085d65e3无许可证386 个星标收录于 2026年10月8日更新于 2026年10月8日仓库7个月前更新

Design algorithms with LaTeX pseudocode and UML diagrams. Generate algorithmic environments, Mermaid class/sequence diagrams, and ensure consistency between pseudocode and implementation. Use when formalizing methods for a paper.

AI 生成的概览

将方法形式化为 LaTeX 算法伪代码和 Mermaid UML 图,并检查与代码的一致性。

功能
把方法描述或实现转化为正式的算法伪代码,使用 LaTeX 的 algorithm 与 algpseudocode 环境,包含输入、输出、参数和编号步骤。它还会生成用于系统架构的 Mermaid 类图和时序图。最后,它会核对伪代码步骤、UML 类以及参数名是否与实现一致。
适用场景
适用于为论文或技术文档形式化方法、且需要标准算法记号的场景。也适合需要让伪代码与架构图同现有代码保持一致的工作。
运行要求
伪代码输出需要带 algorithm 与 algpseudocode 宏包的 LaTeX,图示需要 Mermaid 支持。它会读取随附的算法与图示模板参考文件。不附带脚本,仅为说明性内容。

Algorithm Design

Formalize methods into algorithm pseudocode and system architecture diagrams.

Input

  • $0 — Method description or implementation to formalize

References

  • Algorithm and diagram templates: ~/.claude/skills/algorithm-design/references/algorithm-templates.md

Workflow

Step 1: Formalize the Algorithm

  1. Define clear inputs and outputs
  2. Identify the main loop / recursive structure
  3. Specify all parameters and their types
  4. Write step-by-step pseudocode

Step 2: Generate LaTeX Pseudocode

Use algorithm + algpseudocode environments:

latex
\begin{algorithm}[t]\caption{Method Name}\label{alg:method}\begin{algorithmic}[1]\Require Input $x$, parameters $\theta$\Ensure Output $y$\State Initialize ...\For{$t = 1$ to $T$}    \State $z_t \gets f(x_t; \theta)$    \If{convergence criterion met}        \State \textbf{break}    \EndIf\EndFor\State \Return $y$\end{algorithmic}\end{algorithm}

Step 3: Generate UML Diagrams (Mermaid)

Class Diagram
mermaid
classDiagram    class Model {        +forward(x: Tensor) Tensor        +train_step(batch) float    }
Sequence Diagram
mermaid
sequenceDiagram    participant M as Main    participant D as DataLoader    M->>D: load_data()    D-->>M: batches

Step 4: Verify Consistency

  • Every pseudocode step must map to a code module
  • Every class in the UML must exist in the implementation
  • Parameter names must match between pseudocode and code

Rules

  • Use standard algorithmic notation (not code syntax)
  • Number lines for easy reference
  • Include complexity analysis as a comment or proposition
  • Use \Require / \Ensure for inputs/outputs
  • Keep pseudocode at the right abstraction level — not too detailed, not too vague

Related Skills

  • Upstream: atomic-decomposition, math-reasoning
  • Downstream: experiment-code, paper-writing-section
  • See also: symbolic-equation

来源与署名

来源:lingzhi227/agent-research-skills位于skills/algorithm-design提交9e6c085

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架