aboutsummaryrefslogtreecommitdiff
path: root/solvability.sh
diff options
context:
space:
mode:
authorCharlie Blake2018-08-09 19:44:47 +0100
committerCharlie Blake2018-08-09 19:59:11 +0100
commita4b73d21d130c64102b5e2b88dc93bdbb9f81021 (patch)
tree6193371614b7895794e2265cc47a30e62a3b0a34 /solvability.sh
parentMerge pull request #84 from thecharlesblake/spider-face-up (diff)
downloadmetasol-a4b73d21d130c64102b5e2b88dc93bdbb9f81021.tar.gz
metasol-a4b73d21d130c64102b5e2b88dc93bdbb9f81021.zip

Write results to independent files and combines

Diffstat (limited to 'solvability.sh')
-rwxr-xr-xsolvability.sh36
1 files changed, 33 insertions, 3 deletions
diff --git a/solvability.sh b/solvability.sh
index 3fc9f7f..eae6636 100755
--- a/solvability.sh
+++ b/solvability.sh
@@ -1,16 +1,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\" results.csv"
+ 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"
-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"
+cleanup
+
+trap "exitfn" INT
+
+parallel --results "$tmp" --progress -j"$cores" "$sol_command" --ra {} --class ::: $(seq "$seeds") >/dev/null
+
+exitfn
-parallel -j"$cores" "$sol_command" --str smart-solvability --ra {} --class ::: $(seq "$seeds") >> "$out" 2> /dev/null