一键导入
matlab-model-code-generator
Generate executable MATLAB or Beita Tianyuan compatible modeling code from a validated method plan and cleaned data.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Generate executable MATLAB or Beita Tianyuan compatible modeling code from a validated method plan and cleaned data.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
At a judgment point, emit the 2-3 questions only the human modeler can answer — framed as trade-offs, not answers — and refuse to answer them. The inverse of "AI answers, human confirms": here the AI asks, the human answers, then the AI assists with the consequences.
Manage the full mathematical modeling contest workflow and decide which skill should be used next.
Verify every skill that claims "completed" produced a substantive audit/review artifact on disk with ≥ 5 explicit pass items. Runs as part of the independent audit layer that does not trust any single skill's self-declaration of done.
Plan figures and tables that support the modeling logic, results, and paper narrative.
Generate publication-quality mathematical modeling figures with matplotlib, covering evaluation charts, prediction plots, optimization diagrams, mechanism schematics, heatmaps, and multi-panel layouts. Use when creating or revising figures for contest papers.
Extract, organize, and document unified model assumptions from the problem parse and candidate method pools, distinguishing necessary from simplifying assumptions.
| name | matlab-model-code-generator |
| description | Generate executable MATLAB or Beita Tianyuan compatible modeling code from a validated method plan and cleaned data. |
| license | MIT |
Generate MATLAB / 北太天元 compatible modeling code from a validated candidate method pool and cleaned data.
This skill implements the approved candidate methods (baseline, main candidates, optional improved) as .m scripts. It should produce code that reads cleaned data, runs the planned models, saves results in the experiments/roundN/ output structure, generates a run_summary.json, and produces portable artifacts for downstream experiment reports, robustness checks, and paper writing.
This skill does not choose the model, clean raw data, review code, run final QA, or write paper sections.
Use this skill:
model-code-analyzer hands off to matlab-model-code-generator.implementation.target = matlab..m scripts are needed for one or more candidate methods in a specific experiment round.The following should already exist or be provided:
methods/Qx/qx_method_candidates.md.implementation.target = matlab.workspace/data/data_clean/, unless the model does not need tabular data.code/model-code-analyzer.md — the code thinking document specifying round number, methods to implement, and output structure.If the candidate method pool is missing, hand back to method-selector.
If code/model-code-analyzer.md is missing, hand back to model-code-analyzer.
If cleaned data is required but missing, hand back to data-auditor-cleaner.
If implementation.target is not matlab, hand back to model-code-analyzer.
Use or request:
methods/Qx/qx_method_candidates.md — candidate method pool for each subquestion.code/model-code-analyzer.md — code thinking document.workspace/data/data_report.md, if available.workspace/data/data_clean/.roundN).beita-tianyuan-compatibleavoid-heavy-toolboxesprefer-basic-matrix-and-table-operationsavoid-live-scriptsavoid-app-designersave-portable-artifactsRead the code thinking document and candidate method pool.
Confirm MATLAB target.
implementation.target = matlab.Check data readiness.
workspace/data/data_clean/.workspace/data/data_raw/ unless only inspecting metadata is explicitly requested.Plan script structure per subquestion.
code/matlab/Qx/ (e.g., code/matlab/Q1/).qx_m1_baseline.m, qx_m2_main.m, qx_m3_improved.m.README.md in each code folder: run order, inputs, outputs, dependencies.run_all.m only if batch execution is useful..m scripts over Live Scripts.Generate code for each candidate method.
workspace/data/data_clean/ using readtable, readmatrix, or load.results/Qx/experiments/roundN/tables/ using writetable, writematrix, or save.results/Qx/experiments/roundN/figures/ using saveas or print.results/Qx/experiments/roundN/metrics/.diary to write execution log to results/Qx/experiments/roundN/logs/.run_all.m or the last script, generate results/Qx/experiments/roundN/run_summary.json.Implement baseline code first.
m1_scores.csv).Implement main and optional methods.
Implement run_summary.json generation.
run_summary.json using MATLAB's jsonencode:
run_summary = struct();
run_summary.question = 'Q1';
run_summary.round = 'round1';
run_summary.execution_timestamp = datestr(now, 'yyyy-mm-ddTHH:MM:SS');
run_summary.implementation_target = 'matlab';
run_summary.random_seed = 2026;
run_summary.methods = struct(...
'method_id', 'M1', ...
'method_name', 'equal_weight_scoring', ...
'script', 'code/matlab/Q1/q1_m1_baseline.m', ...
'status', 'success');
% ... add more methods and details
f = fopen('results/Q1/experiments/round1/run_summary.json', 'w');
fprintf(f, '%s', jsonencode(run_summary));
fclose(f);
Add a README.md per code folder.
Hand off to code-reviewer.
.m scripts to matlab-code-reviewer.Produce MATLAB implementation artifacts such as:
code/matlab/Q1/README.mdcode/matlab/Q1/q1_m1_baseline.mcode/matlab/Q1/q1_m2_main.mcode/matlab/Q1/q1_m3_improved.m (if applicable)code/matlab/Q1/run_all.m (if useful)results/Q1/experiments/roundN/ (created by running the scripts):
tables/*.csvfigures/*.pngmetrics/*.jsonlogs/*.logrun_summary.jsonPrefer this JSON-compatible summary:
{
"matlab_code_generation_summary": {
"implementation_target": "matlab",
"subquestion": "Q1",
"round": "round1",
"runtime_notes": ["beita-tianyuan-compatible", "avoid-heavy-toolboxes"],
"generated_scripts": [
"code/matlab/Q1/q1_m1_baseline.m",
"code/matlab/Q1/q1_m2_main.m",
"code/matlab/Q1/run_all.m"
],
"data_inputs": [
"workspace/data/data_clean/indicator_data.csv"
],
"result_outputs": [
"results/Q1/experiments/round1/tables/m1_scores.csv",
"results/Q1/experiments/round1/tables/m2_scores.csv"
],
"figure_outputs": [
"results/Q1/experiments/round1/figures/m1_score_bar.png"
],
"run_instructions": [
"Run code/matlab/Q1/q1_m1_baseline.m",
"Run code/matlab/Q1/q1_m2_main.m"
],
"known_risks": [
"Compatibility with 北太天元 should be checked if toolbox-specific functions are introduced."
],
"recommended_next_skill": "code-reviewer"
}
}
Use conservative MATLAB-compatible code.
Prefer:
.m scriptsreadtable, writetablereadmatrix, writematrixsave, loadplot, bar, scatter, histogramrng(seed)fullfileresults/Qx/experiments/roundN/jsonencode for run_summary.json (or manual JSON string construction for older MATLAB)Avoid unless explicitly approved:
For 北太天元 compatibility:
.csv, .mat, .png).Use relative paths where practical.
Recommended paths:
workspace/data/data_clean/
code/matlab/Qx/
results/Qx/experiments/roundN/
├── tables/
├── figures/
├── metrics/
├── logs/
└── run_summary.json
Example path setup:
dataDir = fullfile('workspace', 'data_clean');
resultDir = fullfile('results', 'Q1', 'experiments', 'round1');
tableDir = fullfile(resultDir, 'tables');
figureDir = fullfile(resultDir, 'figures');
metricDir = fullfile(resultDir, 'metrics');
logDir = fullfile(resultDir, 'logs');
if ~exist(tableDir, 'dir'), mkdir(tableDir); end
if ~exist(figureDir, 'dir'), mkdir(figureDir); end
if ~exist(metricDir, 'dir'), mkdir(metricDir); end
if ~exist(logDir, 'dir'), mkdir(logDir); end
workspace/data/data_clean/.workspace/data/data_raw/.code/matlab/Qx/.results/Qx/experiments/roundN/tables/.results/Qx/experiments/roundN/figures/.results/Qx/experiments/roundN/metrics/.results/Qx/experiments/roundN/logs/.run_summary.json under results/Qx/experiments/roundN/..mat files when useful.If randomness is used:
rng(seed).run_summary.json.rng(2026);
Use comments to explain:
Avoid over-commenting trivial syntax.
run_summary.json.experiments/roundN/ directory structure.matlab-code-reviewer.Before handing off, verify:
implementation.target = matlab.code/matlab/Qx/.results/Qx/experiments/roundN/.run_summary.json generation is implemented.results/Qx/experiments/roundN/figures/.README.md exists in the code folder.code-reviewer.Stop and report a blocker if:
code/model-code-analyzer.md is missing.implementation.target is not matlab.This skill must stop instead of guessing when:
When stopping, output:
After generating MATLAB scripts, hand off to:
code-reviewer
The handoff should include:
.m script pathsREADME.md pathresults/Qx/experiments/roundN/code-reviewer should route the scripts to matlab-code-reviewer.
Do not hand off directly to robustness-checker or result-report-generator.
Input state:
implementation.target = matlab.beita-tianyuan-compatible.Output:
{
"matlab_code_generation_summary": {
"implementation_target": "matlab",
"subquestion": "Q1",
"round": "round1",
"generated_scripts": [
"code/matlab/Q1/q1_m1_baseline.m",
"code/matlab/Q1/q1_m2_entropy_topsis.m",
"code/matlab/Q1/run_all.m",
"code/matlab/Q1/README.md"
],
"data_inputs": [
"workspace/data/data_clean/indicator_data.csv"
],
"result_outputs": [
"results/Q1/experiments/round1/tables/m1_equal_weight_scores.csv",
"results/Q1/experiments/round1/tables/m2_entropy_topsis_scores.csv",
"results/Q1/experiments/round1/run_summary.json"
],
"figure_outputs": [
"results/Q1/experiments/round1/figures/m1_score_bar.png",
"results/Q1/experiments/round1/figures/m2_weight_bar.png"
],
"run_instructions": [
"Run code/matlab/Q1/q1_m1_baseline.m",
"Run code/matlab/Q1/q1_m2_entropy_topsis.m"
],
"known_risks": [
"Indicator direction must match the method plan before interpretation.",
"jsonencode requires MATLAB R2016b+; for older/北太天元, manual JSON string construction is used."
],
"recommended_next_skill": "code-reviewer"
}
}
{
"blocked_items": [
"The candidate method pool is missing at methods/Q1/q1_method_candidates.md."
],
"recommended_next_skill": "method-selector",
"recommended_next_action": "Generate the candidate method pool for Q1 before MATLAB code generation."
}
{
"blocked_items": [
"The selected implementation appears to require a toolbox-specific optimization function, which conflicts with the 北太天元 compatibility constraint."
],
"affected_model": "Q3 M2",
"recommended_next_skill": "method-selector",
"recommended_next_action": "Revise the candidate method pool to use a basic matrix-based or explicitly supported solver approach."
}