aboutsummaryrefslogtreecommitdiff
path: root/solvability.sh
diff options
context:
space:
mode:
authorCharlie Blake2018-08-09 20:00:47 +0100
committerGitHub2018-08-09 20:00:47 +0100
commitb9ed38b7880cb55f2ea850c08d608efd4a2f5833 (patch)
treeb291edbc7c45a685f7eac8814b88fe1e3d052158 /solvability.sh
parentMerge pull request #84 from thecharlesblake/spider-face-up (diff)
parentFlushes output before and after results (diff)
downloadmetasol-b9ed38b7880cb55f2ea850c08d608efd4a2f5833.tar.gz
metasol-b9ed38b7880cb55f2ea850c08d608efd4a2f5833.zip

Merge pull request #85 from thecharlesblake/fix-write-out-bugs

Fix write out bugs

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