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

Class to manage a callback function called by Gurobi Optimizer. More...

#include <qbpp_grb.hpp>

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

Public Member Functions

 Callback (const QuadModel &quad_model)
 Constructor: a new Callback object. More...
 
virtual ~Callback ()=default
 
Sol get_sol ()
 Get the solution obtained by Gurobi Optimizer. More...
 
virtual void callback () override
 Default callback function for Gurobi Optimizer. More...
 
void set_target_energy (qbpp::energy_t target_energy)
 Set the target energy for Gurobi Optimizer. More...
 
void abort_if_target_energy (qbpp::energy_t energy)
 Abort the optimization process if the target energy is achieved. More...
 
double getDoubleInfoPublic (int what)
 Calls GetDoubleInfo() of GRBCallback. More...
 
double getSolutionPublic (GRBVar v)
 Calls getSolution() of GRBCallback. More...
 

Protected Attributes

const QuadModel quad_model
 QUBO model. More...
 
const GRBModel & grb_model
 Shortcut to the GRBModel in QuadModel. More...
 
std::optional< qbpp::energy_ttarget_energy = std::nullopt
 Target energy to stop the Gurobi optimizer. More...
 
std::mutex mtx
 Mutex to lock the critical section in get_sol() More...
 

Detailed Description

Class to manage a callback function called by Gurobi Optimizer.

This class is used to manage a callback function for Gurobi Optimizer through QUBO++ library.

Definition at line 149 of file qbpp_grb.hpp.

Constructor & Destructor Documentation

◆ Callback()

qbpp_grb::Callback::Callback ( const QuadModel quad_model)
inline

Constructor: a new Callback object.

Parameters
quad_modelQUBO model of QUBO++ library

Definition at line 169 of file qbpp_grb.hpp.

Here is the call graph for this function:

◆ ~Callback()

virtual qbpp_grb::Callback::~Callback ( )
virtualdefault

Member Function Documentation

◆ get_sol()

Sol qbpp_grb::Callback::get_sol ( )
inline

Get the solution obtained by Gurobi Optimizer.

Returns
Solution by Gurobi Optimizer

Definition at line 274 of file qbpp_grb.hpp.

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

◆ callback()

virtual void qbpp_grb::Callback::callback ( )
inlineoverridevirtual

Default callback function for Gurobi Optimizer.

This function is called during the optimization process of Gurobi Optimizer. The function can be customized by overriding it.

Reimplemented in GRB_Callback, and qbpp::factorization::GRB_Callback.

Definition at line 183 of file qbpp_grb.hpp.

Here is the call graph for this function:

◆ set_target_energy()

void qbpp_grb::Callback::set_target_energy ( qbpp::energy_t  target_energy)
inline

Set the target energy for Gurobi Optimizer.

Definition at line 194 of file qbpp_grb.hpp.

◆ abort_if_target_energy()

void qbpp_grb::Callback::abort_if_target_energy ( qbpp::energy_t  energy)
inline

Abort the optimization process if the target energy is achieved.

Parameters
energyEnergy of the current solution

This function is intended to be called in callback() function.

Definition at line 201 of file qbpp_grb.hpp.

Here is the caller graph for this function:

◆ getDoubleInfoPublic()

double qbpp_grb::Callback::getDoubleInfoPublic ( int  what)
inline

Calls GetDoubleInfo() of GRBCallback.

Parameters
whatwhat to get
Returns
double value

Definition at line 210 of file qbpp_grb.hpp.

Here is the caller graph for this function:

◆ getSolutionPublic()

double qbpp_grb::Callback::getSolutionPublic ( GRBVar  v)
inline

Calls getSolution() of GRBCallback.

Parameters
vGurobi variable
Returns
double value

Definition at line 215 of file qbpp_grb.hpp.

Here is the caller graph for this function:

Member Data Documentation

◆ quad_model

const QuadModel qbpp_grb::Callback::quad_model
protected

QUBO model.

Definition at line 152 of file qbpp_grb.hpp.

◆ grb_model

const GRBModel& qbpp_grb::Callback::grb_model
protected

Shortcut to the GRBModel in QuadModel.

Definition at line 155 of file qbpp_grb.hpp.

◆ target_energy

std::optional<qbpp::energy_t> qbpp_grb::Callback::target_energy = std::nullopt
protected

Target energy to stop the Gurobi optimizer.

Definition at line 158 of file qbpp_grb.hpp.

◆ mtx

std::mutex qbpp_grb::Callback::mtx
mutableprotected

Mutex to lock the critical section in get_sol()

Definition at line 164 of file qbpp_grb.hpp.


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