58 assert(scalars != NULL);
59 assert(*vars != NULL);
60 assert(*scalars != NULL);
61 assert(nvars != NULL);
62 assert(constant != NULL);
66 if( requiredsize > *nvars )
73 assert(requiredsize <= *nvars);
100 assert(vals != NULL);
102 rowidx = matrix->
nrows;
103 rangedorequality =
FALSE;
108 matrix->
lhs[rowidx] = -rhs;
115 matrix->
lhs[rowidx] = lhs;
116 matrix->
rhs[rowidx] = rhs;
120 rangedorequality =
TRUE;
133 if( rangedorequality )
137 for( j = 0; j < nvars; j++ )
139 assert(maxnnonzsmem > matrix->
nnonzs);
147 assert(matrix->
vars[probindex] == vars[j]);
152 assert(0 <= probindex && probindex < matrix->ncols);
161 for( j = 0; j < nvars; j++ )
163 assert(maxnnonzsmem > matrix->
nnonzs);
172 assert(matrix->
vars[probindex] == vars[j]);
182 assert(0 <= probindex && probindex < matrix->ncols);
217 assert(scip != NULL);
218 assert(matrix != NULL);
219 assert(vars != NULL || nvars == 0);
221 assert(rowadded != NULL);
236 activeconstant = 0.0;
248 for( v = 0; v < nactivevars; v++ )
257 lhs -= activeconstant;
259 rhs -= activeconstant;
262 if( nactivevars > 0 )
264 SCIP_CALL(
addRow(scip, matrix, activevars, activevals, nactivevars, lhs, rhs, maxnnonzsmem, rowadded) );
288 assert(scip != NULL);
289 assert(matrix != NULL);
303 for( i = 0; i < matrix->
nrows; i++ )
307 for( ; rowpnt < rowend; rowpnt++ )
315 for( i = 0; i < matrix->
ncols-1; i++ )
320 for( i = 0; i < matrix->
nrows; i++ )
326 for( ; rowpnt < rowend; rowpnt++, valpnt++ )
328 assert(*rowpnt < matrix->ncols);
355 assert(scip != NULL);
356 assert(matrix != NULL);
358 for( row = 0; row < matrix->
nrows; row++ )
368 rowend = rowpnt + matrix->
rowmatcnt[row];
371 for( ; rowpnt < rowend; rowpnt++, valpnt++ )
380 assert(matrix->
ncols > col);
439 const char* conshdlrname;
456 assert(scip != NULL);
457 assert(matrixptr != NULL);
458 assert(initialized != NULL);
459 assert(complete != NULL);
461 *initialized =
FALSE;
474 for( i = 0; i < nconshdlrs; ++i )
480 if( nconshdlrconss > 0 )
484 if( (strcmp(conshdlrname,
"linear") == 0) || (strcmp(conshdlrname,
"setppc") == 0)
485 || (strcmp(conshdlrname,
"logicor") == 0) || (strcmp(conshdlrname,
"knapsack") == 0)
486 || (strcmp(conshdlrname,
"varbound") == 0) )
489 nconss += nconshdlrconss;
493 nconssall += nconshdlrconss;
504 if( nconss < nconssall )
506 SCIPdebugMsg(scip,
"Warning: milp matrix not complete!\n");
526 for( i = nvars - 1; i >= 0; --i )
542 matrix->
ncols = nvars;
561 for( v = 0; v < matrix->
ncols; v++ )
563 var = matrix->
vars[v];
589 for( i = 0; i < nconshdlrs; ++i )
605 if( strcmp(conshdlrname,
"linear") == 0 )
607 for( c = 0; c < nconshdlrconss && (c % 1000 != 0 || !
SCIPisStopped(scip)); ++c )
609 cons = conshdlrconss[c];
618 assert(cnt < nconss);
619 matrix->
cons[cnt] = cons;
624 else if( strcmp(conshdlrname,
"setppc") == 0 )
626 for( c = 0; c < nconshdlrconss && (c % 1000 != 0 || !
SCIPisStopped(scip)); ++c )
631 cons = conshdlrconss[c];
657 assert(cnt < nconss);
658 matrix->
cons[cnt] = cons;
663 else if( strcmp(conshdlrname,
"logicor") == 0 )
665 for( c = 0; c < nconshdlrconss && (c % 1000 != 0 || !
SCIPisStopped(scip)); ++c )
667 cons = conshdlrconss[c];
675 assert(cnt < nconss);
676 matrix->
cons[cnt] = cons;
681 else if( strcmp(conshdlrname,
"knapsack") == 0 )
683 if( nconshdlrconss > 0 )
691 for( c = 0; c < nconshdlrconss && (c % 1000 != 0 || !
SCIPisStopped(scip)); ++c )
695 cons = conshdlrconss[c];
701 if( nvars > valssize )
703 valssize = (int) (1.5 * nvars);
707 for( v = 0; v < nvars; v++ )
716 assert(cnt < nconss);
717 matrix->
cons[cnt] = cons;
725 else if( strcmp(conshdlrname,
"varbound") == 0 )
727 if( nconshdlrconss > 0 )
736 for( c = 0; c < nconshdlrconss && (c % 1000 != 0 || !
SCIPisStopped(scip)); ++c )
738 cons = conshdlrconss[c];
751 assert(cnt < nconss);
752 matrix->
cons[cnt] = cons;
762 assert(matrix->
nrows == cnt);
763 assert(matrix->
nrows <= nconss);
764 assert(matrix->
nnonzs <= nnonzstmp);
787 assert(scip != NULL);
788 assert(matrix != NULL);
790 if( (*matrix) != NULL )
792 assert((*matrix)->colmatval != NULL);
793 assert((*matrix)->colmatind != NULL);
794 assert((*matrix)->colmatbeg != NULL);
795 assert((*matrix)->colmatcnt != NULL);
796 assert((*matrix)->lb != NULL);
797 assert((*matrix)->ub != NULL);
798 assert((*matrix)->nuplocks != NULL);
799 assert((*matrix)->ndownlocks != NULL);
801 assert((*matrix)->rowmatval != NULL);
802 assert((*matrix)->rowmatind != NULL);
803 assert((*matrix)->rowmatbeg != NULL);
804 assert((*matrix)->rowmatcnt != NULL);
805 assert((*matrix)->lhs != NULL);
806 assert((*matrix)->rhs != NULL);
834 (*matrix)->nrows = 0;
835 (*matrix)->ncols = 0;
836 (*matrix)->nnonzs = 0;
858 rowend = rowpnt + matrix->
rowmatcnt[row];
862 for(; (rowpnt < rowend); rowpnt++, valpnt++)
873 printf(
" <= %.15g ###\n", matrix->
rhs[row]);
907 assert(scip != NULL);
908 assert(matrix != NULL);
909 assert(pclass != NULL);
921 classsizes[0] = matrix->
nrows;
923 for( t = 1; t < matrix->
nrows; ++t )
924 pcset[pcsetfill++] = t;
927 for( c = 0; c < matrix->
ncols; ++c )
937 for( ; (colpnt < colend); colpnt++, valpnt++ )
942 if( scale[rowidx] == 0.0 )
944 assert(scale[rowidx] != 0.0);
946 rowindices[i] = rowidx;
947 values[i] = aij / scale[rowidx];
949 assert(pc < matrix->nrows);
952 assert(classsizes[pc] > 0);
954 if( classsizes[pc] == 0 )
956 assert(pcsetfill < matrix->nrows);
957 pcset[pcsetfill++] = pc;
978 while( k < i && pcs[k] == startpc )
988 assert(startk + t < i);
989 startval = values[startk + t];
993 while( t < k - startk &&
SCIPisEQ(scip, startval, values[startk + t]) )
997 newpclass = pcset[0];
998 assert(pcsetfill > 0);
999 pcset[0] = pcset[--pcsetfill];
1002 for( m = startk + startt; m < startk + t; m++ )
1005 assert(rowindices[m] < matrix->
nrows);
1006 assert(newpclass < matrix->nrows);
1008 pclass[rowindices[m]] = newpclass;
1009 classsizes[newpclass]++;
1012 if( t == k - startk )
1064 assert(scip != NULL);
1065 assert(matrix != NULL);
1066 assert(pclass != NULL);
1067 assert(varineq != NULL);
1079 classsizes[0] = matrix->
ncols;
1081 for( t = 1; t < matrix->
ncols; ++t )
1082 pcset[pcsetfill++] = t;
1085 for( r = 0; r < matrix->
nrows; ++r )
1095 for( ; (rowpnt < rowend); rowpnt++, valpnt++ )
1101 varineq[colidx] =
TRUE;
1103 if( scale[colidx] == 0.0 )
1104 scale[colidx] = aij;
1105 assert(scale[colidx] != 0.0);
1107 colindices[i] = colidx;
1108 values[i] = aij / scale[colidx];
1109 pc = pclass[colidx];
1110 assert(pc < matrix->ncols);
1113 assert(classsizes[pc] > 0);
1115 if( classsizes[pc] == 0 )
1117 assert(pcsetfill < matrix->ncols);
1118 pcset[pcsetfill++] = pc;
1139 while( k < i && pcs[k] == startpc )
1143 if( k - startk > 1 )
1144 SCIPsortRealInt(&(values[startk]), &(colindices[startk]), k - startk);
1149 assert(startk + t < i);
1150 startval = values[startk + t];
1154 while( t < k - startk &&
SCIPisEQ(scip, startval, values[startk + t]) )
1158 newpclass = pcset[0];
1159 assert(pcsetfill > 0);
1160 pcset[0] = pcset[--pcsetfill];
1163 for( m = startk + startt; m < startk + t; m++ )
1166 assert(colindices[m] < matrix->
ncols);
1167 assert(newpclass < matrix->ncols);
1169 pclass[colindices[m]] = newpclass;
1170 classsizes[newpclass]++;
1173 if( t == k - startk )
1203 #undef SCIPmatrixGetColValPtr 1204 #undef SCIPmatrixGetColIdxPtr 1205 #undef SCIPmatrixGetColNNonzs 1206 #undef SCIPmatrixGetNColumns 1207 #undef SCIPmatrixGetColUb 1208 #undef SCIPmatrixGetColLb 1209 #undef SCIPmatrixGetColNUplocks 1210 #undef SCIPmatrixGetColNDownlocks 1211 #undef SCIPmatrixGetVar 1212 #undef SCIPmatrixGetColName 1213 #undef SCIPmatrixGetRowValPtr 1214 #undef SCIPmatrixGetRowIdxPtr 1215 #undef SCIPmatrixGetRowNNonzs 1216 #undef SCIPmatrixGetRowName 1217 #undef SCIPmatrixGetNRows 1218 #undef SCIPmatrixGetRowLhs 1219 #undef SCIPmatrixGetRowRhs 1220 #undef SCIPmatrixIsRowRhsInfinity 1221 #undef SCIPmatrixGetNNonzs 1222 #undef SCIPmatrixGetRowMinActivity 1223 #undef SCIPmatrixGetRowMaxActivity 1224 #undef SCIPmatrixGetRowNMinActNegInf 1225 #undef SCIPmatrixGetRowNMinActPosInf 1226 #undef SCIPmatrixGetRowNMaxActNegInf 1227 #undef SCIPmatrixGetRowNMaxActPosInf 1228 #undef SCIPmatrixGetCons 1229 #undef SCIPmatrixUplockConflict 1230 #undef SCIPmatrixDownlockConflict 1238 assert(matrix != NULL);
1239 assert(0 <= col && col < matrix->ncols);
1250 assert(matrix != NULL);
1251 assert(0 <= col && col < matrix->ncols);
1262 assert(matrix != NULL);
1263 assert(0 <= col && col < matrix->ncols);
1273 assert(matrix != NULL);
1275 return matrix->
ncols;
1284 assert(matrix != NULL);
1286 return matrix->
ub[col];
1295 assert(matrix != NULL);
1297 return matrix->
lb[col];
1306 assert(matrix != NULL);
1307 assert(0 <= col && col < matrix->ncols);
1318 assert(matrix != NULL);
1319 assert(0 <= col && col < matrix->ncols);
1330 assert(matrix != NULL);
1331 assert(0 <= col && col < matrix->ncols);
1333 return matrix->
vars[col];
1342 assert(matrix != NULL);
1343 assert(0 <= col && col < matrix->ncols);
1354 assert(matrix != NULL);
1355 assert(0 <= row && row < matrix->nrows);
1366 assert(matrix != NULL);
1367 assert(0 <= row && row < matrix->nrows);
1378 assert(matrix != NULL);
1379 assert(0 <= row && row < matrix->nrows);
1390 assert(matrix != NULL);
1391 assert(0 <= row && row < matrix->nrows);
1401 assert(matrix != NULL);
1403 return matrix->
nrows;
1412 assert(matrix != NULL);
1413 assert(0 <= row && row < matrix->nrows);
1415 return matrix->
lhs[row];
1424 assert(matrix != NULL);
1425 assert(0 <= row && row < matrix->nrows);
1427 return matrix->
rhs[row];
1436 assert(matrix != NULL);
1437 assert(0 <= row && row < matrix->nrows);
1447 assert(matrix != NULL);
1458 assert(matrix != NULL);
1459 assert(0 <= row && row < matrix->nrows);
1470 assert(matrix != NULL);
1471 assert(0 <= row && row < matrix->nrows);
1482 assert(matrix != NULL);
1483 assert(0 <= row && row < matrix->nrows);
1494 assert(matrix != NULL);
1495 assert(0 <= row && row < matrix->nrows);
1506 assert(matrix != NULL);
1507 assert(0 <= row && row < matrix->nrows);
1518 assert(matrix != NULL);
1519 assert(0 <= row && row < matrix->nrows);
1530 assert(matrix != NULL);
1531 assert(0 <= row && row < matrix->nrows);
1533 return matrix->
cons[row];
1542 assert(matrix != NULL);
1543 assert(0 <= col && col < matrix->ncols);
1554 assert(matrix != NULL);
1555 assert(0 <= col && col < matrix->ncols);
void SCIPsortRealInt(SCIP_Real *realarray, int *intarray, int len)
void SCIPmatrixPrintRow(SCIP *scip, SCIP_MATRIX *matrix, int row)
SCIP_RETCODE SCIPmatrixGetParallelRows(SCIP *scip, SCIP_MATRIX *matrix, SCIP_Real *scale, int *pclass)
SCIP_VAR * SCIPmatrixGetVar(SCIP_MATRIX *matrix, int col)
int SCIPmatrixGetNRows(SCIP_MATRIX *matrix)
Constraint handler for variable bound constraints .
int SCIPgetNVarsSetppc(SCIP *scip, SCIP_CONS *cons)
static SCIP_RETCODE addConstraint(SCIP *scip, SCIP_MATRIX *matrix, SCIP_VAR **vars, SCIP_Real *vals, int nvars, SCIP_Real lhs, SCIP_Real rhs, int maxnnonzsmem, SCIP_Bool *rowadded)
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
int SCIPgetNVarsLogicor(SCIP *scip, SCIP_CONS *cons)
SCIP_CONS * SCIPmatrixGetCons(SCIP_MATRIX *matrix, int row)
void SCIPmatrixFree(SCIP *scip, SCIP_MATRIX **matrix)
SCIP_Real SCIPinfinity(SCIP *scip)
enum SCIP_Retcode SCIP_RETCODE
int SCIPvarGetProbindex(SCIP_VAR *var)
SCIP_Bool SCIPconsIsTransformed(SCIP_CONS *cons)
SCIP_VAR ** SCIPgetVarsKnapsack(SCIP *scip, SCIP_CONS *cons)
void SCIPsortIntIntReal(int *intarray1, int *intarray2, SCIP_Real *realarray, int len)
SCIP_RETCODE SCIPmatrixGetParallelCols(SCIP *scip, SCIP_MATRIX *matrix, SCIP_Real *scale, int *pclass, SCIP_Bool *varineq)
#define SCIPduplicateBufferArray(scip, ptr, source, num)
SCIP_Bool SCIPisEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
#define SCIPfreeBufferArray(scip, ptr)
SCIP_Real SCIPmatrixGetRowMaxActivity(SCIP_MATRIX *matrix, int row)
Constraint handler for the set partitioning / packing / covering constraints .
SCIP_RETCODE SCIPmatrixCreate(SCIP *scip, SCIP_MATRIX **matrixptr, SCIP_Bool *initialized, SCIP_Bool *complete)
SCIP_Real SCIPgetRhsLinear(SCIP *scip, SCIP_CONS *cons)
int SCIPmatrixGetRowNNonzs(SCIP_MATRIX *matrix, int row)
int SCIPgetNConshdlrs(SCIP *scip)
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
SCIP_Real SCIPmatrixGetRowLhs(SCIP_MATRIX *matrix, int row)
Constraint handler for knapsack constraints of the form , x binary and .
SCIP_VAR * SCIPgetVarVarbound(SCIP *scip, SCIP_CONS *cons)
SCIP_Real * SCIPmatrixGetColValPtr(SCIP_MATRIX *matrix, int col)
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
SCIP_CONSHDLR ** SCIPgetConshdlrs(SCIP *scip)
static SCIP_RETCODE calcActivityBounds(SCIP *scip, SCIP_MATRIX *matrix)
SCIP_Real SCIPgetRhsVarbound(SCIP *scip, SCIP_CONS *cons)
Constraint handler for logicor constraints (equivalent to set covering, but algorithms are suited fo...
#define SCIPallocBuffer(scip, ptr)
int SCIPmatrixGetRowNMaxActPosInf(SCIP_MATRIX *matrix, int row)
SCIP_Real SCIPgetVbdcoefVarbound(SCIP *scip, SCIP_CONS *cons)
#define SCIPfreeBufferArrayNull(scip, ptr)
const char * SCIPconsGetName(SCIP_CONS *cons)
SCIP_VAR ** SCIPgetVarsLogicor(SCIP *scip, SCIP_CONS *cons)
int * SCIPmatrixGetRowIdxPtr(SCIP_MATRIX *matrix, int row)
const char * SCIPvarGetName(SCIP_VAR *var)
const char * SCIPmatrixGetRowName(SCIP_MATRIX *matrix, int row)
SCIP_VAR * SCIPgetVbdvarVarbound(SCIP *scip, SCIP_CONS *cons)
int SCIPmatrixGetRowNMaxActNegInf(SCIP_MATRIX *matrix, int row)
const char * SCIPmatrixGetColName(SCIP_MATRIX *matrix, int col)
SCIP_RETCODE SCIPgetProbvarLinearSum(SCIP *scip, SCIP_VAR **vars, SCIP_Real *scalars, int *nvars, int varssize, SCIP_Real *constant, int *requiredsize, SCIP_Bool mergemultiples)
SCIP_Real SCIPmatrixGetColLb(SCIP_MATRIX *matrix, int col)
SCIP_Real * SCIPmatrixGetRowValPtr(SCIP_MATRIX *matrix, int row)
SCIP_Real SCIPmatrixGetColUb(SCIP_MATRIX *matrix, int col)
SCIP_Bool SCIPmatrixDownlockConflict(SCIP_MATRIX *matrix, int col)
SCIP_Longint SCIPgetCapacityKnapsack(SCIP *scip, SCIP_CONS *cons)
#define SCIPallocBufferArray(scip, ptr, num)
SCIP_SETPPCTYPE SCIPgetTypeSetppc(SCIP *scip, SCIP_CONS *cons)
int SCIPvarGetNLocksUp(SCIP_VAR *var)
int * SCIPmatrixGetColIdxPtr(SCIP_MATRIX *matrix, int col)
SCIP_Bool * isrhsinfinite
#define SCIPfreeMemoryArray(scip, ptr)
Constraint handler for linear constraints in their most general form, .
int SCIPmatrixGetRowNMinActNegInf(SCIP_MATRIX *matrix, int row)
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
data structure for MIP matrix
public methods for matrix
#define SCIPallocClearMemoryArray(scip, ptr, num)
SCIP_VAR ** SCIPgetVarsSetppc(SCIP *scip, SCIP_CONS *cons)
int SCIPgetNVars(SCIP *scip)
#define SCIPfreeBuffer(scip, ptr)
int SCIPvarGetNLocksDown(SCIP_VAR *var)
static SCIP_RETCODE setColumnMajorFormat(SCIP *scip, SCIP_MATRIX *matrix)
static const SCIP_Real scalars[]
SCIP_Real SCIPmatrixGetRowRhs(SCIP_MATRIX *matrix, int row)
SCIP_VAR ** SCIPgetVarsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_CONS ** SCIPconshdlrGetCheckConss(SCIP_CONSHDLR *conshdlr)
int SCIPgetNConss(SCIP *scip)
SCIP_Bool SCIPmatrixIsRowRhsInfinity(SCIP_MATRIX *matrix, int row)
SCIP_VAR ** SCIPgetVars(SCIP *scip)
SCIP_Bool SCIPisStopped(SCIP *scip)
int SCIPgetNVarsKnapsack(SCIP *scip, SCIP_CONS *cons)
int SCIPconshdlrGetNCheckConss(SCIP_CONSHDLR *conshdlr)
SCIP_Real SCIPmatrixGetRowMinActivity(SCIP_MATRIX *matrix, int row)
SCIP_Bool SCIPmatrixUplockConflict(SCIP_MATRIX *matrix, int col)
int SCIPmatrixGetColNDownlocks(SCIP_MATRIX *matrix, int col)
int SCIPmatrixGetNNonzs(SCIP_MATRIX *matrix)
SCIP_Bool SCIPisZero(SCIP *scip, SCIP_Real val)
int SCIPmatrixGetRowNMinActPosInf(SCIP_MATRIX *matrix, int row)
SCIP_Real * SCIPgetValsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_Bool SCIPisLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
static SCIP_RETCODE addRow(SCIP *scip, SCIP_MATRIX *matrix, SCIP_VAR **vars, SCIP_Real *vals, int nvars, SCIP_Real lhs, SCIP_Real rhs, int maxnnonzsmem, SCIP_Bool *rowadded)
int SCIPmatrixGetColNUplocks(SCIP_MATRIX *matrix, int col)
#define BMSclearMemoryArray(ptr, num)
common defines and data types used in all packages of SCIP
SCIP_Longint * SCIPgetWeightsKnapsack(SCIP *scip, SCIP_CONS *cons)
static SCIP_RETCODE getActiveVariables(SCIP *scip, SCIP_VAR ***vars, SCIP_Real **scalars, int *nvars, SCIP_Real *constant)
SCIP_Real SCIPgetLhsVarbound(SCIP *scip, SCIP_CONS *cons)
int SCIPgetNVarsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_Real SCIPgetLhsLinear(SCIP *scip, SCIP_CONS *cons)
int SCIPmatrixGetNColumns(SCIP_MATRIX *matrix)
#define SCIPreallocBufferArray(scip, ptr, num)
int SCIPmatrixGetColNNonzs(SCIP_MATRIX *matrix, int col)