aboutsummaryrefslogtreecommitdiff
path: root/src/main/input-output/input/command_line_helper.cpp
diff options
context:
space:
mode:
authorCharlie Blake2018-06-20 10:05:47 +0100
committerGitHub2018-06-20 10:05:47 +0100
commitadb28d39b2d693db3d2cfa2a04d56c3942122e64 (patch)
tree1fb5c123465c39b77c05e6857621bc06bfc34b4f /src/main/input-output/input/command_line_helper.cpp
parentMerge pull request #62 from thecharlesblake/fix-broken-tests (diff)
parentReduce memory taken up by dfs datastructures (diff)
downloadmetasol-adb28d39b2d693db3d2cfa2a04d56c3942122e64.tar.gz
metasol-adb28d39b2d693db3d2cfa2a04d56c3942122e64.zip

Merge pull request #63 from thecharlesblake/improve-mem-performance

Improve mem performance

Diffstat (limited to 'src/main/input-output/input/command_line_helper.cpp')
-rw-r--r--src/main/input-output/input/command_line_helper.cpp32
1 files changed, 28 insertions, 4 deletions
diff --git a/src/main/input-output/input/command_line_helper.cpp b/src/main/input-output/input/command_line_helper.cpp
index cfbfd2f..2abef54 100644
--- a/src/main/input-output/input/command_line_helper.cpp
+++ b/src/main/input-output/input/command_line_helper.cpp
@@ -44,7 +44,10 @@ command_line_helper::command_line_helper()
"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. "
+ ("resume", po::value<vector<int>>()->multitoken(), "resumes the solvability percentage calculation from a "
+ "previous run. Must be supplied with the solvability option. "
+ "Syntax: [sol unsol intract in-progress-1 in-progress-2 ...]")
+ ("cores", po::value<uint>(), "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 "
@@ -119,11 +122,18 @@ bool command_line_helper::parse(int argc, const char* argv[]) {
}
if (vm.count("cores")) {
- cores = vm["cores"].as<int>();
+ cores = vm["cores"].as<uint>();
} else {
cores = 1;
}
+ if (vm.count("resume")) {
+ resume = vm["resume"].as<vector<int>>();
+ } else {
+ resume = {0, 0, 0};
+ for (uint i = 0; i < cores; i++) resume.push_back(i);
+ }
+
benchmark = (vm.count("benchmark") != 0);
@@ -139,6 +149,11 @@ bool command_line_helper::assess_errors() {
if (available_game_types || !describe_game_rules.empty()) return true;
+ if (solvability > 0 && resume.size() != 3 + cores) {
+ print_resume_error();
+ return false;
+ }
+
// 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 > 0) + benchmark;
@@ -196,7 +211,12 @@ void command_line_helper::print_sol_type_rules_error() {
void command_line_helper::print_too_many_opts_error() {
LOG_ERROR ("Error: User must supply input file(s), the '--random' option, the 'benchmark' option,, "
- "or the '--solvability' option, not multiple");
+ "or the '--solvability' option, not multiple");
+ print_help();
+}
+
+void command_line_helper::print_resume_error() {
+ LOG_ERROR ("Error: Resume contains " << resume.size() << " options, and should contain " << cores + 3);
print_help();
}
@@ -228,7 +248,11 @@ int command_line_helper::get_solvability() {
return solvability;
}
-int command_line_helper::get_cores() {
+vector<int> command_line_helper::get_resume() {
+ return resume;
+}
+
+uint command_line_helper::get_cores() {
return cores;
}