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
GRB_Callback Class Reference

Class to define Gurobi callback function for factorization. More...

Inheritance diagram for GRB_Callback:
Inheritance graph
[legend]
Collaboration diagram for GRB_Callback:
Collaboration graph
[legend]

Public Member Functions

 GRB_Callback (const qbpp::tsp::TSPQuadModel &tsp_quad_model, qbpp::energy_t target_energy)
 Construct a new grb callback object. More...
 
void callback () override
 callback function for Gurobi optimizer. More...
 
Sol get_sol ()
 Get the solution obtained by 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::mutex mtx
 Mutex to lock the critical section in get_sol() More...
 

Private Attributes

const qbpp::tsp::TSPQuadModeltsp_quad_model
 
std::optional< qbpp::energy_ttarget_energy
 

Detailed Description

Class to define Gurobi callback function for factorization.

Note
This Gurobi callback inherits from qbpp_grb::Callback.

Definition at line 18 of file tsp_grb.cpp.

Constructor & Destructor Documentation

◆ GRB_Callback()

GRB_Callback::GRB_Callback ( const qbpp::tsp::TSPQuadModel tsp_quad_model,
qbpp::energy_t  target_energy 
)
inline

Construct a new grb callback object.

Parameters
tsp_quad_modelThe TSP expression.
target_energyThe target energy.

Definition at line 26 of file tsp_grb.cpp.

Member Function Documentation

◆ callback()

void GRB_Callback::callback ( )
inlineoverridevirtual

callback function for Gurobi optimizer.

The callback function is called by the Gurobi optimizer for every event. It displays the solution of the TSP when a new best solution obtained.

Reimplemented from qbpp_grb::Callback.

Definition at line 36 of file tsp_grb.cpp.

Here is the call graph for this function:

◆ get_sol()

Sol qbpp_grb::Callback::get_sol ( )
inlineinherited

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:

◆ set_target_energy()

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

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)
inlineinherited

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)
inlineinherited

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)
inlineinherited

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

◆ tsp_quad_model

const qbpp::tsp::TSPQuadModel& GRB_Callback::tsp_quad_model
private

Definition at line 19 of file tsp_grb.cpp.

◆ target_energy

std::optional<qbpp::energy_t> GRB_Callback::target_energy
private

Definition at line 20 of file tsp_grb.cpp.

◆ quad_model

const QuadModel qbpp_grb::Callback::quad_model
protectedinherited

QUBO model.

Definition at line 152 of file qbpp_grb.hpp.

◆ grb_model

const GRBModel& qbpp_grb::Callback::grb_model
protectedinherited

Shortcut to the GRBModel in QuadModel.

Definition at line 155 of file qbpp_grb.hpp.

◆ mtx

std::mutex qbpp_grb::Callback::mtx
mutableprotectedinherited

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: