aboutsummaryrefslogtreecommitdiff
path: root/src/main/input-output
diff options
context:
space:
mode:
authorCharlie Blake2018-06-15 11:13:48 +0100
committerGitHub2018-06-15 11:13:48 +0100
commit094a651cbbcda3a343f5f133bab95160db8c5dc2 (patch)
treed25077e5b092755f83fbbf0d7625eb2ad9b4912e /src/main/input-output
parentMerge pull request #60 from thecharlesblake/cache-mem-limit (diff)
parentFix bug with full cache crash (diff)
downloadmetasol-094a651cbbcda3a343f5f133bab95160db8c5dc2.tar.gz
metasol-094a651cbbcda3a343f5f133bab95160db8c5dc2.zip

Merge pull request #61 from thecharlesblake/parallelise-solvability

Parallelise solvability

Diffstat (limited to 'src/main/input-output')
-rw-r--r--src/main/input-output/input/command_line_helper.cpp27
-rw-r--r--src/main/input-output/input/command_line_helper.h6
2 files changed, 26 insertions, 7 deletions
diff --git a/src/main/input-output/input/command_line_helper.cpp b/src/main/input-output/input/command_line_helper.cpp
index e88f434..cfbfd2f 100644
--- a/src/main/input-output/input/command_line_helper.cpp
+++ b/src/main/input-output/input/command_line_helper.cpp
@@ -40,10 +40,12 @@ command_line_helper::command_line_helper()
"classification")
("cache-capacity", po::value<uint64_t>(), "sets an upper bound on the number of states allowed in "
"the cache")
- ("solvability", "calculates the solvability "
- "percentage of the supplied solitaire game. Must supply "
+ ("solvability", po::value<int>(), "calculates the solvability "
+ "percentage of the supplied solitaire game, given a timeout in milliseconds. Must supply "
"either 'random', 'benchmark', 'solvability' or list of deals to be "
"solved.")
+ ("cores", po::value<int>(), "the number of cores for the solvability percentages to be run across. "
+ "Must be supplied with the solvability option.")
("benchmark", "outputs performance statistics for the solver on the "
"supplied solitaire game. Must supply "
"either 'random', 'benchmark', 'solvability' or list of deals to be "
@@ -110,7 +112,18 @@ bool command_line_helper::parse(int argc, const char* argv[]) {
cache_capacity = 100000000; // One hundred-million
}
- solvability = (vm.count("solvability") != 0);
+ if (vm.count("solvability")) {
+ solvability = vm["solvability"].as<int>();
+ } else {
+ solvability = -1;
+ }
+
+ if (vm.count("cores")) {
+ cores = vm["cores"].as<int>();
+ } else {
+ cores = 1;
+ }
+
benchmark = (vm.count("benchmark") != 0);
@@ -128,7 +141,7 @@ bool command_line_helper::assess_errors() {
// The user must either supply input files, a random seed, or ask for the
// solvability percentage, or benchmark
- int opt_count = (random_deal != -1) + !input_files.empty() + solvability + benchmark;
+ int opt_count = (random_deal != -1) + !input_files.empty() + (solvability > 0) + benchmark;
if (opt_count > 1) {
print_too_many_opts_error();
@@ -211,10 +224,14 @@ uint64_t command_line_helper::get_cache_capacity() {
return cache_capacity;
}
-bool command_line_helper::get_solvability() {
+int command_line_helper::get_solvability() {
return solvability;
}
+int command_line_helper::get_cores() {
+ return cores;
+}
+
bool command_line_helper::get_available_game_types() {
return available_game_types;
}
diff --git a/src/main/input-output/input/command_line_helper.h b/src/main/input-output/input/command_line_helper.h
index ca58d5f..f3320da 100644
--- a/src/main/input-output/input/command_line_helper.h
+++ b/src/main/input-output/input/command_line_helper.h
@@ -17,7 +17,8 @@ public:
const std::string get_rules_file();
int get_random_deal();
bool get_classify();
- bool get_solvability();
+ int get_solvability();
+ int get_cores();
bool get_available_game_types();
bool get_benchmark();
uint64_t get_cache_capacity();
@@ -42,7 +43,8 @@ private:
int random_deal;
bool help;
bool classify;
- bool solvability;
+ int solvability;
+ int cores;
bool available_game_types;
bool benchmark;
uint64_t cache_capacity;