From 0c5edfac929ae8e68090af1ef5a4031e9f02f2c2 Mon Sep 17 00:00:00 2001 From: Charlie Blake Date: Wed, 25 Jul 2018 15:00:18 +0100 Subject: Add csv output to single deal and init sol script --- src/main/solver/solver.cpp | 63 ++++++++++++++++++++++++++++++++++++++++++++++ src/main/solver/solver.h | 4 +++ 2 files changed, 67 insertions(+) (limited to 'src/main/solver') diff --git a/src/main/solver/solver.cpp b/src/main/solver/solver.cpp index abe55f5..3aaceb8 100644 --- a/src/main/solver/solver.cpp +++ b/src/main/solver/solver.cpp @@ -9,11 +9,13 @@ #include #include #include +#include #include "solver.h" #include "../game/move.h" #include "../input-output/output/log_helper.h" #include "../input-output/output/state_printer.h" +#include "../input-output/input/command_line_helper.h" using std::atomic; using std::vector; @@ -24,6 +26,8 @@ using std::max; using std::begin; using std::end; using boost::optional; +using std::fixed; +using std::setprecision; solver::solver(const game_state& gs, uint64_t cache_capacity) : cache(lru_cache(gs, cache_capacity)) @@ -240,6 +244,65 @@ std::ostream& operator<< (std::ostream& out, const solver::result& r) { << "Time Taken (milliseconds): " << r.time.count() << "\n"; } +void solver::print_header(long t, command_line_helper::streamliner_opt stream_opt) { + cout << "Calculating solvability percentage...\n\n" + "Lower Bound" + ", Upper Bound" + ", Solvable" + ", Unsolvable" + ", Timed-out" + ", Memory Limited, "; + if (stream_opt == command_line_helper::streamliner_opt::SMART) { + cout << "| (Streamliner Results:) " + "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" + "| (Non-Streamliner Results:) "; + } + cout << "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" + ", Seeds In Progress ..." + "\n--- Timeout = " << t << " milliseconds ---\n"; + cout << fixed << setprecision(3); +} + +void solver::print_result_csv(solver::result res) { + cout << ", " << res.sol_type + << ", " << res.time.count() + << ", " << res.states_searched + << ", " << res.unique_states_searched + << ", " << res.backtracks + << ", " << res.dominance_moves + << ", " << res.states_removed_from_cache + << ", " << res.cache_size + << ", " << res.cache_bucket_count + << ", " << res.max_depth + << ", " << res.depth; +} + +void solver::print_null_seed_info() { + cout << ", , , , , , , , , , , , "; +} + const vector solver::get_frontier() const { return frontier; } diff --git a/src/main/solver/solver.h b/src/main/solver/solver.h index 4035d6a..90796f7 100644 --- a/src/main/solver/solver.h +++ b/src/main/solver/solver.h @@ -12,6 +12,7 @@ #include "../game/global_cache.h" #include "../game/sol_rules.h" +#include "../input-output/input/command_line_helper.h" class solver { public: @@ -45,6 +46,9 @@ public: result run(boost::optional = boost::none); void print_solution() const; + static void print_header(long, command_line_helper::streamliner_opt); + static void print_result_csv(solver::result); + static void print_null_seed_info(); const std::vector get_frontier() const; private: -- cgit v1.2.1