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

Class to store a QUBO model using Gurobi Optimizer through QUBO++ library. More...

#include <qbpp_grb.hpp>

Inheritance diagram for qbpp_grb::QuadModel:
Inheritance graph
[legend]
Collaboration diagram for qbpp_grb::QuadModel:
Collaboration graph
[legend]

Public Member Functions

 QuadModel (const qbpp::QuadModel &quad_model, bool verbose=false)
 Constructor to create a model from QuadModel object. More...
 
 QuadModel (const QuadModel &grb_model)=default
 Copy constructor to create a model from another model. More...
 
void set (const std::string &key, const std::string &val)
 Sets a parameter to the Gurobi environment. More...
 
void set_time_limit (uint32_t time_limit)
 Sets time limit to the Gurobi model. More...
 
void set (Callback &cb)
 Set a callback function to the Gurobi model. More...
 
GRBVar get_grb_var (int index) const
 Get the Gurobi variable from the index. More...
 
GRBModel & get_grb_model ()
 Get the Gurobi model. More...
 
const GRBModel & get_grb_model () const
 Get the Gurobi model. More...
 
void write (std::string filename)
 Write the model to a file. More...
 
const std::vector< coeff_t > & get_linear () const
 
coeff_t get_linear (vindex_t index) const
 
const std::vector< vindex_t > & get_degree () const
 
vindex_t get_degree (vindex_t index) const
 
const std::vector< std::vector< std::pair< vindex_t, coeff_t > > > & get_quadratic () const
 
std::pair< vindex_t, coeff_t > get_quadratic (vindex_t i, vindex_t j) const
 
size_t term_count (vindex_t deg) const
 
size_t term_count () const override
 
coeff_t get_min_coeff () const
 
coeff_t get_max_coeff () const
 
vindex_t var_count () const
 
Var get_var (vindex_t index) const
 
vindex_t get_index (Var var) const
 
bool has (Var var) const
 
const Expr & get_expr () const
 
 operator const Expr & () const
 
energy_t get_constant () const
 
const Terms & get_terms () const
 
std::vector< Var > get_index_var () const
 
Sol optimize ()
 Optimize the QUBO model. More...
 

Static Protected Member Functions

static const Expr & check_expr (const Expr &expr)
 
static Expr check_expr (Expr &&expr)
 

Protected Attributes

GRBEnv grb_env
 Gurobi environment. More...
 
std::shared_ptr< GRBModel > grb_model_ptr
 Gurobi model. More...
 
GRBVar * grb_x
 Pointer to Gurobi variables. More...
 
const std::shared_ptr< const Expr > expr_ptr_
 
const std::shared_ptr< const impl::IndexVarMapper > index_var_ptr_
 

Private Attributes

const std::shared_ptr< const Implpimpl_
 
const std::vector< coeff_t > & linear_
 
const std::vector< vindex_t > & degree_
 
const std::vector< std::vector< std::pair< vindex_t, coeff_t > > > & quadratic_
 

Detailed Description

Class to store a QUBO model using Gurobi Optimizer through QUBO++ library.

This class is used to store a QUBO model and solve it using Gurobi Optimizer through QUBO++ library.

Definition at line 42 of file qbpp_grb.hpp.

Member Function Documentation

◆ get_grb_var()

GRBVar qbpp_grb::QuadModel::get_grb_var ( int  index) const
inline

Get the Gurobi variable from the index.

Parameters
indexindex of the variable from 0 to size()-1
Returns
Gurobi variable

Definition at line 92 of file qbpp_grb.hpp.

Here is the caller graph for this function:

◆ get_grb_model() [1/2]

GRBModel& qbpp_grb::QuadModel::get_grb_model ( )
inline

Get the Gurobi model.

Returns
Gurobi model

Definition at line 96 of file qbpp_grb.hpp.

◆ get_grb_model() [2/2]

const GRBModel& qbpp_grb::QuadModel::get_grb_model ( ) const
inline

Get the Gurobi model.

Returns
Gurobi model

Definition at line 100 of file qbpp_grb.hpp.

◆ optimize()

Sol qbpp_grb::QuadModel::optimize ( )
inline

Optimize the QUBO model.

Returns
Solution of the QUBO model

Definition at line 260 of file qbpp_grb.hpp.

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

◆ write()

void qbpp_grb::QuadModel::write ( std::string  filename)
inline

Write the model to a file.

Parameters
filenameFile name

The model is written in the LP format. The format type is determined by the file extension such as .lp and .mps.

Definition at line 112 of file qbpp_grb.hpp.

◆ get_linear() [1/2]

const std::vector<coeff_t>& qbpp::QuadModel::get_linear ( ) const
inlineinherited

Definition at line 1241 of file qbpp.hpp.

Here is the caller graph for this function:

◆ get_linear() [2/2]

coeff_t qbpp::QuadModel::get_linear ( vindex_t  index) const
inlineinherited

Definition at line 1250 of file qbpp.hpp.

◆ get_degree() [1/2]

const std::vector<vindex_t>& qbpp::QuadModel::get_degree ( ) const
inlineinherited

Definition at line 1243 of file qbpp.hpp.

Here is the caller graph for this function:

◆ get_degree() [2/2]

vindex_t qbpp::QuadModel::get_degree ( vindex_t  index) const
inlineinherited

Definition at line 1252 of file qbpp.hpp.

◆ get_quadratic() [1/2]

const std::vector<std::vector<std::pair<vindex_t, coeff_t> > >& qbpp::QuadModel::get_quadratic ( ) const
inlineinherited

Definition at line 1245 of file qbpp.hpp.

Here is the caller graph for this function:

◆ get_quadratic() [2/2]

std::pair<vindex_t, coeff_t> qbpp::QuadModel::get_quadratic ( vindex_t  i,
vindex_t  j 
) const
inlineinherited

Definition at line 1254 of file qbpp.hpp.

◆ term_count() [1/2]

size_t qbpp::QuadModel::term_count ( vindex_t  deg) const
inlineinherited

Definition at line 1258 of file qbpp.hpp.

Here is the caller graph for this function:

◆ term_count() [2/2]

size_t qbpp::QuadModel::term_count ( ) const
inlineoverridevirtualinherited

Reimplemented from qbpp::Model.

Definition at line 1268 of file qbpp.hpp.

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

◆ get_min_coeff()

coeff_t qbpp::QuadModel::get_min_coeff ( ) const
inlineinherited

Definition at line 1270 of file qbpp.hpp.

Here is the caller graph for this function:

◆ get_max_coeff()

coeff_t qbpp::QuadModel::get_max_coeff ( ) const
inlineinherited

Definition at line 1272 of file qbpp.hpp.

Here is the caller graph for this function:

◆ check_expr() [1/2]

static const Expr& qbpp::Model::check_expr ( const Expr expr)
inlinestaticprotectedinherited

Definition at line 1111 of file qbpp.hpp.

Here is the call graph for this function:

◆ check_expr() [2/2]

static Expr qbpp::Model::check_expr ( Expr &&  expr)
inlinestaticprotectedinherited

Definition at line 1120 of file qbpp.hpp.

Here is the call graph for this function:

◆ var_count()

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

Definition at line 1154 of file qbpp.hpp.

Here is the caller graph for this function:

◆ get_var()

Var qbpp::Model::get_var ( vindex_t  index) const
inlineinherited

Definition at line 1156 of file qbpp.hpp.

Here is the caller graph for this function:

◆ get_index()

vindex_t qbpp::Model::get_index ( Var  var) const
inlineinherited

Definition at line 1158 of file qbpp.hpp.

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

◆ has()

bool qbpp::Model::has ( Var  var) const
inlineinherited

Definition at line 1160 of file qbpp.hpp.

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

◆ get_expr()

const Expr& qbpp::Model::get_expr ( ) const
inlineinherited

Definition at line 1164 of file qbpp.hpp.

Here is the caller graph for this function:

◆ operator const Expr &()

qbpp::Model::operator const Expr & ( ) const
inlineinherited

Definition at line 1166 of file qbpp.hpp.

◆ get_constant()

energy_t qbpp::Model::get_constant ( ) const
inlineinherited

Definition at line 1168 of file qbpp.hpp.

Here is the caller graph for this function:

◆ get_terms()

const Terms& qbpp::Model::get_terms ( ) const
inlineinherited

Definition at line 1170 of file qbpp.hpp.

◆ get_index_var()

std::vector<Var> qbpp::Model::get_index_var ( ) const
inlineinherited

Definition at line 1172 of file qbpp.hpp.

Here is the caller graph for this function:

Member Data Documentation

◆ grb_env

GRBEnv qbpp_grb::QuadModel::grb_env
protected

Gurobi environment.

Definition at line 45 of file qbpp_grb.hpp.

◆ grb_model_ptr

std::shared_ptr<GRBModel> qbpp_grb::QuadModel::grb_model_ptr
protected

Gurobi model.

Definition at line 47 of file qbpp_grb.hpp.

◆ grb_x

GRBVar* qbpp_grb::QuadModel::grb_x
protected

Pointer to Gurobi variables.

Definition at line 49 of file qbpp_grb.hpp.

◆ pimpl_

const std::shared_ptr<const Impl> qbpp::QuadModel::pimpl_
privateinherited

Definition at line 1195 of file qbpp.hpp.

◆ linear_

const std::vector<coeff_t>& qbpp::QuadModel::linear_
privateinherited

Definition at line 1197 of file qbpp.hpp.

◆ degree_

const std::vector<vindex_t>& qbpp::QuadModel::degree_
privateinherited

Definition at line 1199 of file qbpp.hpp.

◆ quadratic_

const std::vector<std::vector<std::pair<vindex_t, coeff_t> > >& qbpp::QuadModel::quadratic_
privateinherited

Definition at line 1201 of file qbpp.hpp.

◆ expr_ptr_

const std::shared_ptr<const Expr> qbpp::Model::expr_ptr_
protectedinherited

Definition at line 1107 of file qbpp.hpp.

◆ index_var_ptr_

const std::shared_ptr<const impl::IndexVarMapper> qbpp::Model::index_var_ptr_
protectedinherited

Definition at line 1109 of file qbpp.hpp.


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