26   auto constraint = 0 <= 
qbpp::sum(x * weights) <= 20;
 
   29   auto f = -objective + constraint * 1000;
 
   33   std::cout << 
"f = " << f << std::endl;
 
   37   auto sol = solver.search();
 
   39   std::cout << 
"Solution = " << sol << std::endl;
 
   41   for (
size_t i = 0; i < values.
size(); i++) {
 
   42     if (sol.get(x[i]) == 1) {
 
   43       std::cout << 
"Item " << i << 
" with value " << values[i] << 
" and weight " 
   44                 << weights[i] << 
" is selected" << std::endl;
 
Expr & simplify_as_binary()
Var var(const std::string &var_str)
Expr sum(const Vector< T > &items)
QUBO++, a C++ library for generating expressions for binary and spin variables.
Exhaustive QUBO Solver for solving QUBO problems.