blob: eae6636a5933ce6958fc91e873c844f228bcbed8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
#!/bin/bash
if [ "$#" != 4 ]; then
echo "Usage: <seeds> <cores> \"<solvitaire_command>\" <output_file>"
echo "e.g.: ./solvability.sh 1000 40 \"sol --type alpha-star --timeout 6000 --str smart-solvability\" results.csv"
exit 1
fi
tmp=".tmp"
cleanup () {
if [ -d "$tmp" ]; then
rm -r "$tmp"
fi
}
writetofile () {
if [ -d "$tmp" ]; then
echo "Attempted Seed, Outcome, Time Taken(ms), States Searched, Unique States Searched, Backtracks, Dominance Moves, States Removed From Cache, Final States In Cache, Final Buckets In Cache, Maximum Search Depth, Final Search Depth" > "$out"
cat "$tmp"/*/*/stdout >> "$out"
fi
}
exitfn () {
if [ -d "$tmp" ]; then
writetofile
cleanup
exit
fi
}
seeds="$1"
cores="$2"
sol_command="$3"
out="$4"
cleanup
trap "exitfn" INT
parallel --results "$tmp" --progress -j"$cores" "$sol_command" --ra {} --class ::: $(seq "$seeds") >/dev/null
exitfn
|