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++ Easy 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.")
 
   26     (
"time,t", po::value<uint32_t>()->default_value(10), 
"Set the time limit in seconds.");
 
   31     po::store(po::parse_command_line(argc, argv, desc), vm);
 
   32   } 
catch (
const std::exception &e) {
 
   33     std::cout << 
"Wrong arguments. Please use -h/--help option to see the " 
   39   if (vm.count(
"help")) {
 
   40     std::cout << desc << std::endl;
 
   45   if (vm.count(
"random")) {
 
   50   size_t size = vm[
"size"].as<
size_t>();
 
   55   uint32_t time_limit = vm[
"time"].as<uint32_t>();
 
   61   for (
size_t i = 0; i < size; i++) {
 
   66   std::cout << 
qbpp::str(w, 
"w") << std::endl;
 
   76   solver.set_time_limit(time_limit);
 
   79   solver.set_target_energy(1);
 
   82   solver.enable_default_callback();
 
   85   auto sol = solver.search();
 
   88   std::cout << 
"Solution = " << sol << std::endl;
 
   92   for (
size_t i = 0; i < size; i++) {
 
   93     if (sol.get(x[i]) == 0) {
 
   94       std::cout << 
" " << w[i];
 
   97   std::cout << std::endl;
 
   99   for (
size_t i = 0; i < size; i++) {
 
  100     if (sol.get(x[i]) == 1) {
 
  101       std::cout << 
" " << w[i];
 
  104   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++ Easy Solver.
 
QUBO++, a C++ library for generating expressions for binary and spin variables.
 
Easy QUBO Solver for solving QUBO problems.
 
A miscellaneous library used for sample programs of the QUBO++ library.