Preface¶
The common pain point in mathematical modeling competitions (CUMCM / MCM / National Competition, etc.) is that problems, data, code, charts, and papers are scattered across multiple tools, and the agent starts from scratch every time. What has been done is breaking modeling into a long prompt and having the LLM write it all at once, but the results are not reproducible and intermediate artifacts lack acceptance checks. dsh-mathmodeling-workflow is a workflow plugin on DSH, maintained by xzwwwwww. It solidifies the entire pipeline into a deterministic 8-step workflow: problem analysis, modeling and solving, programming implementation, data charts, flowcharts, logic counter-check, paper writing, and PDF compilation. Below is an introduction to what this plugin is, how to install it, and how to use it.
What is it¶
One sentence: Treat a problem folder as input, the plugin runs 8 steps sequentially through numbered agents, and finally produces a LaTeX paper PDF, along with all source code, charts, and intermediate artifacts. It is not another model, nor a generic agent framework, but a bundle attached to the DSH plugin mechanism.
Repo address: https://github.com/xzwwwwww/dsh-mathmodeling-workflow
Directory page: https://www.skillhub.cn/plugins/xzwwwwww/dsh-mathmodeling-workflow
Category is “Workflow”, GitHub stars 1, License MIT, npm version 0.3.11.
The specific problem it solves is that modeling results only appear “after a round is run,” while existing approaches lack step-by-step acceptance nodes. This plugin has a deterministic gate check at the end of every step. If it fails, it re-queues with a fix hint, retrying up to 2 times. The main session only handles scheduling and acceptance.
Core Features¶
1. 8-Step Workflow¶
| # | Step | What it does |
|---|---|---|
| 01 | Problem Analysis | Break down sub-problems, define variables, plan modeling approach and chart list |
| 02 | Modeling & Solving | Assumptions, model building, solving, verification, logic contract |
| 03 | Programming Implementation | Write runnable code, run results, generate results JSON |
| 04 | Chart Generation | Data charts (matplotlib, verified against manifest) |
| 05 | Flowchart/Architecture Diagram | DrawIO or HTML engine to draw flow, architecture, TikZ diagrams |
| 06 | Logic Counter-Check | Review 6 types of logical gaps (reversed direction, cross-question contradictions, misread tasks…) |
| 07 | Paper Writing | LaTeX body, abstract, chart embedding, citations; strict mode does data authenticity verification |
| 08 | Compilation & Compliance Check | XeLaTeX compilation, template integrity, image embedding, AI disclosure compliance |
Steps can be disabled: flowchart_engine=html replaces step 05 with HTML engine; skip_figures removes 04 and 05; enable_comp_review=false removes 06; fast mode skips deep review and data verification of 06.
2. Gate Validation¶
Each step ends with a deterministic gate validation. Checkpoints include whether artifacts exist, whether charts are reconciled, whether page count meets standards, whether a logic contract is established, whether AI disclosure is compliant, and whether data has been verified. If it fails, it re-queues with a fix hint, retrying up to 2 times.
3. Competition Adaptation¶
The competition switch supports 11 types of competitions (cumcm, wuyi, huazhong, apmcm_zh, diangong, mathorcup, zhongqing, yangtze, liaoning, huashu, huawei, generic). Each competition corresponds to different rules, default page counts, and LaTeX templates. Most competitions default to 30 pages, apmcm_zh is 25 pages.
Installation and Enablement¶
Prerequisites: DSH (Desktop or Web version). Installing via npx requires Node.js + pnpm; if only pure Node environment, run npm i -g pnpm first. DSH desktop version comes with pnpm.
Other dependencies are installed as needed; missing one only affects that specific step:
- Python 3.10+ (can
import matplotlib): Data charts, result verification - XeLaTeX (TeX Live / MiKTeX): Compiling paper PDF
- Chromium kernel browser (Edge / Chrome): Only needed when
flowchart_engine=html - Chinese fonts: Compiling Chinese templates (initialization will attempt to fill back from system fonts)
Compatibility: README notes tested successfully on DSH 0.2.2-rc.1 (tool registration, system prompt injection, 8-step pipeline, question forwarding, switch rewriting, gate validation all normal). After upgrading DSH, if the plugin management shows it’s not enabled, re-enable it once, as upgrades may reset bundle selection in the profile.
Method 1: npx one command (Recommended)¶
npx -y @deepseek-ai/dsh plugin --profile desktop add github:xzwwwwww/dsh-mathmodeling-workflow
This command pulls the repo, installs it into the desktop profile, and auto-registers it into the bundle list. For Web version, replace desktop with web.
Method 2: Install from Local Directory¶
First clone the repo:
git clone https://github.com/xzwwwwww/dsh-mathmodeling-workflow.git
Then choose one in DSH. On desktop, go to Plugin Management → Install Bundle, target the cloned directory. On Agent side, call directly:
plugin_manager({ action: "install_bundle", target: "<absolute path of cloned directory>" })
Updates: For Method 1, re-run the npx command; for Method 2, git pull then close and re-enable the plugin (or restart DSH). Uninstall: Remove in Plugin Management, or plugin_manager({ action: "remove_bundle", target: "@local/dsh-mathmodeling-workflow" }).
Typical Usage¶
1. Put the problem and data into one folder¶
2026国赛A/
├─ 赛题A.docx # Original problem: PDF / DOCX / MD all work
├─ 数据.csv # Data attachments: csv / xlsx / json
└─ 自定义要求.md # Optional: supervisor standards, review preferences, required content
2. Say one sentence in DSH¶
Simplest call, all switches use defaults:
用建模插件跑这个赛题:D:\2026国赛A
Call with requirements, only write what you care about:
用建模插件跑:D:\2026国赛A,国赛 A 题,正文 25 页,
数据图用 nature 风格,流程图用 HTML 引擎,严格审查
The agent will echo the final switches, then generate the workspace. The directory name looks like modeling-2026国赛A-<timestamp>/.
3. A Complete Example¶
用建模插件跑:D:\2026国赛A,国赛 A 题,正文 25 页,
数据图用 nature 风格,流程图用 HTML 引擎(modern 版式),
AI 声明按"使用过 AI 工具"写,开启逻辑对抗复核,
自定义要求:摘要不超过一页,必须包含灵敏度分析。
The agent will echo a switch summary, for example:
赛项:国赛 (CUMCM)(cumcm) | 题号=A | 页数(正文)=25 | 数据图风格=nature
流程图=html/modern | 丰满模式=关 | 审查=strict | AI声明=used | 对抗复核=开
→ 8 步,工作区 modeling-2026国赛A-20261104-2030/
4. Workflow after it runs¶
- Each step uses a sub-agent, executes sequentially, and only proceeds to the next step if the previous step’s gate passes. The main session only handles scheduling and validation.
- If a sub-agent is unsure of key information (problem ID, data selection, hard requirements), it will ask first before continuing; if it can proceed with reasonable assumptions, it will document the assumptions in the artifact.
- You can check progress anytime:
看下当前进度, which will list the status of the 8 steps, artifact sizes, and pending questions. - The workspace root directory contains
PROBLEM_ANALYSIS.md,MODELING_REPORT.md,RESULTS.md,code/,figures/,paper/main.pdf.
Switches Overview (20)¶
Initialization parameters: only 3 are not switches: input_dir (required, problem directory), workspace_name (workspace directory name, defaults to directory name + timestamp), overwrite (whether to rebuild if workspace already exists).
Main switches:
| Switch | Values | Default | Purpose |
|---|---|---|---|
competition |
11 types | cumcm |
Determines competition rules, default pages, LaTeX template |
problem_id |
A/B/C… | Empty | Problem ID, written into parameters and rules section |
title |
Any string | Empty (takes dir name) | Paper title / problem short name |
max_pages |
Positive integer | Competition default | Target body page count (lower limit), excludes abstract/table of contents/references/appendix/AI disclosure |
figure_style |
default / nature |
default |
Data chart style |
flowchart_engine |
drawio / html |
drawio |
Flowchart engine; drawio artifacts are draggable and editable |
diagram_style |
mono / plain / modern |
mono |
Flowchart style, only effective for html engine |
rich_mode |
true / false | false |
Rich mode: body 40-60 pages, 30+ figures, abstract 1500-2200 words |
validation_mode |
strict / fast |
strict |
strict includes data authenticity verification in paper; fast skips verification and deep self-repair |
enable_comp_review |
true / false | true |
Whether to insert the logic counter-check step |
ai_disclosure |
off / none / used |
off |
AI Disclosure: off writes nothing and forbids residuals; none writes a sentence |
skip_figures |
true / false | false |
Skip the two chart steps |
skip_drawio |
true / false | false |
Only skip the flowchart step |
flow_per_problem |
true / false | false |
Per-question flowcharts |
min_figures / min_tables / min_models |
Integer or auto |
auto |
Quantity lower limit reference, written into CLAUDE.md for skill self-check |
custom_requirements |
Free text | Empty | Custom requirements, highest priority, will be written into CLAUDE.md |
Optional: Generate Concept Diagrams / Mechanism Diagrams / Per-Question Framework Diagrams¶
Data charts and flowcharts are fully local (matplotlib / local browser rendering), no keys needed. Only “Concept Diagrams / Scenario Diagrams” require an image model. The workspace already comes with a config file:
<workspace>/_utils/_gpt_image_config.json
{
"api_key": "",
"base_url": ""
}
api_key is obtained from a relay station or official source; base_url fill in the relay station’s interface address, leave empty to use official https://api.openai.com/v1. You can also not change the file and directly set environment variables GPT_IMAGE_API_KEY / GPT_IMAGE_BASE_URL, which have higher priority. To check if configured: python _utils/gpt_image.py --check. It can run without configuration; concept diagrams in the plan will be automatically skipped, not affecting other steps.
Scenario diagrams and mechanism diagrams are injected with fixed styles (MCM Academic Illustration / Scientific Mechanism Diagram), you just need to write the content theme. Per-question framework diagrams (--style framework) are disabled by default, only enabled when flow_per_problem: true and custom_requirements explicitly states to use image.
Applicable Scenarios and Notes¶
Who is it for: Users doing mathematical modeling competitions in DSH who need a reproducible pipeline from problem to paper; scenarios where you want an agent to output structured LaTeX papers while requiring intermediate artifacts to be verifiable.
Notes:
- The plugin runs with current DSH process permissions. Check source code and license before installing third-party bundles. License is MIT.
- PDF compilation relies on XeLaTeX. Without TeX environment, step 08 will fail; Chinese templates also require Chinese fonts in the system.
- Step 04 for data charts requires Python 3.10+ and
import matplotlibto be available. flowchart_engine=htmlhas an extra dependency on a Chromium kernel browser.- Among the 20 switches,
max_pagesis the lower bound for the body text, not the upper bound for the full text, avoid understanding it as “not exceeding N pages”. custom_requirementshas the highest priority, written intoCLAUDE.md, and sub-agents will execute according to it.- If the bundle shows as not enabled after upgrading DSH, just re-enable it.
Conclusion¶
The value of this plugin lies in breaking a one-time long task in modeling competitions into 8 gated steps. Every step’s artifact is saved and verified before proceeding to the next, reducing rework costs. It still relies on local LaTeX, Python, browsers, etc., and is a workflow maintained by a community author, not an official DeepSeek application. You can view full documentation and try it out via the directory page or GitHub repository.
Directory page: https://www.skillhub.cn/plugins/xzwwwwww/dsh-mathmodeling-workflow
GitHub: https://github.com/xzwwwwww/dsh-mathmodeling-workflow