6 #include <boost/program_options.hpp>
12 namespace po = boost::program_options;
18 int main(
int argc,
char **argv) {
20 po::options_description desc(
21 "Solving the random partitioning problem using QUBO++ Exhaustive Solver.");
22 desc.add_options()(
"help,h",
"produce help message.")
23 (
"size,s", po::value<size_t>()->default_value(10),
"Set the size of the input set.")
24 (
"random,r", po::value<int>(),
"Set the base seed for the random number generator for deterministic behavior.")
25 (
"max,m", po::value<qbpp::energy_t>()->default_value(1000),
"Set the maximum value of the input set.");
30 po::store(po::parse_command_line(argc, argv, desc), vm);
31 }
catch (
const std::exception &e) {
32 std::cout <<
"Wrong arguments. Please use -h/--help option to see the "
38 if (vm.count(
"help")) {
39 std::cout << desc << std::endl;
44 if (vm.count(
"random")) {
49 size_t size = vm[
"size"].as<
size_t>();
57 for (
size_t i = 0; i < size; i++) {
62 std::cout <<
qbpp::str(w,
"w") << std::endl;
71 solver.enable_default_callback();
74 auto sol = solver.search();
77 std::cout <<
"Solution = " << sol << std::endl;
81 for (
size_t i = 0; i < size; i++) {
82 if (sol.get(x[i]) == 0) {
83 std::cout <<
" " << w[i];
86 std::cout << std::endl;
88 for (
size_t i = 0; i < size; i++) {
89 if (sol.get(x[i]) == 1) {
90 std::cout <<
" " << w[i];
93 std::cout << std::endl;
static void set_seed(uint32_t seed=1)
Var var(const std::string &var_str)
Expr sum(const Vector< T > &items)
energy_t eval(const Expr &expr, const Sol &sol)
Vector< Expr > sqr(const Vector< T > &arg)
int main(int argc, char **argv)
Solves the Partitioning problem using the QUBO++ Exhaustive Solver.
QUBO++, a C++ library for generating expressions for binary and spin variables.
Exhaustive QUBO Solver for solving QUBO problems.
A miscellaneous library used for sample programs of the QUBO++ library.