run_simulation
Run Monte Carlo risk simulations on an Excel workbook to generate outcome data, saving results to a .vmrs file for analysis.
Instructions
ModelRisk: Run a Monte Carlo simulation on the active (or named) workbook and save the results to a .vmrs file. Defaults to 1000 iterations with a fixed seed for reproducibility, and saves the .vmrs next to the workbook as <book>.vmrs. The simulation is run via the same XLL commands ModelRisk's own ribbon uses (VoseStartSimulCustom12 + VoseGetDataSZ12 with the SaveResultsToFile session), so behaviour matches what you'd see clicking 'Simulate' manually. ModelRisk simulates the active workbook, so a named workbook is made active first. The saved .vmrs is checked to hold this run (workbook, start time, iterations) before success is reported. Blocks until the simulation completes. After this returns, call get_simulation_results — the produced .vmrs is automatically pinned as the active results source. engine='turbo' runs ModelRisk's Turbo engine (its 'Fast Simulation'), often much faster. Turbo cannot evaluate every function: the engine's own check runs first, and the classic engine runs instead (see note and engine in the result) when Turbo cannot run the workbook or returns NaN outputs. Turbo can still give results that differ from the classic engine's for some functions, so confirm figures that matter with the classic engine. A Turbo run shows ModelRisk's progress window and opens its results in the Results Viewer.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| seed | No | Random seed for reproducibility (fixed seed). | |
| engine | No | 'classic' (default): ModelRisk's own engine, in Excel. 'turbo': ModelRisk's Turbo engine; .xlsx and .xlsm workbooks only, and falls back to classic when it cannot run the workbook. | classic |
| samples | No | Iteration count. Default: 1000. Either `samples` or `iterations` is accepted (they mean the same thing). If both are passed, `samples` wins. | |
| save_to | No | Absolute path to write the .vmrs. Default: next to the workbook as `<book_stem>.vmrs`. For OneDrive-hosted workbooks (where path resolution can fail) the default falls back to the user's Desktop folder. | |
| iterations | No | Alias for `samples`. ModelRisk's UI calls this 'samples'; many users call it 'iterations'. Both work. | |
| workbook_name | No | Workbook file name (e.g. 'model.xlsx'). Omit for the active workbook. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| note | No | Set when ModelRisk's own save returned a different run (its Results Viewer had another run loaded) and the .vmrs was rebuilt from this run's ModelRisk run file, or when Turbo was asked for and the classic engine ran instead, and why. The results are this run's either way. | |
| seed | Yes | ||
| engine | No | The engine whose run was saved. 'classic' after a request for 'turbo' means Turbo could not run the workbook; `note` says why. | classic |
| samples | Yes | ||
| next_step | Yes | Suggested follow-up call for the MCP client — typically `get_simulation_results` to pull the per-output statistics. | |
| vmrs_path | Yes | ||
| workbook_name | Yes |