From 20236b6e7f16fc736fcf96f8f655bbcd09b59133 Mon Sep 17 00:00:00 2001 From: Charlie Blake Date: Wed, 20 Jun 2018 11:19:21 +0100 Subject: Change sol output to csv and refactor results dir --- src/main/solver/solver.cpp | 35 +++++++++++++++++++++++++---------- src/main/solver/solver.h | 15 ++++++++++++++- 2 files changed, 39 insertions(+), 11 deletions(-) (limited to 'src/main/solver') diff --git a/src/main/solver/solver.cpp b/src/main/solver/solver.cpp index 53c7d1b..e600835 100644 --- a/src/main/solver/solver.cpp +++ b/src/main/solver/solver.cpp @@ -187,16 +187,31 @@ void solver::print_solution() const { cout << "\n"; } -void solver::print_solution_info() const { - cout << "States Searched: " << states_searched << "\n" - << "Unique States Searched: " << unique_states_searched << "\n" - << "Backtracks: " << backtracks << "\n" - << "Dominance Moves: " << dominance_moves << "\n" - << "States Removed From Cache: " << cache.get_states_removed_from_cache() << "\n" - << "Final States In Cache: " << cache.size() << "\n" - << "Final Buckets In Cache: " << cache.bucket_count() << "\n" - << "Maximum Search Depth: " << max_depth << "\n" - << "Final Search Depth: " << depth << "\n"; +std::ostream& operator<< (std::ostream& out, const solver::solution_info& si) { + return out + << "States Searched: " << si.states_searched << "\n" + << "Unique States Searched: " << si.unique_states_searched << "\n" + << "Backtracks: " << si.backtracks << "\n" + << "Dominance Moves: " << si.dominance_moves << "\n" + << "States Removed From Cache: " << si.states_removed_from_cache << "\n" + << "Final States In Cache: " << si.cache_size << "\n" + << "Final Buckets In Cache: " << si.cache_bucket_count << "\n" + << "Maximum Search Depth: " << si.max_depth << "\n" + << "Final Search Depth: " << si.depth << "\n"; +} + +solver::solution_info solver::get_solution_info() { + solution_info si; + si.states_searched = states_searched; + si.unique_states_searched = unique_states_searched; + si.backtracks = backtracks; + si.dominance_moves = dominance_moves; + si.states_removed_from_cache = cache.get_states_removed_from_cache(); + si.cache_size = cache.size(); + si.cache_bucket_count = cache.bucket_count(); + si.max_depth = max_depth; + si.depth = depth; + return si; } const vector solver::get_frontier() const { diff --git a/src/main/solver/solver.h b/src/main/solver/solver.h index 14dedc5..3aa0d95 100644 --- a/src/main/solver/solver.h +++ b/src/main/solver/solver.h @@ -24,17 +24,30 @@ public: boost::optional cache_state; // Optional, as dominance moves aren't cached }; + struct solution_info { + int states_searched; + int unique_states_searched; + int backtracks; + int dominance_moves; + uint64_t states_removed_from_cache; + lru_cache::item_list::size_type cache_size; + lru_cache::item_list::size_type cache_bucket_count; + int max_depth; + int depth; + }; + friend std::ostream& operator<< (std::ostream&, const solution_info&); + explicit solver(const game_state&, uint64_t); sol_state run(boost::optional &> = boost::none); void print_solution() const; - void print_solution_info() const; int get_states_searched() const; int get_unique_states_searched() const; int get_cache_size() const; int get_states_rem_from_cache() const; const std::vector get_frontier() const; + solution_info get_solution_info(); private: bool revert_to_last_node_with_children(boost::optional = boost::none); -- cgit v1.2.1