MinLCA algorithms
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
lemon::GrbBase Class Reference

Base interface for the Gurobi LP and MIP solver. More...

#include <grb.h>

Inheritance diagram for lemon::GrbBase:
[legend]
Collaboration diagram for lemon::GrbBase:
[legend]

Public Member Functions

GRBEnv getEnv () const
 Get the environment of the underlying Gurobi model.
 
GRBEnv getEnv ()
 Get the environment of the underlying Gurobi model.
 
GRBModel & getModel ()
 Get the underlying Gurobi model.
 
void writeCompressed (std::string filename, std::string format="")
 Output model in compressed format. More...
 
void forceModelUpdate ()
 Force model update. More...
 

Static Public Member Functions

static GRBEnv getDefaultEnv ()
 Get default Gurobi environment. More...
 

Protected Member Functions

 GrbBase (const GRBEnv &env=_defEnv)
 Default constructor. More...
 
void _updateModel (bool what)
 
void _copyExprToConstr (int row)
 
void _copyExprToConstr ()
 
virtual int _addCol ()
 
 
virtual int _addRow ()
 
 
virtual int _addRow (Value l, ExprIterator b, ExprIterator e, Value u)
 
 
virtual void _eraseCol (int i)
 
 
virtual void _eraseRow (int i)
 
 
virtual void _getColName (int col, std::string &name) const
 
 
virtual void _setColName (int col, const std::string &name)
 
 
virtual int _colByName (const std::string &name) const
 
 
virtual void _getRowName (int row, std::string &name) const
 
 
virtual void _setRowName (int row, const std::string &name)
 
 
virtual int _rowByName (const std::string &name) const
 
 
virtual void _setRowCoeffs (int row, ExprIterator b, ExprIterator e)
 
 
virtual void _getRowCoeffs (int row, InsertIterator b) const
 
 
virtual void _setColCoeffs (int col, ExprIterator b, ExprIterator e)
 
 
virtual void _getColCoeffs (int col, InsertIterator b) const
 
 
virtual void _setCoeff (int row, int col, Value value)
 Set one element of the coefficient matrix.
 
virtual Value _getCoeff (int row, int col) const
 Get one element of the coefficient matrix.
 
virtual void _setColLowerBound (int i, Value value)
 
virtual Value _getColLowerBound (int i) const
  More...
 
virtual void _setColUpperBound (int i, Value value)
 
virtual Value _getColUpperBound (int i) const
  More...
 
virtual void _setRowLowerBound (int i, Value value)
 
virtual Value _getRowLowerBound (int i) const
  More...
 
virtual void _setRowUpperBound (int i, Value value)
 
virtual Value _getRowUpperBound (int i) const
  More...
 
virtual void _setObjCoeffs (ExprIterator b, ExprIterator e)
 
 
virtual void _getObjCoeffs (InsertIterator b) const
 
 
virtual void _setObjCoeff (int i, Value obj_coef)
 
 
virtual Value _getObjCoeff (int i) const
 
 
virtual void _setSense (Sense)
 
 
virtual Sense _getSense () const
 
 
virtual void _clear ()
 
 
virtual void _messageLevel (MessageLevel)
 
 
virtual void _write (std::string file, std::string format) const
 Write model to file (disabled)
 

Protected Attributes

GRBModel _model
 Underlying Gurobi model.
 
bool _dirtyVars
 Dirty bit for variables.
 
bool _dirtyConstrs
 Dirty bit for constraints.
 
GRBEnv _env
 Gurobi environment for the model.
 
std::map< std::string, int > _varNameToId
 Map variable names to id.
 
std::vector< GRBVar > _idToVar
 Map id to variables.
 
std::vector< std::string > _idToVarName
 Map variable id to names.
 
std::vector< bool > _deletedVars
 List of deleted variables.
 
std::vector< GRBLinExpr > _idToExpr
 Linear expression of each constraint.
 
std::vector< bool > _exprCopiedToConstr
 
std::map< std::string, int > _constrNameToId
 Map constraint names to id.
 
std::vector< GRBConstr > _idToConstr
 Map id to constraints.
 
std::vector< std::string > _idToConstrName
 Map constraint id to names.
 
std::vector< GRBVar > _constrAux
 Needed because LEMON allows constraints with both upper and lower bounds.
 
std::vector< bool > _deletedConstrs
 List of deleted variables.
 

Static Protected Attributes

static GRBEnv _defEnv = GRBEnv()
 Default Gurobi environment.
 

Detailed Description

Base interface for the Gurobi LP and MIP solver.

This class implements the common interface of the Gurobi LP and MIP solver.

Warning
We recommend creating all variables before adding the constraints. Before adding the constraints, and also before solving the model, please update it using forceModelUpdate(). See minlca/lp-model.hh for an example.

Definition at line 48 of file grb.h.

Constructor & Destructor Documentation

lemon::GrbBase::GrbBase ( const GRBEnv &  env = _defEnv)
protected

Default constructor.

Allows building a model using a custom environment. If the environment is not set by the user, it uses the default one, from getDefaultEnv()

See also
getDefaultEnv()

Definition at line 34 of file grb.cc.

Member Function Documentation

GrbBase::Value lemon::GrbBase::_getColLowerBound ( int  i) const
protectedvirtual

The lower bound of a variable (column) is an extended number of type Value, i.e. a finite number of type Value or -INF.

Definition at line 260 of file grb.cc.

GrbBase::Value lemon::GrbBase::_getColUpperBound ( int  i) const
protectedvirtual

The upper bound of a variable (column) is an extended number of type Value, i.e. a finite number of type Value or INF.

Definition at line 270 of file grb.cc.

GrbBase::Value lemon::GrbBase::_getRowLowerBound ( int  i) const
protectedvirtual

The lower bound of a constraint (row) is an extended number of type Value, i.e. a finite number of type Value or -INF.

Definition at line 280 of file grb.cc.

GrbBase::Value lemon::GrbBase::_getRowUpperBound ( int  i) const
protectedvirtual

The upper bound of a constraint (row) is an extended number of type Value, i.e. a finite number of type Value or INF.

Definition at line 290 of file grb.cc.

void lemon::GrbBase::_setColLowerBound ( int  i,
Value  value 
)
protectedvirtual

The lower bound of a variable (column) have to be given by an extended number of type Value, i.e. a finite number of type Value or -INF.

Definition at line 255 of file grb.cc.

void lemon::GrbBase::_setColUpperBound ( int  i,
Value  value 
)
protectedvirtual

The upper bound of a variable (column) have to be given by an extended number of type Value, i.e. a finite number of type Value or INF.

Definition at line 265 of file grb.cc.

void lemon::GrbBase::_setRowLowerBound ( int  i,
Value  value 
)
protectedvirtual

The lower bound of a constraint (row) have to be given by an extended number of type Value, i.e. a finite number of type Value or -INF.

Definition at line 275 of file grb.cc.

void lemon::GrbBase::_setRowUpperBound ( int  i,
Value  value 
)
protectedvirtual

The upper bound of a constraint (row) have to be given by an extended number of type Value, i.e. a finite number of type Value or INF.

Definition at line 285 of file grb.cc.

void lemon::GrbBase::forceModelUpdate ( )

Force model update.

Forces Gurobi to update the model, due to its asyncronous working model.

Warning
Try to use it only after adding all variables and also after adding all constraints. Updating the model can have a very bad impact on the execution time when used too often.

Definition at line 71 of file grb.cc.

GRBEnv lemon::GrbBase::getDefaultEnv ( )
static

Get default Gurobi environment.

The default Gurobi environment is used when creating new models.

Definition at line 40 of file grb.cc.

void lemon::GrbBase::writeCompressed ( std::string  filename,
std::string  format = "" 
)

Output model in compressed format.

Write model in compressed format, using one of Gurobi's allowed formats.

Definition at line 368 of file grb.cc.


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