Skip to content
Snippets Groups Projects
Commit ee9885ad authored by Jarrod Pas's avatar Jarrod Pas
Browse files

Adds runner for all algorithms

parent 747f1733
No related branches found
No related tags found
1 merge request!3Version 0.2
#!/usr/bin/env bash
set -euo pipefail
shed=$1
epoch=$((7*24*60*60))
ticks_per_packet=$((60*120))
time_to_live=$((3*$epoch))
buffer_size=$((3*7*24*60*60))
duty=300
run() {
echo 'start:' $@ >&2
python main.py \
--seed "$3" \
--router "$1" \
--community "$2" \
--community-args \
"epoch=${epoch}" \
--trace "csv" \
--trace-args \
"path=shed/data/pp_${shed}_reduced.csv" \
--node-args \
"tick_time=${duty}" \
"buffer_size=${buffer_size}" \
--packet-args \
"ticks_per_packet=${ticks_per_packet}" \
"time_to_live=${time_to_live}" \
"start_delay=${epoch}"
echo 'done:' $@ >&2
}
nproc=$(nproc)
mkdir -p logs/$shed
for seed in {1..10}; do
for router in direct epidemic; do
[[ "$(jobs | wc -l)" -ge "$nproc" ]] && wait -n
run "$router" "none" "$seed" > "logs/${shed}/${router}_${seed}.log" &
done
for router in bubble hcbf; do
for community in kclique louvain; do
[[ "$(jobs | wc -l)" -ge "$nproc" ]] && wait -n
run "$router" "$community" "$seed" > "logs/${shed}/${router}_${community}_${seed}.log" &
done
done
done
wait
for f in direct epidemic {bubble,hcbf}_{kclique,louvain}; do
./util/shed_summary "logs/$shed/$f"*.log > "logs/$shed/${f}_summary.yml"
done
# send slack notification if the script exists
status=$?
notify=$HOME/dev/slack-notifier/send_notification_via_slack.py
[[ -e "$notify" ]] && $notify "\`$shed done: exit($status)\`"
#!/usr/bin/env python
from collections import defaultdict
import re
import sys
import scipy.stats as stats
import yaml
if __name__ == '__main__':
data = defaultdict(list)
pattern = re.compile(r'^\w+:')
for f in sys.argv[1:]:
with open(f) as f:
y = ''
for line in f:
if pattern.match(line):
y += line
d = yaml.load(y)
for k, v in d.items():
data[k].append(v)
o = {}
for k, v in data.items():
d = stats.describe(v)
o[k] = {
'mean': float(d.mean),
'stddev': float(d.variance**(1/2)),
}
print(yaml.dump(o))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment