Quick Reference: Variables and Expressions

Data types used in qbpp::Expr

Available integer data types

WARNING
To maximize performance, QUBO++ does not check for arithmetic overflow.
During development and testing, it is recommended to use wider bit widths for coeff_t and energy_t.
If the required bit widths are unclear, use qbpp::cpp_int to ensure correctness, and switch to fixed-width integer types after validation.

Printing class objects

Most classes in QUBO++ can be printed using the << operator with std::ostream, which is useful for debugging. For example, an object obj in QUBO++ can be printed to std::cout as follows:

std::cout << obj << std::endl;

This invokes either obj.str() or str(obj), which returns a std::string containing a textual representation of obj. This design allows easy inspection of internal states without relying on a debugger.

Variable classes

NOTE
A qbpp::Var object represents a variable symbolically.
No specific data type is associated with it.
It can be used to represent binary, spin, or other types of variables.

Variable creation functions

The following functions are provided to create variables:

NOTE
If "name" is omitted, numbered names such as "{0}", "{1}", … are automatically assigned in creation order.

qbpp::Var member functions

For a qbpp::Var instance x, the following member functions are available:

Usually, there is no need to call these member functions explicitly in QUBO++ programs.

Integer variable class

Integer variable creation functions

The following functions are provided to create integer variables:

Integer variable member functions

For a qbpp::VarInt instance x, the following member functions are available:

The following expression is equivalent to the expression stored in x:

x.min_val() + qbpp::sum(x.coeffs() * x.vars())

Last updated: 2025.12.31