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:

ArgumentDescription
policy_namePolicy to run (e.g., null, high-risk, low-risk, age-first)
repeatNumber of repetitions
repeat_startStarting index for repetition numbering
output_dirBase directory for output files

Simulation parameters (--):

FlagDefaultDescription
--T_max40000Maximum simulation time (days)
--p_length100Episode length (days)
--p_freeze2Periods to freeze before updating scores
--p_freeze_policy10Periods before updating the policy
--rel_off_probation2000Off-probation term (days)
--beta_arrival5Arrival rate parameter
--beta_initial5Initial population size

Treatment parameters:

FlagDefaultDescription
--treatment_capacity80Treatment slots per episode
--treatment_effect0.5Effect size (0-1), or type-1 for heterogeneous
--treatment_dosagedefaultdefault (1.0) or type-1 for heterogeneous

Example:

python run_policy.py high-risk 10 0 results --T_max 60000 --treatment_capacity 100

Batch 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.sh

Available batch scripts:

ScriptDescription
run_all.zshStandard run across policies
run_all_params_cap.zshVary treatment capacity
run_all_params-dosage.zshVary dosage
run_all_params-dosage-type1.zshType-1 heterogeneous dosage
run_all_params-less-people.zshSmaller population
run_all_params-more-people.zshLarger population
run_all_params-ofpl.zshVary off-probation length
run_all_params-younger.zshYounger age distribution

Environment variables

VariableDefaultDescription
DBG01 for debug mode (more arrivals, faster iteration)
TR_LOW15.0Treatment effect lower bound
TR_HIGH0.0Treatment 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