Detailed Description
LP interface for Gurobi.
This LPI only works with Gurobi versions >= 7.0.2.
Definition in file lpi_grb.c.
#include <assert.h>
#include <string.h>
#include "gurobi_c.h"
#include "lpi/lpi.h"
#include "scip/pub_message.h"
#include "scip/pub_misc_sort.h"
#include "tinycthread/tinycthread.h"
Go to the source code of this file.
Data Structures | |
struct | SCIP_LPi |
struct | SCIP_LPiState |
struct | SCIP_LPiNorms |
Macros | |
#define | SCIP_REUSEENV |
#define | CHECK_ZERO(messagehdlr, x) |
#define | CHECK_ZERO_STAR(messagehdlr, x) |
#define | SVECTOR GRBsvec |
#define | SCIP_DUALPACKETSIZE (sizeof(SCIP_DUALPACKET)*4) |
#define | COLS_PER_PACKET SCIP_DUALPACKETSIZE |
#define | ROWS_PER_PACKET SCIP_DUALPACKETSIZE |
#define | GRB_REFACTORMAXITERS 50 |
#define | NUMINTPARAM 6 |
#define | NUMDBLPARAM 7 |
Typedefs | |
typedef unsigned int | SCIP_DUALPACKET |
typedef SCIP_DUALPACKET | COLPACKET |
typedef SCIP_DUALPACKET | ROWPACKET |
typedef struct GRBParam | GRBPARAM |
Variables | |
static GRBenv * | reusegrbenv = NULL |
static int | numlp = 0 |
static const char * | intparam [NUMINTPARAM] |
static const char * | dblparam [NUMDBLPARAM] |
static const double | dblparammin [NUMDBLPARAM] |
static const char | grbname [] |
Macro Definition Documentation
◆ SCIP_REUSEENV
◆ CHECK_ZERO
#define CHECK_ZERO | ( | messagehdlr, | |
x | |||
) |
Definition at line 71 of file lpi_grb.c.
Referenced by addRangeVars(), delRangeVars(), getBase(), getParameterValues(), lpiStrongbranch(), restoreLPData(), SCIPlpiAddCols(), SCIPlpiAddRows(), SCIPlpiChgBounds(), SCIPlpiChgCoef(), SCIPlpiChgObj(), SCIPlpiChgObjsen(), SCIPlpiChgSides(), SCIPlpiClear(), SCIPlpiClearState(), SCIPlpiDelCols(), SCIPlpiDelColset(), SCIPlpiDelRows(), SCIPlpiDelRowset(), SCIPlpiGetBase(), SCIPlpiGetBasisInd(), SCIPlpiGetBInvACol(), SCIPlpiGetBInvARow(), SCIPlpiGetBInvCol(), SCIPlpiGetBInvRow(), SCIPlpiGetBounds(), SCIPlpiGetCoef(), SCIPlpiGetCols(), SCIPlpiGetDualfarkas(), SCIPlpiGetNCols(), SCIPlpiGetNNonz(), SCIPlpiGetNorms(), SCIPlpiGetNRows(), SCIPlpiGetObj(), SCIPlpiGetObjsen(), SCIPlpiGetPrimalRay(), SCIPlpiGetRows(), SCIPlpiGetSides(), SCIPlpiGetSol(), SCIPlpiLoadColLP(), SCIPlpiReadLP(), SCIPlpiReadState(), SCIPlpiSetBase(), SCIPlpiSetState(), SCIPlpiSolveBarrier(), SCIPlpiSolveDual(), SCIPlpiSolvePrimal(), SCIPlpiWriteLP(), SCIPlpiWriteState(), setBase(), and setParameterValues().
◆ CHECK_ZERO_STAR
#define CHECK_ZERO_STAR | ( | messagehdlr, | |
x | |||
) |
Definition at line 80 of file lpi_grb.c.
Referenced by SCIPlpiCreate(), and SCIPlpiFree().
◆ SVECTOR
#define SVECTOR GRBsvec |
Definition at line 89 of file lpi_grb.c.
Referenced by SCIPlpiGetBInvACol(), SCIPlpiGetBInvARow(), SCIPlpiGetBInvCol(), and SCIPlpiGetBInvRow().
◆ SCIP_DUALPACKETSIZE
#define SCIP_DUALPACKETSIZE (sizeof(SCIP_DUALPACKET)*4) |
each entry needs two bits of information
Definition at line 93 of file lpi_grb.c.
Referenced by SCIPdecodeDualBitNeg(), and SCIPencodeDualBitNeg().
◆ COLS_PER_PACKET
#define COLS_PER_PACKET SCIP_DUALPACKETSIZE |
Definition at line 96 of file lpi_grb.c.
Referenced by colpacketNum().
◆ ROWS_PER_PACKET
#define ROWS_PER_PACKET SCIP_DUALPACKETSIZE |
Definition at line 98 of file lpi_grb.c.
Referenced by rowpacketNum().
◆ GRB_REFACTORMAXITERS
#define GRB_REFACTORMAXITERS 50 |
maximal number of iterations allowed for producing a refactorization of the basis
Definition at line 104 of file lpi_grb.c.
Referenced by restoreLPData().
◆ NUMINTPARAM
#define NUMINTPARAM 6 |
number of Gurobi integer parameters that can be changed
Definition at line 108 of file lpi_grb.c.
Referenced by checkParameterValues(), copyParameterValues(), getIntParam(), getParameterValues(), setIntParam(), and setParameterValues().
◆ NUMDBLPARAM
#define NUMDBLPARAM 7 |
number of Gurobi double parameters that can be changed
Definition at line 121 of file lpi_grb.c.
Referenced by checkParameterValues(), copyParameterValues(), getDblParam(), getParameterValues(), setDblParam(), and setParameterValues().
Typedef Documentation
◆ SCIP_DUALPACKET
typedef unsigned int SCIP_DUALPACKET |
◆ COLPACKET
typedef SCIP_DUALPACKET COLPACKET |
◆ ROWPACKET
typedef SCIP_DUALPACKET ROWPACKET |
◆ GRBPARAM
Function Documentation
◆ ensureSidechgMem()
|
static |
resizes senarray to have at least num entries
- Parameters
-
lpi LP interface structure num minimal number of entries in array
Definition at line 224 of file lpi_grb.c.
References BMSreallocMemoryArray, MAX, NULL, SCIP_LPi::rhsarray, SCIP_LPi::rngarray, SCIP_LPi::rngidxarray, SCIP_ALLOC, SCIP_OKAY, SCIP_LPi::senarray, and SCIP_LPi::sidechgsize.
Referenced by SCIPlpiAddRows(), SCIPlpiChgSides(), SCIPlpiGetBase(), SCIPlpiGetRows(), SCIPlpiGetSides(), SCIPlpiGetSol(), and SCIPlpiLoadColLP().
◆ ensureValMem()
|
static |
resizes valarray and indarray to have at least num entries
- Parameters
-
lpi LP interface structure num minimal number of entries in array
Definition at line 249 of file lpi_grb.c.
References BMSreallocMemoryArray, SCIP_LPi::indarray, MAX, NULL, SCIP_ALLOC, SCIP_OKAY, SCIP_LPi::valarray, and SCIP_LPi::valsize.
Referenced by SCIPlpiScaleCol(), and SCIPlpiScaleRow().
◆ ensureCstatMem()
|
static |
resizes cstat array to have at least num entries
- Parameters
-
lpi LP interface structure num minimal number of entries in array
Definition at line 272 of file lpi_grb.c.
References BMSreallocMemoryArray, SCIP_LPi::cstat, SCIP_LPi::cstatsize, MAX, NULL, SCIP_ALLOC, and SCIP_OKAY.
Referenced by getBase(), SCIPlpiSetBase(), and SCIPlpiSetState().
◆ ensureRstatMem()
|
static |
resizes rstat array to have at least num entries
- Parameters
-
lpi LP interface structure num minimal number of entries in array
Definition at line 294 of file lpi_grb.c.
References BMSreallocMemoryArray, MAX, NULL, SCIP_LPi::rstat, SCIP_LPi::rstatsize, SCIP_ALLOC, and SCIP_OKAY.
Referenced by getBase(), SCIPlpiSetBase(), and SCIPlpiSetState().
◆ ensureRngrowmapMem()
|
static |
resizes rngrowmap array to have at least num entries
- Parameters
-
lpi LP interface structure num minimal number of entries in array
Definition at line 316 of file lpi_grb.c.
References BMSreallocMemoryArray, MAX, NULL, r, SCIP_LPi::rngrowmap, SCIP_LPi::rngrowmapsize, SCIP_ALLOC, and SCIP_OKAY.
Referenced by addRangeInfo(), SCIPlpiAddRows(), and SCIPlpiChgSides().
◆ ensureRngrowsMem()
|
static |
resizes rngrows and rngvals arrays to have at least num entries
- Parameters
-
lpi LP interface structure num minimal number of entries in array
Definition at line 341 of file lpi_grb.c.
References BMSreallocMemoryArray, MAX, NULL, SCIP_LPi::rngrows, SCIP_LPi::rngrowssize, SCIP_LPi::rngvals, SCIP_ALLOC, and SCIP_OKAY.
Referenced by addRangeInfo(), and SCIPlpiChgSides().
◆ getBase()
|
static |
stores current basis in internal arrays of LPI data structure
- Parameters
-
lpi LP interface structure success whether basis information has successfully been obtained
Definition at line 364 of file lpi_grb.c.
References CHECK_ZERO, SCIP_LPi::cstat, ensureCstatMem(), ensureRstatMem(), FALSE, SCIP_LPi::grbenv, SCIP_LPi::grbmodel, SCIP_LPi::messagehdlr, NULL, SCIP_LPi::rstat, SCIP_CALL, SCIP_LPERROR, SCIP_OKAY, SCIPdebugMessage, SCIPerrorMessage, and TRUE.
Referenced by lpiStrongbranch(), and SCIPlpiGetState().
◆ setBase()
|
static |
loads basis stored in internal arrays of LPI data structure into Gurobi
- Parameters
-
lpi LP interface structure
Definition at line 422 of file lpi_grb.c.
References CHECK_ZERO, SCIP_LPi::cstat, SCIP_LPi::grbmodel, SCIP_LPi::messagehdlr, NULL, SCIP_LPi::rstat, SCIP_OKAY, and SCIPdebugMessage.
Referenced by lpiStrongbranch(), and SCIPlpiSetState().
◆ colpacketNum()
|
static |
returns the number of packets needed to store column packet information
- Parameters
-
ncols number of columns to store
Definition at line 455 of file lpi_grb.c.
References COLS_PER_PACKET.
Referenced by lpistateCreate(), and lpistateFree().
◆ rowpacketNum()
|
static |
returns the number of packets needed to store row packet information
- Parameters
-
nrows number of rows to store
Definition at line 464 of file lpi_grb.c.
References ROWS_PER_PACKET.
Referenced by lpistateCreate(), and lpistateFree().
◆ SCIPencodeDualBitNeg()
|
static |
encode a negated dual bit vector into packed format
- Parameters
-
inp unpacked input vector out buffer to store the packed vector count number of elements
Definition at line 476 of file lpi_grb.c.
References NULL, and SCIP_DUALPACKETSIZE.
Referenced by lpistatePack().
◆ SCIPdecodeDualBitNeg()
|
static |
decode a packed dual bit vector into negated unpacked format
- Parameters
-
inp packed input vector out buffer to store unpacked vector count number of elements
Definition at line 547 of file lpi_grb.c.
References NULL, and SCIP_DUALPACKETSIZE.
Referenced by lpistateUnpack().
◆ lpistatePack()
|
static |
store row and column basis status in a packed LPi state object
- Parameters
-
lpistate pointer to LPi state data cstat basis status of columns in unpacked format rstat basis status of rows in unpacked format
Definition at line 623 of file lpi_grb.c.
References SCIP_LPiState::ncols, SCIP_LPiState::nrngrows, SCIP_LPiState::nrows, NULL, SCIP_LPiState::packcstat, SCIP_LPiState::packrstat, and SCIPencodeDualBitNeg().
Referenced by SCIPlpiGetState().
◆ lpistateUnpack()
|
static |
unpacks row and column basis status from a packed LPi state object
- Parameters
-
lpistate pointer to LPi state data cstat buffer for storing basis status of columns in unpacked format rstat buffer for storing basis status of rows in unpacked format
Definition at line 639 of file lpi_grb.c.
References SCIP_LPiState::ncols, SCIP_LPiState::nrngrows, SCIP_LPiState::nrows, NULL, SCIP_LPiState::packcstat, SCIP_LPiState::packrstat, and SCIPdecodeDualBitNeg().
Referenced by SCIPlpiSetState().
◆ lpistateCreate()
|
static |
creates LPi state information object
- Parameters
-
lpistate pointer to LPi state blkmem block memory ncols number of columns to store nrows number of rows to store nrngrows number of ranged rows
Definition at line 655 of file lpi_grb.c.
References BMSallocBlockMemory, BMSallocBlockMemoryArray, colpacketNum(), NULL, rowpacketNum(), SCIP_ALLOC, and SCIP_OKAY.
Referenced by SCIPlpiGetState().
◆ lpistateFree()
|
static |
frees LPi state information
- Parameters
-
lpistate pointer to LPi state information (like basis information) blkmem block memory
Definition at line 677 of file lpi_grb.c.
References BMSfreeBlockMemory, BMSfreeBlockMemoryArrayNull, colpacketNum(), NULL, and rowpacketNum().
Referenced by SCIPlpiFreeState().
◆ getParameterValues()
|
static |
gets all Gurobi parameters used in LPI
- Parameters
-
lpi LP interface structure grbparam Gurobi parameters
Definition at line 699 of file lpi_grb.c.
References CHECK_ZERO, dblparam, SCIP_LPi::grbenv, intparam, SCIP_LPi::messagehdlr, NULL, NUMDBLPARAM, NUMINTPARAM, SCIP_OKAY, and SCIPdebugMessage.
Referenced by checkParameterValues(), and SCIPlpiCreate().
◆ checkParameterValues()
|
static |
in debug mode, checks validity of Gurobi parameters
- Parameters
-
lpi LP interface structure
Definition at line 726 of file lpi_grb.c.
References SCIP_LPi::curparam, dblparammin, SCIP_CPXParam::dblparval, getParameterValues(), SCIP_CPXParam::intparval, MAX, NUMDBLPARAM, NUMINTPARAM, SCIP_CALL, and SCIP_OKAY.
Referenced by setParameterValues().
◆ setParameterValues()
|
static |
sets all Gurobi parameters used in LPI
- Parameters
-
lpi LP interface structure grbparam Gurobi parameters
Definition at line 746 of file lpi_grb.c.
References CHECK_ZERO, checkParameterValues(), SCIP_LPi::curparam, dblparam, dblparammin, SCIP_CPXParam::dblparval, SCIP_LPi::grbenv, intparam, SCIP_CPXParam::intparval, MAX, SCIP_LPi::messagehdlr, NULL, NUMDBLPARAM, NUMINTPARAM, SCIP_CALL, SCIP_OKAY, and SCIPdebugMessage.
Referenced by lpiStrongbranch(), SCIPlpiSolveBarrier(), SCIPlpiSolveDual(), and SCIPlpiSolvePrimal().
◆ copyParameterValues()
copies Gurobi parameters from source to dest
- Parameters
-
dest destination Gurobi parameters source original Gurobi parameters
Definition at line 787 of file lpi_grb.c.
References NUMDBLPARAM, and NUMINTPARAM.
Referenced by SCIPlpiCreate().
◆ getIntParam()
|
static |
gets a single integer parameter value
- Parameters
-
lpi LP interface structure param parameter name p value of parameter
Definition at line 802 of file lpi_grb.c.
References SCIP_LPi::grbparam, intparam, NULL, NUMINTPARAM, SCIP_LPERROR, SCIP_OKAY, and SCIPerrorMessage.
Referenced by SCIPlpiGetIntpar().
◆ setIntParam()
|
static |
sets a single integer parameter value
- Parameters
-
lpi LP interface structure param parameter name parval value of parameter
Definition at line 827 of file lpi_grb.c.
References SCIP_LPi::grbparam, intparam, NULL, NUMINTPARAM, SCIP_LPERROR, SCIP_OKAY, and SCIPerrorMessage.
Referenced by SCIPlpiSetIntpar().
◆ getDblParam()
|
static |
gets a single double parameter value
- Parameters
-
lpi LP interface structure param parameter name p value of parameter
Definition at line 852 of file lpi_grb.c.
References dblparam, SCIP_LPi::grbparam, NULL, NUMDBLPARAM, SCIP_LPERROR, SCIP_OKAY, and SCIPerrorMessage.
Referenced by lpiStrongbranch(), SCIPlpiGetIntpar(), SCIPlpiGetObjval(), SCIPlpiGetRealpar(), and SCIPlpiSolveDual().
◆ setDblParam()
|
static |
sets a single double parameter value
- Parameters
-
lpi LP interface structure param parameter name parval value of parameter
Definition at line 877 of file lpi_grb.c.
References dblparam, SCIP_LPi::grbparam, NULL, NUMDBLPARAM, SCIP_LPERROR, SCIP_OKAY, and SCIPerrorMessage.
Referenced by lpiStrongbranch(), SCIPlpiSetIntpar(), and SCIPlpiSetRealpar().
◆ invalidateSolution()
|
static |
marks the current LP to be unsolved
- Parameters
-
lpi LP interface structure
Definition at line 902 of file lpi_grb.c.
References NULL, and SCIP_LPi::solstat.
Referenced by SCIPlpiAddCols(), SCIPlpiAddRows(), SCIPlpiChgBounds(), SCIPlpiChgCoef(), SCIPlpiChgObj(), SCIPlpiChgObjsen(), SCIPlpiChgSides(), SCIPlpiClear(), SCIPlpiCreate(), SCIPlpiDelCols(), SCIPlpiDelColset(), SCIPlpiDelRows(), SCIPlpiDelRowset(), SCIPlpiLoadColLP(), SCIPlpiScaleCol(), SCIPlpiScaleRow(), SCIPlpiSetBase(), SCIPlpiSolveBarrier(), SCIPlpiSolveDual(), and SCIPlpiSolvePrimal().
◆ convertSides()
|
static |
converts SCIP's lhs/rhs pairs into Gurobi's sen/rhs
- Parameters
-
lpi LP interface structure nrows number of rows lhs left hand side vector rhs right hand side vector rngcount number of ranged rows found
Definition at line 912 of file lpi_grb.c.
References NULL, SCIP_LPi::rhsarray, SCIP_LPi::rngarray, SCIP_LPi::rngidxarray, SCIP_OKAY, and SCIP_LPi::senarray.
Referenced by SCIPlpiAddRows(), SCIPlpiChgSides(), and SCIPlpiLoadColLP().
◆ reconvertSides()
|
static |
converts Gurobi's sen/rhs pairs into SCIP's lhs/rhs pairs
- Parameters
-
lpi LP interface structure firstrow first row to get sides for lastrow last row to get sides for lhs buffer to store the left hand side vector, or NULL rhs buffer to store the right hand side vector, or NULL
Definition at line 970 of file lpi_grb.c.
References SCIP_LPi::nrngrows, NULL, SCIP_LPi::rhsarray, SCIP_LPi::rngrowmap, SCIP_LPi::rngvals, SCIP_LPERROR, SCIP_OKAY, SCIPABORT, SCIPerrorMessage, and SCIP_LPi::senarray.
Referenced by SCIPlpiGetRows(), and SCIPlpiGetSides().
◆ restoreLPData()
|
static |
after restoring old LP data, need to resolve the LP to be able to retrieve correct information
- Parameters
-
lpi LP interface structure
Definition at line 1033 of file lpi_grb.c.
References CHECK_ZERO, GRB_REFACTORMAXITERS, SCIP_LPi::grbenv, SCIP_LPi::grbmodel, SCIP_LPi::messagehdlr, NULL, SCIP_OKAY, and SCIPmessagePrintWarning().
Referenced by SCIPlpiGetBasisInd(), SCIPlpiGetBInvACol(), SCIPlpiGetBInvARow(), SCIPlpiGetBInvCol(), and SCIPlpiGetBInvRow().
◆ checkRangeInfo()
|
static |
verifies in debug mode that ranged row information is consistent
- Parameters
-
lpi LP interface structure
Definition at line 1065 of file lpi_grb.c.
References SCIP_LPi::nrngrows, NULL, SCIP_LPi::rngrowmap, SCIP_LPi::rngrowmapsize, SCIP_LPi::rngrows, SCIP_LPi::rngrowssize, SCIP_LPi::rngvals, SCIP_CALL_ABORT, and SCIPlpiGetNRows().
Referenced by SCIPlpiAddCols(), SCIPlpiAddRows(), SCIPlpiChgBounds(), SCIPlpiChgSides(), SCIPlpiClear(), SCIPlpiCreate(), SCIPlpiDelCols(), SCIPlpiDelColset(), SCIPlpiDelRows(), SCIPlpiDelRowset(), SCIPlpiLoadColLP(), SCIPlpiScaleCol(), SCIPlpiScaleRow(), SCIPlpiSolveBarrier(), SCIPlpiSolveDual(), SCIPlpiSolvePrimal(), SCIPlpiStrongbranchesFrac(), SCIPlpiStrongbranchesInt(), SCIPlpiStrongbranchFrac(), and SCIPlpiStrongbranchInt().
◆ addRangeVars()
|
static |
adds range variables to Gurobi LP
- Parameters
-
lpi LP interface structure
Definition at line 1107 of file lpi_grb.c.
References CHECK_ZERO, SCIP_LPi::grbmodel, SCIP_LPi::messagehdlr, SCIP_LPi::nrngrows, NULL, SCIP_LPi::rngrowmap, SCIP_LPi::rngrows, SCIP_LPi::rngvals, SCIP_LPi::rngvarsadded, SCIP_OKAY, and TRUE.
Referenced by lpiStrongbranch(), SCIPlpiSolveBarrier(), SCIPlpiSolveDual(), SCIPlpiSolvePrimal(), and SCIPlpiWriteLP().
◆ delRangeVars()
|
static |
deletes range variables from Gurobi LP
- Parameters
-
lpi LP interface structure
Definition at line 1138 of file lpi_grb.c.
References BMSallocMemoryArray, BMSfreeMemoryArray, CHECK_ZERO, FALSE, SCIP_LPi::grbmodel, SCIP_LPi::messagehdlr, SCIP_LPi::nrngrows, SCIP_LPi::rngvarsadded, SCIP_ALLOC, SCIP_CALL, SCIP_OKAY, and SCIPlpiGetNCols().
Referenced by addRangeInfo(), SCIPlpiAddCols(), SCIPlpiChgSides(), SCIPlpiDelRows(), SCIPlpiDelRowset(), and SCIPlpiWriteLP().
◆ clearRangeInfo()
|
static |
clear ranged row information
- Parameters
-
lpi LP interface structure
Definition at line 1168 of file lpi_grb.c.
References BMSfreeMemoryArrayNull, SCIP_LPi::nrngrows, SCIP_LPi::rngrowmap, SCIP_LPi::rngrowmapsize, SCIP_LPi::rngrows, SCIP_LPi::rngrowssize, SCIP_LPi::rngvals, and SCIP_LPi::rngvarsadded.
Referenced by SCIPlpiChgSides(), SCIPlpiClear(), SCIPlpiDelRows(), and SCIPlpiDelRowset().
◆ addRangeInfo()
|
static |
creates or updates maps for ranged rows after new rows have been added
- Parameters
-
lpi LP interface structure rngcount number of ranged rows added firstrow index of first row that was added
Definition at line 1185 of file lpi_grb.c.
References delRangeVars(), ensureRngrowmapMem(), ensureRngrowsMem(), SCIP_LPi::nrngrows, NULL, r, SCIP_LPi::rngarray, SCIP_LPi::rngidxarray, SCIP_LPi::rngrowmap, SCIP_LPi::rngrows, SCIP_LPi::rngvals, SCIP_LPi::rngvarsadded, SCIP_CALL, SCIP_OKAY, SCIPlpiGetNCols(), and SCIPlpiGetNRows().
Referenced by SCIPlpiAddRows(), and SCIPlpiLoadColLP().
Variable Documentation
◆ reusegrbenv
|
static |
◆ numlp
|
static |
◆ intparam
|
static |
Definition at line 110 of file lpi_grb.c.
Referenced by getIntParam(), getParameterValues(), setIntParam(), and setParameterValues().
◆ dblparam
|
static |
Definition at line 123 of file lpi_grb.c.
Referenced by getDblParam(), getParameterValues(), setDblParam(), and setParameterValues().
◆ dblparammin
|
static |
minimal values for double parameters
Definition at line 135 of file lpi_grb.c.
Referenced by checkParameterValues(), and setParameterValues().
◆ grbname
|
static |
Definition at line 1246 of file lpi_grb.c.
Referenced by SCIPlpiGetSolverName().