|
| 1 | +#include "packingsolver/irregular/instance_builder.hpp" |
| 2 | +#include "packingsolver/irregular/solution.hpp" |
| 3 | + |
| 4 | +#include <boost/program_options.hpp> |
| 5 | + |
| 6 | +using namespace packingsolver; |
| 7 | +using namespace packingsolver::irregular; |
| 8 | +namespace po = boost::program_options; |
| 9 | + |
| 10 | +int main(int argc, char *argv[]) |
| 11 | +{ |
| 12 | + po::options_description desc("Allowed options"); |
| 13 | + desc.add_options() |
| 14 | + (",h", "Produce help message") |
| 15 | + ("instance,i", po::value<std::string>()->required(), "Instance path") |
| 16 | + ("solution,s", po::value<std::string>()->required(), "Solution path") |
| 17 | + ; |
| 18 | + po::positional_options_description pod; |
| 19 | + pod.add("instance", 1); |
| 20 | + pod.add("solution", 1); |
| 21 | + |
| 22 | + po::variables_map vm; |
| 23 | + po::store(po::command_line_parser(argc, argv).options(desc).positional(pod).run(), vm); |
| 24 | + if (vm.count("help")) { |
| 25 | + std::cout << desc << std::endl; |
| 26 | + return 1; |
| 27 | + } |
| 28 | + try { |
| 29 | + po::notify(vm); |
| 30 | + } catch (const po::required_option& e) { |
| 31 | + std::cout << desc << std::endl; |
| 32 | + return 1; |
| 33 | + } |
| 34 | + |
| 35 | + InstanceBuilder instance_builder; |
| 36 | + instance_builder.read(vm["instance"].as<std::string>()); |
| 37 | + Instance instance = instance_builder.build(); |
| 38 | + |
| 39 | + const std::string solution_path = vm["solution"].as<std::string>(); |
| 40 | + Solution solution(instance, solution_path); |
| 41 | + solution.write(solution_path); |
| 42 | + |
| 43 | + return 0; |
| 44 | +} |
0 commit comments