Recent advances in Large Language Models (LLMs) have shown impressive abilities in mathematical reasoning and code generation. However, LLMs still face significant challenges in the simulation domain—particularly when generating Simulink models, which are critical in engineering and scientific research. Our preliminary experiments indicate that LLM agents alone often struggle to produce reliable and complete Simulink simulation code from textual inputs, likely due to the scarcity of Simulink-specific data in their pre-training corpora.
SimuGen bridges this gap with a multi-modal agentic framework that automatically generates accurate Simulink simulation code by leveraging both visual Simulink diagrams and domain knowledge. SimuGen coordinates multiple specialized agents—including an Investigator, Unit Test Reviewer, Block Builder, Executor, Debug Locator, and Report Writer—supported by a domain-specific block database. This collaborative, modular architecture enables robust, interpretable, and extensible Simulink simulation generation.
The SimuGen pipeline includes the following agents:
- Investigator: Uses multimodal LLMs to extract block and connection relationships from Simulink diagram images.
- Unit Test Reviewer: Validates whether all blocks and connections conform to Simulink standards.
- Block Builder: Converts block and connection descriptions into executable Python code with
matlab.engine. - Executor: Runs the generated code and reports execution results.
- Debug Locator: Diagnoses errors and provides targeted feedback for code or connection revision.
- Report Writer: Compiles a comprehensive simulation report, including theoretical context and implementation details.
- Block Database: Supplies agents with structured, domain-specific knowledge for accurate code synthesis.
SimuGen allows users to flexibly choose the LLM backend and simulation configuration via the autosim_config.yaml file. This configuration file enables you to:
- Specify the preferred LLM model or agent configuration.
- Adjust other system parameters as needed.
To quickly set up the required environment, use the provided environment.yml file with Conda.
This will ensure all dependencies are installed for SimuGen.
conda env create -f environment.yml -n simugen-f environment.ymlspecifies the environment file.-n simugensets the new environment’s name to simugen. (This name will be used regardless of thename:field inenvironment.yml.)
Activate the environment:
conda activate simugenNow you are ready to run SimuGen! If you encounter any dependency installation issues, please copy the error and ask for help.
To generate a Simulink simulation example, simply run:
python run.py --example_name <example_name>where <example_name> can be one of the following:
artificial_algebraic_loopsBipolarTransistorbouncing_ballRCCircuitsimulink_modelstate_eventtwo_buswheel_speedzero_crossing_detection
Example:
python run.py --example_name bouncing_ballYou can configure the model and other parameters in autosim_config.yaml before running.
- Ensure you have correctly set up your Python and MATLAB environments (including
matlab.engine). - For best results, avoid adding
.ipynb_checkpoints,.env, or any sensitive files to version control.
