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

Solution holder to store the best solution of factorization. More...

Inheritance diagram for qbpp::factorization::SolHolder:
Inheritance graph
[legend]
Collaboration diagram for qbpp::factorization::SolHolder:
Collaboration graph
[legend]

Public Member Functions

 SolHolder (const qbpp::QuadModel &quad_model, bool fix_lsb, const qbpp::Vector< qbpp::Var > &var_x, const qbpp::Vector< qbpp::Var > &var_y)
 Constructor with a quad_model. More...
 
 SolHolder (const qbpp::QuadModel &quad_model, bool fix_lsb, const qbpp::Vector< qbpp::Var > &var_z)
 Constructor with a quad_model. More...
 
 SolHolder (const SolHolder &sol_holder)=default
 
void set_bound (int64_t bound)
 Sets the bound value of the best solution. More...
 
std::optional< int64_t > get_bound () const
 Gets the bound value of the best solution. More...
 
std::string get_bound_str () const
 Gets the bound value of the best solution as a string. More...
 
std::optional< double > set_if_better (const qbpp::Sol &new_sol, const std::string &solver) override
 Sets new_sol as the best solution if it is better than the current best solution. More...
 
virtual std::optional< qbpp::Solget_if_better (energy_t my_energy)
 
std::optional< qbpp::Solget_if_better (const Sol &my_sol)
 
std::tuple< Sol, double, std::string > get_sol_tts_solver () const
 
vindex_t var_count () const
 
energy_t get_energy () const
 
const Solget_sol () const
 
Sol copy_sol () const
 
void clear ()
 
double get_tts () const
 
std::string get_solver () const
 
void set_bound (energy_t bound)
 
 operator Sol () const
 

Protected Attributes

Sol sol_
 
std::optional< energy_tbound_ = std::nullopt
 
double startx_ = get_time()
 
double tts_ {0.0}
 
std::string solver_ = "N/A"
 
std::mutex mtx_
 

Private Attributes

const bool factorization_mode = true
 True if factorization, false if multiplication. More...
 
const bool fix_lsb = false
 True if the MSBs and LSBs of x, y, and z are fixed. More...
 
const qbpp::Vector< qbpp::Var > & var_x
 The vector of Var. More...
 
const qbpp::Vector< qbpp::Var > & var_y
 The vector of Var. More...
 
const qbpp::Vector< qbpp::Var > & var_z
 The vector of Var. More...
 
std::optional< int64_t > bound = std::nullopt
 The bound of the best solution found by Gurobi. More...
 
std::mutex mtx
 Mutex for thread safety in print function. More...
 

Detailed Description

Solution holder to store the best solution of factorization.

Note
Inherited from qbpp::SolHolder. Member variable "bound", which stores the bound of the best solution found by Gurobi, is added.

Definition at line 102 of file factorization.cpp.

Constructor & Destructor Documentation

◆ SolHolder() [1/3]

qbpp::factorization::SolHolder::SolHolder ( const qbpp::QuadModel quad_model,
bool  fix_lsb,
const qbpp::Vector< qbpp::Var > &  var_x,
const qbpp::Vector< qbpp::Var > &  var_y 
)
inline

Constructor with a quad_model.

Parameters
quad_modelThe QUBO quad_model.
fix_lsbTrue if the LSBs of x and y are fixed to 1.
var_xThe vector of Var.
var_yThe vector of Var.

Definition at line 124 of file factorization.cpp.

◆ SolHolder() [2/3]

qbpp::factorization::SolHolder::SolHolder ( const qbpp::QuadModel quad_model,
bool  fix_lsb,
const qbpp::Vector< qbpp::Var > &  var_z 
)
inline

Constructor with a quad_model.

Parameters
quad_modelThe QUBO quad_model.
fix_lsbTrue if the LSBs of z are fixed to 1.
var_zThe vector of Var.

Definition at line 137 of file factorization.cpp.

◆ SolHolder() [3/3]

qbpp::factorization::SolHolder::SolHolder ( const SolHolder sol_holder)
default

Member Function Documentation

◆ set_bound() [1/2]

void qbpp::factorization::SolHolder::set_bound ( int64_t  bound)
inline

Sets the bound value of the best solution.

Parameters
boundThe bound value.

Definition at line 150 of file factorization.cpp.

◆ get_bound()

std::optional<int64_t> qbpp::factorization::SolHolder::get_bound ( ) const
inline

Gets the bound value of the best solution.

Returns
int64_t The bound value.

Definition at line 154 of file factorization.cpp.

◆ get_bound_str()

std::string qbpp::factorization::SolHolder::get_bound_str ( ) const
inline

Gets the bound value of the best solution as a string.

Returns
std::string The bound value as a string.

Definition at line 158 of file factorization.cpp.

Here is the caller graph for this function:

◆ set_if_better()

std::optional<double> qbpp::factorization::SolHolder::set_if_better ( const qbpp::Sol new_sol,
const std::string &  solver 
)
inlineoverridevirtual

Sets new_sol as the best solution if it is better than the current best solution.

Parameters
new_solThe new solution.
solverThe solver name.
Returns
std::optional<std::chrono::milliseconds> The time to solution if the current best solution is updated by new_sol.

Reimplemented from qbpp::SolHolder.

Definition at line 172 of file factorization.cpp.

Here is the call graph for this function:

◆ get_if_better() [1/2]

virtual std::optional<qbpp::Sol> qbpp::SolHolder::get_if_better ( energy_t  my_energy)
inlinevirtualinherited

Definition at line 1616 of file qbpp.hpp.

Here is the call graph for this function:

◆ get_if_better() [2/2]

std::optional<qbpp::Sol> qbpp::SolHolder::get_if_better ( const Sol my_sol)
inlineinherited

Definition at line 1626 of file qbpp.hpp.

Here is the call graph for this function:

◆ get_sol_tts_solver()

std::tuple<Sol, double, std::string> qbpp::SolHolder::get_sol_tts_solver ( ) const
inlineinherited

Definition at line 1630 of file qbpp.hpp.

◆ var_count()

vindex_t qbpp::SolHolder::var_count ( ) const
inlineinherited

Definition at line 1635 of file qbpp.hpp.

Here is the call graph for this function:

◆ get_energy()

energy_t qbpp::SolHolder::get_energy ( ) const
inlineinherited

Definition at line 1637 of file qbpp.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_sol()

const Sol& qbpp::SolHolder::get_sol ( ) const
inlineinherited

Definition at line 1639 of file qbpp.hpp.

Here is the caller graph for this function:

◆ copy_sol()

Sol qbpp::SolHolder::copy_sol ( ) const
inlineinherited

Definition at line 1641 of file qbpp.hpp.

Here is the caller graph for this function:

◆ clear()

void qbpp::SolHolder::clear ( )
inlineinherited

Definition at line 1646 of file qbpp.hpp.

Here is the call graph for this function:

◆ get_tts()

double qbpp::SolHolder::get_tts ( ) const
inlineinherited

Definition at line 1653 of file qbpp.hpp.

Here is the caller graph for this function:

◆ get_solver()

std::string qbpp::SolHolder::get_solver ( ) const
inlineinherited

Definition at line 1655 of file qbpp.hpp.

Here is the caller graph for this function:

◆ set_bound() [2/2]

void qbpp::SolHolder::set_bound ( energy_t  bound)
inlineinherited

Definition at line 1657 of file qbpp.hpp.

◆ operator Sol()

qbpp::SolHolder::operator Sol ( ) const
inlineinherited

Definition at line 1661 of file qbpp.hpp.

Member Data Documentation

◆ factorization_mode

const bool qbpp::factorization::SolHolder::factorization_mode = true
private

True if factorization, false if multiplication.

Definition at line 104 of file factorization.cpp.

◆ fix_lsb

const bool qbpp::factorization::SolHolder::fix_lsb = false
private

True if the MSBs and LSBs of x, y, and z are fixed.

Definition at line 106 of file factorization.cpp.

◆ var_x

const qbpp::Vector<qbpp::Var>& qbpp::factorization::SolHolder::var_x
private

The vector of Var.

Definition at line 108 of file factorization.cpp.

◆ var_y

const qbpp::Vector<qbpp::Var>& qbpp::factorization::SolHolder::var_y
private

The vector of Var.

Definition at line 110 of file factorization.cpp.

◆ var_z

const qbpp::Vector<qbpp::Var>& qbpp::factorization::SolHolder::var_z
private

The vector of Var.

Definition at line 112 of file factorization.cpp.

◆ bound

std::optional<int64_t> qbpp::factorization::SolHolder::bound = std::nullopt
private

The bound of the best solution found by Gurobi.

Definition at line 114 of file factorization.cpp.

◆ mtx

std::mutex qbpp::factorization::SolHolder::mtx
mutableprivate

Mutex for thread safety in print function.

Definition at line 116 of file factorization.cpp.

◆ sol_

Sol qbpp::SolHolder::sol_
protectedinherited

Definition at line 1584 of file qbpp.hpp.

◆ bound_

std::optional<energy_t> qbpp::SolHolder::bound_ = std::nullopt
protectedinherited

Definition at line 1585 of file qbpp.hpp.

◆ startx_

double qbpp::SolHolder::startx_ = get_time()
protectedinherited

Definition at line 1586 of file qbpp.hpp.

◆ tts_

double qbpp::SolHolder::tts_ {0.0}
protectedinherited

Definition at line 1587 of file qbpp.hpp.

◆ solver_

std::string qbpp::SolHolder::solver_ = "N/A"
protectedinherited

Definition at line 1588 of file qbpp.hpp.

◆ mtx_

std::mutex qbpp::SolHolder::mtx_
mutableprotectedinherited

Definition at line 1589 of file qbpp.hpp.


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