Algorithm Design

lingzhi227/agent-research-skills/skills/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 從公開儲存庫中收錄這些內容。

檢舉或申請下架