44 auto obj = 6 * x1 + 4 * x2 + 3 * x3 + 5 * x4;
47 auto c1 = x1 + 2 * x2 + 3 * x3 + 4 * x4;
48 auto c2 = 3 * x1 + x2 + 2 * x3 + x4;
51 auto f = -obj + 100 * ((0 <= c1 <= 15) + (0 <= c2 <= 10));
54 f.simplify_as_binary();
60 auto sol_optimal = solver.search_optimal_solutions();
63 std::cout << sol_optimal;
66 auto sol = sol_optimal.get_sol();
69 std::cout <<
"x1 = " <<
eval(x1, sol) << std::endl;
70 std::cout <<
"x2 = " <<
eval(x2, sol) << std::endl;
71 std::cout <<
"x3 = " <<
eval(x3, sol) << std::endl;
72 std::cout <<
"x4 = " <<
eval(x4, sol) << std::endl;
73 std::cout <<
"c1 = " <<
eval(c1, sol) << std::endl;
74 std::cout <<
"c2 = " <<
eval(c2, sol) << std::endl;
75 std::cout <<
"Objective value = " <<
eval(obj, sol) << std::endl;
VarIntCore var_int(const std::string &var_str)
energy_t eval(const Expr &expr, const Sol &sol)
QUBO++, a C++ library for generating expressions for binary and spin variables.
Exhaustive QUBO Solver for solving QUBO problems.