QUBO++ Library with QUBO Solver APIs
Author: Koji Nakano, License: Non-commercial research and evaluation purposes without any guarantees.
simple_factorization_abs2.cpp
Go to the documentation of this file.
1 
8 #include "qbpp.hpp"
9 #include "qbpp_abs2.hpp"
10 
11 int main() {
12  auto x = 1 <= qbpp::var_int("x") <= 100;
13  auto y = 1 <= qbpp::var_int("y") <= 100;
14  auto f = x * y == 97 * 89;
15  auto quad_model = qbpp::QuadModel(simplify_as_binary(reduce(f)));
16  std::cout << "quad_model has " << quad_model.var_count() << " variables, "
17  << quad_model.term_count(1) << " linear terms, and "
18  << quad_model.term_count(2) << " quadratic terms" << std::endl;
19  auto solver = qbpp_abs2::Solver();
20  auto param = qbpp_abs2::Param();
21  auto callback = qbpp_abs2::Callback(quad_model);
22  param.set_time_limit(10);
23  param.set_target_energy(0);
24  param.set(callback);
25  auto sol = solver(quad_model, param);
26  std::cout << "x = " << x << " = " << sol.get(x) << std::endl;
27  std::cout << "y = " << y << " = " << sol.get(y) << std::endl;
28 }
A class for defining the ABS2 callback function.
Definition: qbpp_abs2.hpp:204
A class for setting parameters for the ABS2 QUBO solver.
Definition: qbpp_abs2.hpp:104
A class for calling the ABS2 QUBO solver.
Definition: qbpp_abs2.hpp:53
VarIntCore var_int(const std::string &var_str)
Definition: qbpp.hpp:2217
Expr simplify_as_binary(const Expr &expr)
Definition: qbpp.hpp:2759
Expr reduce(const Expr &expr)
Definition: qbpp.hpp:2878
QUBO++, a C++ library for generating expressions for binary and spin variables.
QUBO++ interface to call ABS2 GPU QUBO solver.