diff options
Diffstat (limited to 'solvability.sh')
| -rwxr-xr-x | solvability.sh | 36 |
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 |
