Running Simulations
CLI usage
The main entry point is run_policy.py:
python run_policy.py <policy_name> <repeat> <repeat_start> <output_dir> [options]Positional arguments:
| Argument | Description |
|---|---|
policy_name | Policy to run (e.g., null, high-risk, low-risk, age-first) |
repeat | Number of repetitions |
repeat_start | Starting index for repetition numbering |
output_dir | Base directory for output files |
Simulation parameters (--):
| Flag | Default | Description |
|---|---|---|
--T_max | 40000 | Maximum simulation time (days) |
--p_length | 100 | Episode length (days) |
--p_freeze | 2 | Periods to freeze before updating scores |
--p_freeze_policy | 10 | Periods before updating the policy |
--rel_off_probation | 2000 | Off-probation term (days) |
--beta_arrival | 5 | Arrival rate parameter |
--beta_initial | 5 | Initial population size |
Treatment parameters:
| Flag | Default | Description |
|---|---|---|
--treatment_capacity | 80 | Treatment slots per episode |
--treatment_effect | 0.5 | Effect size (0-1), or type-1 for heterogeneous |
--treatment_dosage | default | default (1.0) or type-1 for heterogeneous |
Example:
python run_policy.py high-risk 10 0 results --T_max 60000 --treatment_capacity 100Batch runs
Shell scripts in sbin/ generate and run batches of policy simulations:
# Generate commands for 10 repeats starting at index 0, output to results/
zsh sbin/run_all.zsh 10 0 results
# This creates results/cmd.sh which can be executed:
bash results/cmd.shAvailable batch scripts:
| Script | Description |
|---|---|
run_all.zsh | Standard run across policies |
run_all_params_cap.zsh | Vary treatment capacity |
run_all_params-dosage.zsh | Vary dosage |
run_all_params-dosage-type1.zsh | Type-1 heterogeneous dosage |
run_all_params-less-people.zsh | Smaller population |
run_all_params-more-people.zsh | Larger population |
run_all_params-ofpl.zsh | Vary off-probation length |
run_all_params-younger.zsh | Younger age distribution |
Environment variables
| Variable | Default | Description |
|---|---|---|
DBG | 0 | 1 for debug mode (more arrivals, faster iteration) |
TR_LOW | 15.0 | Treatment effect lower bound |
TR_HIGH | 0.0 | Treatment effect upper bound |
Sensitivity analysis
Sensitivity analysis scripts live in sensanaly/:
python sensanaly/run_sensanaly_capeff.py # capacity effect
python sensanaly/run_sensanaly_prscale.py # probability scale