QUBO++ Library with QUBO Solver APIs
Author: Koji Nakano, License: Non-commercial research and evaluation purposes without any guarantees.
Public Member Functions | Private Attributes | List of all members
abs2::Model Class Reference

Class to store and manipulate a QUBO model. More...

#include <abs2.hpp>

Public Member Functions

 Model (int size, int bits)
 Constructor for an empty QUBO model. More...
 
 Model (int size, int64_t min_coeff, int64_t max_coeff)
 Constructor for an empty QUBO model with specified variable size and coefficient range. More...
 
 Model (const std::string &filename)
 Constructor for loading a QUBO model from a file. More...
 
 ~Model ()
 Destructor for the QUBO model. More...
 
 Model (const Model &model)
 Copy constructor for the QUBO model. More...
 
Modeloperator= (const Model &model)
 Assignment operator for copying the QUBO model. More...
 
void set (int i, int j, int64_t val)
 Sets the value of W_{i,j} if i<=j, and W_{j,i} if j<i. More...
 
int64_t get (int i, int j) const
 Gets the value of W_{i,j} if i<=j, and W_{j,i} if j<i. More...
 
void set (const std::string &key, const std::string &val)
 Sets a value for a given key. More...
 
std::string get (const std::string &key) const
 Gets the value associated with a given key. More...
 
void print (const std::string &option="", std::ostream &output_stream=std::cout) const
 Outputs the model to the specified output stream. More...
 
void print (std::ostream &output_stream, const std::string &option="") const
 Outputs the model to the specified output stream. More...
 

Private Attributes

std::unique_ptr< Impl > pimpl
 

Detailed Description

Class to store and manipulate a QUBO model.

Definition at line 91 of file abs2.hpp.

Constructor & Destructor Documentation

◆ Model() [1/4]

abs2::Model::Model ( int  size,
int  bits 
)

Constructor for an empty QUBO model.

Parameters
sizeNumber of variables.
bitsNumber of bits for each coefficient.
Note
The "size" must be between 32 and 65536, and [min_coeff, max_coeff] defines the range of W_{i,j}.

◆ Model() [2/4]

abs2::Model::Model ( int  size,
int64_t  min_coeff,
int64_t  max_coeff 
)

Constructor for an empty QUBO model with specified variable size and coefficient range.

Parameters
sizeNumber of variables.
min_coeffMinimum value of W_{i,j}.
max_coeffMaximum value of W_{i,j}.

◆ Model() [3/4]

abs2::Model::Model ( const std::string &  filename)

Constructor for loading a QUBO model from a file.

Parameters
filenameThe name of the file to load the model from.

◆ ~Model()

abs2::Model::~Model ( )

Destructor for the QUBO model.

◆ Model() [4/4]

abs2::Model::Model ( const Model model)

Copy constructor for the QUBO model.

Parameters
modelThe QUBO model to be copied.

Member Function Documentation

◆ operator=()

Model& abs2::Model::operator= ( const Model model)

Assignment operator for copying the QUBO model.

Parameters
modelThe QUBO model to be copied.
Returns
Reference to the copied QUBO model.

◆ set() [1/2]

void abs2::Model::set ( int  i,
int  j,
int64_t  val 
)

Sets the value of W_{i,j} if i<=j, and W_{j,i} if j<i.

Parameters
iRow index of W.
jColumn index of W.
valValue to be set.

◆ get() [1/2]

int64_t abs2::Model::get ( int  i,
int  j 
) const

Gets the value of W_{i,j} if i<=j, and W_{j,i} if j<i.

Parameters
iRow index of W.
jColumn index of W.
Returns
The value of W_{i,j} or W_{j,i}.

◆ set() [2/2]

void abs2::Model::set ( const std::string &  key,
const std::string &  val 
)

Sets a value for a given key.

Parameters
keyThe key.
valThe value to be set.

◆ get() [2/2]

std::string abs2::Model::get ( const std::string &  key) const

Gets the value associated with a given key.

Parameters
keyThe key.
Returns
The value associated with the key.

◆ print() [1/2]

void abs2::Model::print ( const std::string &  option = "",
std::ostream &  output_stream = std::cout 
) const

Outputs the model to the specified output stream.

Parameters
optionThe format option.
output_streamThe output stream to write to. Defaults to std::cout.

◆ print() [2/2]

void abs2::Model::print ( std::ostream &  output_stream,
const std::string &  option = "" 
) const

Outputs the model to the specified output stream.

Parameters
output_streamThe output stream to write to.
optionThe format option. Defaults to an empty string.

Member Data Documentation

◆ pimpl

std::unique_ptr<Impl> abs2::Model::pimpl
private

Definition at line 158 of file abs2.hpp.


The documentation for this class was generated from the following file: