study_runner
agentevac.analysis.study_runner
End-to-end calibration study orchestrator.
study_runner.py is the top-level entry point for running a complete parameter
calibration study. It chains three stages:
1. **Experiment sweep** (``experiments.run_parameter_sweep``):
Spawns one headless ``agentevac.simulation.main`` subprocess per grid cell and collects
the metrics JSON and replay JSONL for each case.
2. **Calibration fit** (``calibration.fit_agent_parameters``):
Scores each run against the reference metrics and ranks candidates by
goodness of fit.
3. **Report export**:
Writes three output artifacts to a timestamped study directory:
- ``experiments/experiment_results.json`` : Full sweep results.
- ``experiments/experiment_results.csv`` : Flat CSV summary.
- ``calibration_report.json`` : Ranked calibration results.
- ``study_report.json`` : Top-level study summary.
Each call to run_study creates a fresh timestamped directory under output_dir
so studies do not overwrite each other.
run_study(*, reference_path, script_path='agentevac/simulation/main.py', python_executable=None, output_dir='outputs/studies', sumo_binary='sumo', run_mode='record', timeout_s=None, sigma_values=None, delay_values=None, trust_values=None, scenario_values=None, messaging_enabled=True, weights=None, top_k=5, map_name=None)
Run a complete parameter calibration study: sweep → fit → report.
Creates a timestamped study directory, runs all grid cases, fits against the reference, and writes summary reports.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reference_path
|
str
|
Path to the reference metrics JSON (target behaviour). |
required |
script_path
|
str
|
Path to |
'agentevac/simulation/main.py'
|
python_executable
|
Optional[str]
|
Python interpreter; defaults to |
None
|
output_dir
|
str
|
Base directory for all study outputs. |
'outputs/studies'
|
sumo_binary
|
str
|
SUMO binary name ( |
'sumo'
|
run_mode
|
str
|
|
'record'
|
timeout_s
|
Optional[float]
|
Per-case subprocess timeout in seconds. |
None
|
sigma_values
|
Optional[List[float]]
|
|
None
|
delay_values
|
Optional[List[float]]
|
|
None
|
trust_values
|
Optional[List[float]]
|
|
None
|
scenario_values
|
Optional[List[str]]
|
Scenario mode strings to sweep. |
None
|
messaging_enabled
|
bool
|
Whether inter-agent messaging is active for all cases. |
True
|
weights
|
Optional[Dict[str, float]]
|
Per-metric calibration weight overrides. |
None
|
top_k
|
int
|
Number of top-ranked candidates to include in the calibration report. |
5
|
map_name
|
Optional[str]
|
Map config directory name (e.g., |
None
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
A study summary dict containing timing information, case counts, file paths, |
Dict[str, Any]
|
and the best-fit parameter configuration. |
Source code in agentevac/analysis/study_runner.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | |