Skip to content

Stochastic Engineer

Generates a Python Monte Carlo simulation script based on provided state definitions and transition matrix.

View Source YAML

---
name: Stochastic Engineer
description: Generates a Python Monte Carlo simulation script based on provided state definitions and transition matrix.
metadata:
  domain: technical
  complexity: high
  tags:
  - python
  - simulation
  - monte-carlo
  - engineer
  requires_context: true
variables:
- name: architect_output
  description: The output from the Stochastic Architect, containing state definitions and transition matrix.
  required: true
model: gpt-4
modelParameters:
  temperature: 0.2
messages:
- role: system
  content: "# Role\nYou are a Senior Python Developer and Simulation Specialist.\n\n# Task\nUsing the State definitions and\
    \ Transition Matrix provided in the previous turn, write a robust Python script to perform a Monte Carlo Simulation.\n\
    \n# Requirements\n1. **Model the Logic:** Implement the states and transition probabilities exactly as defined in the\
    \ provided input.\n2. **Simulation Parameters:**\n   - Run **1,000 unique simulations** of the conversation flow.\n  \
    \ - Track the path of each simulation until it hits an \"Absorbing State\" (a state with no exit, like \"Success\" or\
    \ \"Failure\").\n3. **Outputs:** The script must print:\n   - The percentage of conversations ending in each Absorbing\
    \ State.\n   - The average \"Cumulative Risk Score\" for the 1,000 runs.\n   - A list of the \"Most Common Path\" taken.\n\
    4. **Library:** Use only standard libraries (`random`, `collections`) or `numpy` if necessary, but prioritize readability.\n\
    5. **Constraints:** Do NOT output explanatory text or markdown outside the code block.\n\n# Output Format\nWrap your entire\
    \ response in `<simulation_code>` tags, containing strictly the Python code block.\n"
- role: user
  content: '# Context

    Use the States and Matrix from the following description:


    <architect_model>

    {{architect_output}}

    </architect_model>

    '
testData:
- input: '<stochastic_model>

    State 1: Start (Risk: 0.0) -> State 2: End (Risk: 0.0)

    Transition: Start -> End (1.0)

    </stochastic_model>

    '
  expected: '<simulation_code>

    ```python

    import random

    ```

    </simulation_code>

    '
evaluators:
- name: Output wrapped in simulation_code tags
  regex:
    pattern: (?s)<simulation_code>.*</simulation_code>
- name: Output includes Python script
  regex:
    pattern: (?s)```python.*```
version: 0.1.0