aboutsummaryrefslogtreecommitdiff
path: root/src/main/input-output
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/input-output')
-rw-r--r--src/main/input-output/input/command_line_helper.cpp32
-rw-r--r--src/main/input-output/input/command_line_helper.h7
2 files changed, 33 insertions, 6 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;
}
diff --git a/src/main/input-output/input/command_line_helper.h b/src/main/input-output/input/command_line_helper.h
index f3320da..3ce239d 100644
--- a/src/main/input-output/input/command_line_helper.h
+++ b/src/main/input-output/input/command_line_helper.h
@@ -18,9 +18,10 @@ public:
int get_random_deal();
bool get_classify();
int get_solvability();
- int get_cores();
+ uint get_cores();
bool get_available_game_types();
bool get_benchmark();
+ std::vector<int> get_resume();
uint64_t get_cache_capacity();
std::string get_describe_game_rules();
@@ -31,6 +32,7 @@ private:
void print_sol_type_rules_error();
void print_no_opts_error();
void print_too_many_opts_error();
+ void print_resume_error();
boost::program_options::options_description cmdline_options;
boost::program_options::options_description main_options;
@@ -44,7 +46,8 @@ private:
bool help;
bool classify;
int solvability;
- int cores;
+ std::vector<int> resume;
+ uint cores;
bool available_game_types;
bool benchmark;
uint64_t cache_capacity;