diff options
| author | Charlie Blake | 2018-08-09 20:00:47 +0100 |
|---|---|---|
| committer | GitHub | 2018-08-09 20:00:47 +0100 |
| commit | b9ed38b7880cb55f2ea850c08d608efd4a2f5833 (patch) | |
| tree | b291edbc7c45a685f7eac8814b88fe1e3d052158 | |
| parent | Merge pull request #84 from thecharlesblake/spider-face-up (diff) | |
| parent | Flushes output before and after results (diff) | |
| download | metasol-b9ed38b7880cb55f2ea850c08d608efd4a2f5833.tar.gz metasol-b9ed38b7880cb55f2ea850c08d608efd4a2f5833.zip | |
Merge pull request #85 from thecharlesblake/fix-write-out-bugs
Fix write out bugs
| -rwxr-xr-x | generate-results.sh | 7 | ||||
| -rwxr-xr-x | solvability.sh | 36 | ||||
| -rw-r--r-- | src/main/main.cpp | 2 |
3 files changed, 39 insertions, 6 deletions
diff --git a/generate-results.sh b/generate-results.sh index 0392450..33e92de 100755 --- a/generate-results.sh +++ b/generate-results.sh @@ -3,13 +3,14 @@ trap 'exit 130' INT if [ "$#" != 3 ]; then - echo "Usage: <seeds> <cores> <timeout>" + echo "Usage: <seeds> <cores> \"<solvitaire_command>\"" + echo "e.g.: ./generate-results.sh 1000 40 \"./cmake-build-release/bin/solvitaire --timeout 6000 --str smart-solvability\"" exit 1 fi seeds="$1" cores="$2" -timeout="$3" +sol_command="$3" declare -a arr=( "alpha-star" @@ -81,7 +82,7 @@ echo "Writing to $out_dir/" for i in "${arr[@]}" do echo "Running $i ..." - ./solvability.sh "$seeds" "$cores" "./cmake-build-release/bin/solvitaire --type $i --timeout $timeout" "$out_dir"/$i.csv + ./solvability.sh "$seeds" "$cores" "$sol_command --type $i" "$out_dir"/$i.csv &>/dev/null done echo "Done!" 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 diff --git a/src/main/main.cpp b/src/main/main.cpp index ff03669..cb63634 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -136,6 +136,7 @@ void solve_game(const sol_rules& rules, command_line_helper& clh, optional<int> solve_sol solution = solve_game(rules, timeout, clh.get_cache_capacity(), str_opt, seed, in_doc); bool run_again = smart && solution.second.sol_type != solver::result::type::SOLVED; + cout.flush(); if (run_again) if (!clh.get_classify()) cout << "Unsolvable using streamliner. Running again...\n"; optional<solve_sol> streamliner_solution = run_again @@ -163,6 +164,7 @@ void solve_game(const sol_rules& rules, command_line_helper& clh, optional<int> } cout << s.second; } + cout.flush(); } pair<solver, solver::result> solve_game(const sol_rules& rules, uint64_t timeout, uint64_t cache_capacity, |
