Skip to content
Snippets Groups Projects
Commit e49bb02c authored by Jakub Janák's avatar Jakub Janák
Browse files

controller updated to accept the number of threads for parallel solve

parent 3022a34f
No related branches found
No related tags found
No related merge requests found
......@@ -20,7 +20,7 @@ Controller::Controller() {
("create-synthetic-instance,c", boost::program_options::value<int>(),
"Create synthetic instance (fully connected graph) with n vertices")
("solve,s", "Solve the instances in queue")
("solve-parallel,p", "Parallel solve the instances in queue")
("solve-parallel,p", boost::program_options::value<int>(), "Parallel solve the instances in queue, with number of threads")
("heuristic-combo,e", "Use nearest neighbour + 2Opt to approximate the best path");
}
......@@ -73,7 +73,8 @@ int Controller::run(int argc, char *argv[]) {
}
if (vm.contains("solve-parallel")) {
solve("p");
const int num_of_threads = vm["solve-parallel"].as<int>();
solve("p", num_of_threads);
}
if (vm.contains("heuristic-combo")) {
heuristic_combo();
......@@ -108,7 +109,7 @@ void Controller::create_synthetic_instance(const int num_of_nodes) {
std::cout << "created synthetic instance with: " << num_of_nodes << " nodes" << std::endl;
}
void Controller::solve(const std::string &args) {
void Controller::solve(const std::string &args, const int num_of_threads) {
if (this->unsolvedInstances.empty()) {
std::cout << "Nothing to solve!" << std::endl;
return;
......@@ -116,7 +117,7 @@ void Controller::solve(const std::string &args) {
while (!this->unsolvedInstances.empty()) {
std::cout << "Solving..." << std::endl;
auto &instance = this->unsolvedInstances.front();
instance->solve(args);
instance->solve(args, num_of_threads);
instance->print_statistics();
if (!instance->is_solved()) {
this->unsolvedInstances.pop_front();
......
......@@ -26,7 +26,7 @@ public:
void create_synthetic_instance(int num_of_nodes);
void solve(const std::string& args);
void solve(const std::string& args, const int num_of_threads = 1);
void heuristic_combo();
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment