Installation
Add to your ECF file:
<library name="simple_montecarlo" location="$SIMPLE_EIFFEL/simple_montecarlo/simple_montecarlo.ecf"/>
Basic Concepts
MEASUREMENT
Type-safe wrapper for observed values. Prevents confusion between measurements and probabilities.
create m.make_real (42.5)
create m.make_integer (100)
TRIAL_OUTCOME
Container for measurements from a single trial. Store multiple named measurements.
MONTE_CARLO_EXPERIMENT
Orchestrates N trials with custom logic, collects outcomes, computes statistics.
SIMULATION_STATISTICS
Aggregated results including mean, std_dev, min/max, and confidence intervals.
Workflow
- Create experiment with trial count
- Define trial logic (what happens in each trial)
- Set optional random seed for reproducibility
- Run simulation (executes all trials)
- Get statistics from completed experiment
Design by Contract
All classes use Design by Contract (DBC):
- Preconditions: Valid input requirements
- Postconditions: Guaranteed output properties
- Invariants: Class consistency rules
Contracts are enforced at runtime and catch errors immediately.
Void Safety
All code is void-safe (void_safety="all"). References are explicitly marked:
- attached: Never null
- detachable: May be null (use attached check)