aboutsummaryrefslogtreecommitdiff
path: root/src/main/solver/solver.cpp
diff options
context:
space:
mode:
authorCharlie Blake2018-07-25 15:00:18 +0100
committerCharlie Blake2018-07-26 10:32:38 +0100
commit0c5edfac929ae8e68090af1ef5a4031e9f02f2c2 (patch)
tree79249838d3e5f30869591dce33f74b096617d50f /src/main/solver/solver.cpp
parentAdd timeout to individual games (diff)
downloadmetasol-0c5edfac929ae8e68090af1ef5a4031e9f02f2c2.tar.gz
metasol-0c5edfac929ae8e68090af1ef5a4031e9f02f2c2.zip

Add csv output to single deal and init sol script

Diffstat (limited to 'src/main/solver/solver.cpp')
-rw-r--r--src/main/solver/solver.cpp63
1 files changed, 63 insertions, 0 deletions
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 <list>
#include <malloc.h>
#include <chrono>
+#include <iomanip>
#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::node> solver::get_frontier() const {
return frontier;
}