C++ API

Functions

Warning

doxygenfunction: Unable to resolve function “fixQuboVariables” with arguments (dimod::AdjVectorBQM<V, B>&, bool, double) in doxygen xml output for project “dwave-preprocessing” from directory: /home/docs/checkouts/readthedocs.org/user_builds/d-wave-systems-dwave-ocean-sdk/checkouts/latest/docs/../dwave-preprocessing/docs/build-cpp/xml/. Potential matches:

- template<class PosiformInfo> capacity_type fixQuboVariables(PosiformInfo &posiform_info, int num_bqm_variables, bool strict, std::vector<std::pair<int, int>> &fixed_variables)
- template<class V, class B> std::pair<double, std::vector<std::pair<int, int>>> fixQuboVariables(dimod::BinaryQuadraticModel<B, V> &bqm, bool strict, double offset = 0.0)
template<class PosiformInfo>
capacity_type fix_variables_::fixQuboVariables(PosiformInfo &posiform_info, int num_bqm_variables, bool strict, std::vector<std::pair<int, int>> &fixed_variables)

Fixes the QUBO variables.

Parameters
  • posiform_info – Object containing information needed to recreate a posiform corresponding to QUBO.

  • num_bqm_variables – Number of variables in the original QUBO.

  • strict – When true, only the variables corresponding to strong persistencies are fixed. When false, the function tries to fix all the variables corresponding to strong and weak persistencies. Also when false, variables that do not contribute any coefficient to the posiform are set to 1. This may happen if their bias in the original QUBO was 0 or if they were flushed to zero when converted to the posiform.

Classes

template<class BQM, class coefficient_t>
class PosiformInfo

Contains all the information needed to recreate a posiform corresponding to a BQM.

The intention is to reduce the memory footprint as much as possible, thus requiring some processing before the stored data can be used.

For implementation details, see comments in the source code.

For details on the algorithm, see : Boros, Endre & Hammer, Peter & Tavares, Gabriel. (2006). Preprocessing of unconstrained quadratic binary optimization. RUTCOR Research Report.

Public Functions

PosiformInfo(const BQM &bqm)

Construct a PosiformInfo from a binary quadratic model.

inline int getNumVariables()

Get number of posiform variables.

inline int getNumLinear()

Get number of posiform variables with a non-zero linear bias.

inline coefficient_type getLinear(int posiform_variable)

Get the linear bias of a posiform variable.

inline int getNumQuadratic(int posiform_variable)

Get number of quadratic terms a posiform variable contributes in.

inline std::pair<quadratic_iterator_type, quadratic_iterator_type> getQuadratic(int posiform_variable)

Get the neighbors of a posiform variable in the corresponding BQM.

inline int mapVariableQuboToPosiform(int bqm_variable)

Map a QUBO variable to a posiform variable.

The number of QUBO variables and posiform variables may differ since the coefficient for a QUBO variable may turn out to be zero in a posiform. This may occur if the coefficient is flushed to zero during the conversion or if the variable did not have non-zero linear/quadratic biases in the QUBO.

inline int mapVariablePosiformToQubo(int posiform_variable)

Map a posiform variable to a QUBO variable.

The number of QUBO variables and posiform variables may differ since the coefficient for a QUBO variable may turn out to be zero in a posiform. This may occur if the coefficient is flushed to zero during the conversion or if the variable did not have non-zero linear/quadratic biases in the QUBO.

inline coefficient_type convertToPosiformCoefficient(bias_type bqm_bias)

Convert a QUBO coefficient to a posiform coefficient.

inline double getBiasConversionRatio()

Return the value by which bqm biases are multiplied to get posiform coefficients.

inline double getConstant()

Return the value of the constant term of the posiform.

void print()

Print out posiform details.