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 ) |
| #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, ensureSidechgMem(), MAX, NULL, SCIP_LPi::rhsarray, SCIP_LPi::rngarray, SCIP_LPi::rngidxarray, SCIP_ALLOC, SCIP_OKAY, SCIP_LPi::senarray, and SCIP_LPi::sidechgsize.
|
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, ensureValMem(), SCIP_LPi::indarray, MAX, NULL, SCIP_ALLOC, SCIP_OKAY, SCIP_LPi::valarray, and SCIP_LPi::valsize.
|
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, ensureCstatMem(), MAX, NULL, SCIP_ALLOC, and SCIP_OKAY.
|
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, ensureRstatMem(), MAX, NULL, SCIP_LPi::rstat, SCIP_LPi::rstatsize, SCIP_ALLOC, and SCIP_OKAY.
|
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, ensureRngrowmapMem(), MAX, NULL, r, SCIP_LPi::rngrowmap, SCIP_LPi::rngrowmapsize, SCIP_ALLOC, and SCIP_OKAY.
Referenced by addRangeInfo(), ensureRngrowmapMem(), 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, ensureRngrowsMem(), MAX, NULL, SCIP_LPi::rngrows, SCIP_LPi::rngrowssize, SCIP_LPi::rngvals, SCIP_ALLOC, and SCIP_OKAY.
Referenced by addRangeInfo(), ensureRngrowsMem(), 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, getBase(), 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.
|
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, SCIPdebugMessage, and setBase().
|
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 colpacketNum(), and 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 rowpacketNum(), and 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, SCIP_DUALPACKETSIZE, and SCIPencodeDualBitNeg().
Referenced by lpistatePack(), and SCIPencodeDualBitNeg().
|
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, SCIP_DUALPACKETSIZE, and SCIPdecodeDualBitNeg().
Referenced by lpistateUnpack(), and SCIPdecodeDualBitNeg().
|
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(), lpistatePack(), SCIP_LPiState::ncols, SCIP_LPiState::nrngrows, SCIP_LPiState::nrows, NULL, SCIP_LPiState::packcstat, SCIP_LPiState::packrstat, and SCIPencodeDualBitNeg().
|
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(), lpistateUnpack(), SCIP_LPiState::ncols, SCIP_LPiState::nrngrows, SCIP_LPiState::nrows, NULL, SCIP_LPiState::packcstat, SCIP_LPiState::packrstat, and SCIPdecodeDualBitNeg().
|
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(), lpistateCreate(), NULL, rowpacketNum(), SCIP_ALLOC, and SCIP_OKAY.
|
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(), lpistateFree(), NULL, and rowpacketNum().
|
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, getParameterValues(), SCIP_LPi::grbenv, i, intparam, SCIP_LPi::messagehdlr, NULL, NUMDBLPARAM, NUMINTPARAM, SCIP_OKAY, and SCIPdebugMessage.
|
static |
in debug mode, checks validity of Gurobi parameters
| lpi | LP interface structure |
Definition at line 726 of file lpi_grb.c.
References assert(), checkParameterValues(), SCIP_LPi::curparam, dblparammin, SCIP_CPXParam::dblparval, getParameterValues(), i, SCIP_CPXParam::intparval, MAX, NUMDBLPARAM, NUMINTPARAM, SCIP_CALL, and SCIP_OKAY.
|
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, SCIPdebugMessage, and setParameterValues().
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 copyParameterValues(), i, NUMDBLPARAM, and NUMINTPARAM.
|
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(), getIntParam(), SCIP_LPi::grbparam, i, intparam, NULL, NUMINTPARAM, SCIP_LPERROR, SCIP_OKAY, and SCIPerrorMessage.
|
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, SCIPerrorMessage, and setIntParam().
|
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, getDblParam(), SCIP_LPi::grbparam, i, NULL, NUMDBLPARAM, SCIP_LPERROR, SCIP_OKAY, and SCIPerrorMessage.
|
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, SCIPerrorMessage, and setDblParam().
|
static |
marks the current LP to be unsolved
| lpi | LP interface structure |
Definition at line 902 of file lpi_grb.c.
References assert(), invalidateSolution(), NULL, and SCIP_LPi::solstat.
|
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(), convertSides(), i, NULL, SCIP_LPi::rhsarray, SCIP_LPi::rngarray, SCIP_LPi::rngidxarray, SCIP_OKAY, SCIP_Real, and SCIP_LPi::senarray.
|
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, reconvertSides(), SCIP_LPi::rhsarray, SCIP_LPi::rngrowmap, SCIP_LPi::rngvals, SCIP_CALL, SCIP_LPERROR, SCIP_OKAY, SCIP_Real, SCIPABORT, SCIPerrorMessage, SCIPlpiGetNRows(), and SCIP_LPi::senarray.
|
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 1040 of file lpi_grb.c.
References assert(), CHECK_ZERO, GRB_REFACTORMAXITERS, SCIP_LPi::grbenv, SCIP_LPi::grbmodel, SCIP_LPi::messagehdlr, NULL, restoreLPData(), SCIP_OKAY, and SCIPmessagePrintWarning().
|
static |
verifies in debug mode that ranged row information is consistent
| lpi | LP interface structure |
Definition at line 1072 of file lpi_grb.c.
References assert(), checkRangeInfo(), 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 checkRangeInfo(), 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 1114 of file lpi_grb.c.
References addRangeVars(), 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 addRangeVars(), lpiStrongbranch(), SCIPlpiSolveBarrier(), SCIPlpiSolveDual(), SCIPlpiSolvePrimal(), and SCIPlpiWriteLP().
|
static |
deletes range variables from Gurobi LP
| lpi | LP interface structure |
Definition at line 1145 of file lpi_grb.c.
References assert(), BMSallocMemoryArray, BMSfreeMemoryArray, CHECK_ZERO, delRangeVars(), 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(), delRangeVars(), SCIPlpiAddCols(), SCIPlpiChgSides(), SCIPlpiDelRows(), SCIPlpiDelRowset(), and SCIPlpiWriteLP().
|
static |
clear ranged row information
| lpi | LP interface structure |
Definition at line 1175 of file lpi_grb.c.
References assert(), BMSfreeMemoryArrayNull, clearRangeInfo(), SCIP_LPi::nrngrows, SCIP_LPi::rngrowmap, SCIP_LPi::rngrowmapsize, SCIP_LPi::rngrows, SCIP_LPi::rngrowssize, SCIP_LPi::rngvals, and SCIP_LPi::rngvarsadded.
Referenced by clearRangeInfo(), 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 1192 of file lpi_grb.c.
References addRangeInfo(), 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 addRangeInfo(), SCIPlpiAddRows(), and SCIPlpiLoadColLP().
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Definition at line 1255 of file lpi_grb.c.
Referenced by SCIPlpiGetSolverName().