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 |
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 [] |
#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().
#define CHECK_ZERO_STAR | ( | messagehdlr, | |
x ) |
Definition at line 80 of file lpi_grb.c.
Referenced by SCIPlpiCreate(), and SCIPlpiFree().
#define SVECTOR GRBsvec |
Definition at line 89 of file lpi_grb.c.
Referenced by SCIPlpiGetBInvACol(), SCIPlpiGetBInvARow(), SCIPlpiGetBInvCol(), and SCIPlpiGetBInvRow().
#define SCIP_DUALPACKETSIZE (sizeof(SCIP_DUALPACKET)*4) |
#define COLS_PER_PACKET SCIP_DUALPACKETSIZE |
#define ROWS_PER_PACKET SCIP_DUALPACKETSIZE |
#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().
#define NUMINTPARAM 6 |
#define NUMDBLPARAM 7 |
|
static |
resizes senarray to have at least num entries
lpi | LP interface structure |
num | minimal number of entries in array |
Definition at line 224 of file lpi_grb.c.
References assert(), 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().
|
static |
resizes valarray and indarray to have at least num entries
lpi | LP interface structure |
num | minimal number of entries in array |
Definition at line 249 of file lpi_grb.c.
References assert(), BMSreallocMemoryArray, SCIP_LPi::indarray, MAX, NULL, SCIP_ALLOC, SCIP_OKAY, SCIP_LPi::valarray, and SCIP_LPi::valsize.
Referenced by SCIPlpiScaleCol(), and SCIPlpiScaleRow().
|
static |
resizes cstat array to have at least num entries
lpi | LP interface structure |
num | minimal number of entries in array |
Definition at line 272 of file lpi_grb.c.
References assert(), BMSreallocMemoryArray, SCIP_LPi::cstat, SCIP_LPi::cstatsize, MAX, NULL, SCIP_ALLOC, and SCIP_OKAY.
Referenced by getBase(), SCIPlpiSetBase(), and SCIPlpiSetState().
|
static |
resizes rstat array to have at least num entries
lpi | LP interface structure |
num | minimal number of entries in array |
Definition at line 294 of file lpi_grb.c.
References assert(), BMSreallocMemoryArray, MAX, NULL, SCIP_LPi::rstat, SCIP_LPi::rstatsize, SCIP_ALLOC, and SCIP_OKAY.
Referenced by getBase(), SCIPlpiSetBase(), and SCIPlpiSetState().
|
static |
resizes rngrowmap array to have at least num entries
lpi | LP interface structure |
num | minimal number of entries in array |
Definition at line 316 of file lpi_grb.c.
References assert(), BMSreallocMemoryArray, MAX, NULL, r, SCIP_LPi::rngrowmap, SCIP_LPi::rngrowmapsize, SCIP_ALLOC, and SCIP_OKAY.
Referenced by addRangeInfo(), SCIPlpiAddRows(), and SCIPlpiChgSides().
|
static |
resizes rngrows and rngvals arrays to have at least num entries
lpi | LP interface structure |
num | minimal number of entries in array |
Definition at line 341 of file lpi_grb.c.
References assert(), BMSreallocMemoryArray, MAX, NULL, SCIP_LPi::rngrows, SCIP_LPi::rngrowssize, SCIP_LPi::rngvals, SCIP_ALLOC, and SCIP_OKAY.
Referenced by addRangeInfo(), and SCIPlpiChgSides().
|
static |
stores current basis in internal arrays of LPI data structure
lpi | LP interface structure |
success | whether basis information has successfully been obtained |
Definition at line 364 of file lpi_grb.c.
References assert(), CHECK_ZERO, SCIP_LPi::cstat, ensureCstatMem(), ensureRstatMem(), FALSE, SCIP_LPi::grbenv, SCIP_LPi::grbmodel, SCIP_LPi::messagehdlr, NULL, SCIP_LPi::rstat, SCIP_Bool, SCIP_CALL, SCIP_LPERROR, SCIP_OKAY, SCIPdebugMessage, SCIPerrorMessage, and TRUE.
Referenced by lpiStrongbranch(), and SCIPlpiGetState().
|
static |
loads basis stored in internal arrays of LPI data structure into Gurobi
lpi | LP interface structure |
Definition at line 422 of file lpi_grb.c.
References assert(), CHECK_ZERO, SCIP_LPi::cstat, SCIP_LPi::grbmodel, SCIP_LPi::messagehdlr, NULL, SCIP_LPi::rstat, SCIP_OKAY, and SCIPdebugMessage.
Referenced by lpiStrongbranch(), and SCIPlpiSetState().
|
static |
returns the number of packets needed to store column packet information
ncols | number of columns to store |
Definition at line 455 of file lpi_grb.c.
References COLS_PER_PACKET.
|
static |
returns the number of packets needed to store row packet information
nrows | number of rows to store |
Definition at line 464 of file lpi_grb.c.
References ROWS_PER_PACKET.
|
static |
encode a negated dual bit vector into packed format
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 assert(), i, NULL, and SCIP_DUALPACKETSIZE.
Referenced by lpistatePack().
|
static |
decode a packed dual bit vector into negated unpacked format
inp | packed input vector |
out | buffer to store unpacked vector |
count | number of elements |
Definition at line 547 of file lpi_grb.c.
References assert(), i, NULL, and SCIP_DUALPACKETSIZE.
Referenced by lpistateUnpack().
|
static |
store row and column basis status in a packed LPi state object
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 assert(), SCIP_LPiState::ncols, SCIP_LPiState::nrngrows, SCIP_LPiState::nrows, NULL, SCIP_LPiState::packcstat, SCIP_LPiState::packrstat, and SCIPencodeDualBitNeg().
Referenced by SCIPlpiGetState().
|
static |
unpacks row and column basis status from a packed LPi state object
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 assert(), SCIP_LPiState::ncols, SCIP_LPiState::nrngrows, SCIP_LPiState::nrows, NULL, SCIP_LPiState::packcstat, SCIP_LPiState::packrstat, and SCIPdecodeDualBitNeg().
Referenced by SCIPlpiSetState().
|
static |
creates LPi state information object
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 assert(), BMSallocBlockMemory, BMSallocBlockMemoryArray, colpacketNum(), NULL, rowpacketNum(), SCIP_ALLOC, and SCIP_OKAY.
Referenced by SCIPlpiGetState().
|
static |
frees LPi state information
lpistate | pointer to LPi state information (like basis information) |
blkmem | block memory |
Definition at line 677 of file lpi_grb.c.
References assert(), BMSfreeBlockMemory, BMSfreeBlockMemoryArrayNull, colpacketNum(), NULL, and rowpacketNum().
Referenced by SCIPlpiFreeState().
|
static |
gets all Gurobi parameters used in LPI
lpi | LP interface structure |
grbparam | Gurobi parameters |
Definition at line 699 of file lpi_grb.c.
References assert(), CHECK_ZERO, dblparam, SCIP_LPi::grbenv, i, intparam, SCIP_LPi::messagehdlr, NULL, NUMDBLPARAM, NUMINTPARAM, SCIP_OKAY, and SCIPdebugMessage.
Referenced by checkParameterValues(), and SCIPlpiCreate().
|
static |
in debug mode, checks validity of Gurobi parameters
lpi | LP interface structure |
Definition at line 726 of file lpi_grb.c.
References assert(), SCIP_LPi::curparam, dblparammin, SCIP_CPXParam::dblparval, getParameterValues(), i, SCIP_CPXParam::intparval, MAX, NUMDBLPARAM, NUMINTPARAM, SCIP_CALL, and SCIP_OKAY.
Referenced by setParameterValues().
|
static |
sets all Gurobi parameters used in LPI
lpi | LP interface structure |
grbparam | Gurobi parameters |
Definition at line 746 of file lpi_grb.c.
References assert(), CHECK_ZERO, checkParameterValues(), SCIP_LPi::curparam, dblparam, dblparammin, SCIP_CPXParam::dblparval, SCIP_LPi::grbenv, i, intparam, SCIP_CPXParam::intparval, MAX, SCIP_LPi::messagehdlr, NULL, NUMDBLPARAM, NUMINTPARAM, SCIP_CALL, SCIP_OKAY, and SCIPdebugMessage.
Referenced by lpiStrongbranch(), SCIPlpiSolveBarrier(), SCIPlpiSolveDual(), and SCIPlpiSolvePrimal().
copies Gurobi parameters from source to dest
dest | destination Gurobi parameters |
source | original Gurobi parameters |
Definition at line 787 of file lpi_grb.c.
References i, NUMDBLPARAM, and NUMINTPARAM.
Referenced by SCIPlpiCreate().
|
static |
gets a single integer parameter value
lpi | LP interface structure |
param | parameter name |
p | value of parameter |
Definition at line 802 of file lpi_grb.c.
References assert(), SCIP_LPi::grbparam, i, intparam, NULL, NUMINTPARAM, SCIP_LPERROR, SCIP_OKAY, and SCIPerrorMessage.
Referenced by SCIPlpiGetIntpar().
|
static |
sets a single integer parameter value
lpi | LP interface structure |
param | parameter name |
parval | value of parameter |
Definition at line 827 of file lpi_grb.c.
References assert(), SCIP_LPi::grbparam, i, intparam, NULL, NUMINTPARAM, SCIP_LPERROR, SCIP_OKAY, and SCIPerrorMessage.
Referenced by SCIPlpiSetIntpar().
|
static |
gets a single double parameter value
lpi | LP interface structure |
param | parameter name |
p | value of parameter |
Definition at line 852 of file lpi_grb.c.
References assert(), dblparam, SCIP_LPi::grbparam, i, NULL, NUMDBLPARAM, SCIP_LPERROR, SCIP_OKAY, and SCIPerrorMessage.
Referenced by lpiStrongbranch(), SCIPlpiGetIntpar(), SCIPlpiGetObjval(), SCIPlpiGetRealpar(), and SCIPlpiSolveDual().
|
static |
sets a single double parameter value
lpi | LP interface structure |
param | parameter name |
parval | value of parameter |
Definition at line 877 of file lpi_grb.c.
References assert(), dblparam, SCIP_LPi::grbparam, i, NULL, NUMDBLPARAM, SCIP_LPERROR, SCIP_OKAY, and SCIPerrorMessage.
Referenced by lpiStrongbranch(), SCIPlpiSetIntpar(), and SCIPlpiSetRealpar().
|
static |
marks the current LP to be unsolved
lpi | LP interface structure |
Definition at line 902 of file lpi_grb.c.
References assert(), 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().
|
static |
converts SCIP's lhs/rhs pairs into Gurobi's sen/rhs
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 assert(), i, NULL, SCIP_LPi::rhsarray, SCIP_LPi::rngarray, SCIP_LPi::rngidxarray, SCIP_OKAY, SCIP_Real, and SCIP_LPi::senarray.
Referenced by SCIPlpiAddRows(), SCIPlpiChgSides(), and SCIPlpiLoadColLP().
|
static |
converts Gurobi's sen/rhs pairs into SCIP's lhs/rhs pairs
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 assert(), i, SCIP_LPi::nrngrows, NULL, SCIP_LPi::rhsarray, SCIP_LPi::rngrowmap, SCIP_LPi::rngvals, SCIP_LPERROR, SCIP_OKAY, SCIP_Real, SCIPABORT, SCIPerrorMessage, and SCIP_LPi::senarray.
Referenced by SCIPlpiGetRows(), and SCIPlpiGetSides().
|
static |
after restoring old LP data, need to resolve the LP to be able to retrieve correct information
lpi | LP interface structure |
Definition at line 1033 of file lpi_grb.c.
References assert(), 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().
|
static |
verifies in debug mode that ranged row information is consistent
lpi | LP interface structure |
Definition at line 1065 of file lpi_grb.c.
References assert(), i, 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().
|
static |
adds range variables to Gurobi LP
lpi | LP interface structure |
Definition at line 1107 of file lpi_grb.c.
References assert(), CHECK_ZERO, SCIP_LPi::grbmodel, i, 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().
|
static |
deletes range variables from Gurobi LP
lpi | LP interface structure |
Definition at line 1138 of file lpi_grb.c.
References assert(), BMSallocMemoryArray, BMSfreeMemoryArray, CHECK_ZERO, FALSE, SCIP_LPi::grbmodel, i, 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().
|
static |
clear ranged row information
lpi | LP interface structure |
Definition at line 1168 of file lpi_grb.c.
References assert(), 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().
|
static |
creates or updates maps for ranged rows after new rows have been added
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 assert(), delRangeVars(), ensureRngrowmapMem(), ensureRngrowsMem(), i, 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().
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Definition at line 1246 of file lpi_grb.c.
Referenced by SCIPlpiGetSolverName().