79 #define CONSHDLR_NAME "SOS2" 80 #define CONSHDLR_DESC "SOS2 constraint handler" 81 #define CONSHDLR_SEPAPRIORITY 10 82 #define CONSHDLR_ENFOPRIORITY 100 83 #define CONSHDLR_CHECKPRIORITY -10 84 #define CONSHDLR_SEPAFREQ 0 85 #define CONSHDLR_PROPFREQ 1 86 #define CONSHDLR_EAGERFREQ 100 88 #define CONSHDLR_MAXPREROUNDS -1 89 #define CONSHDLR_DELAYSEPA FALSE 90 #define CONSHDLR_DELAYPROP FALSE 91 #define CONSHDLR_NEEDSCONS TRUE 93 #define CONSHDLR_PROP_TIMING SCIP_PROPTIMING_BEFORELP 94 #define CONSHDLR_PRESOLTIMING SCIP_PRESOLTIMING_FAST 97 #define EVENTHDLR_NAME "SOS2" 98 #define EVENTHDLR_DESC "bound change event handler for SOS2 constraints" 113 struct SCIP_ConshdlrData
148 SCIP_CALL(
SCIPcreateConsLinear(scip, &cons,
"branch", 1, &var, &val, 0.0, 0.0,
TRUE,
TRUE,
TRUE,
TRUE,
TRUE,
200 *tightened = *tightened || tighten;
204 *tightened = *tightened || tighten;
221 assert( scip !=
NULL );
222 assert( cons !=
NULL );
223 assert( var !=
NULL );
240 assert( scip !=
NULL );
241 assert( cons !=
NULL );
242 assert( var !=
NULL );
260 assert( consdata !=
NULL );
261 assert( consdata->nvars <= consdata->maxvars );
263 if ( num > consdata->maxvars )
269 if ( reserveWeights )
271 consdata->maxvars = newsize;
273 assert( num <= consdata->maxvars );
289 assert( scip !=
NULL );
290 assert( cons !=
NULL );
291 assert( consdata !=
NULL );
292 assert( var !=
NULL );
303 assert( conshdlrdata !=
NULL );
304 assert( conshdlrdata->eventhdlr !=
NULL );
311 assert( consdata->nfixednonzeros >= 0 );
313 ++consdata->nfixednonzeros;
320 if ( consdata->row !=
NULL )
350 assert( var !=
NULL );
351 assert( cons !=
NULL );
354 assert( consdata !=
NULL );
356 if ( consdata->weights ==
NULL && consdata->maxvars > 0 )
370 assert( var !=
NULL );
374 assert( consdata->weights !=
NULL );
375 assert( consdata->maxvars >= consdata->nvars+1 );
378 for (pos = 0; pos < consdata->nvars; ++pos)
380 if ( consdata->weights[pos] > weight )
383 assert( 0 <= pos && pos <= consdata->nvars );
386 for (j = consdata->nvars; j > pos; --j)
388 consdata->vars[j] = consdata->vars[j-1];
389 consdata->weights[j] = consdata->weights[j-1];
393 consdata->vars[pos] = var;
394 consdata->weights[pos] = weight;
415 assert( var !=
NULL );
416 assert( cons !=
NULL );
419 assert( consdata !=
NULL );
429 assert( var !=
NULL );
435 consdata->vars[consdata->nvars] = var;
436 assert( consdata->weights !=
NULL || consdata->nvars > 0 );
437 if ( consdata->weights !=
NULL && consdata->nvars > 0 )
438 consdata->weights[consdata->nvars] = consdata->weights[consdata->nvars-1] + 1.0;
460 assert( 0 <= pos && pos < consdata->nvars );
469 for (j = pos; j < consdata->nvars-1; ++j)
471 consdata->vars[j] = consdata->vars[j+1];
472 if ( consdata->weights !=
NULL )
473 consdata->weights[j] = consdata->weights[j+1];
526 int lastFixedNonzero;
528 int localnremovedvars;
532 assert( scip !=
NULL );
533 assert( cons !=
NULL );
534 assert( consdata !=
NULL );
535 assert( eventhdlr !=
NULL );
536 assert( cutoff !=
NULL );
537 assert( success !=
NULL );
538 assert( ndelconss !=
NULL );
539 assert( nfixedvars !=
NULL );
540 assert( nremovedvars !=
NULL );
548 if( consdata->nvars <= 2 )
550 SCIPdebugMsg(scip,
"Deleting constraint with <= 2 variables.\n");
562 lastFixedNonzero = -1;
563 vars = consdata->vars;
564 lastzero = consdata->nvars;
565 localnremovedvars = 0;
568 for( j = consdata->nvars - 1; j >= 0; --j )
577 assert(vars == consdata->vars);
610 if( lastFixedNonzero != -1 && lastFixedNonzero != j + 1 )
612 SCIPdebugMsg(scip,
"The problem is infeasible: two non-consecutive variables have bounds that keep them from being 0.\n");
618 if( nfixednonzeros > 2 )
620 SCIPdebugMsg(scip,
"The problem is infeasible: more than two variables have bounds that keep them from being 0.\n");
625 if( lastFixedNonzero == -1)
626 lastFixedNonzero = j;
633 if( j == consdata->nvars - 1 )
643 else if( lastzero > j + 1 )
647 lastzero = consdata->nvars;
651 assert(vars == consdata->vars);
654 if( lastzero < consdata->nvars )
656 assert(lastzero >= 0);
658 for( j = lastzero; j >= 0; --j )
666 localnremovedvars += (lastzero + 1);
671 assert(vars == consdata->vars);
673 *nremovedvars += localnremovedvars;
676 if( lastFixedNonzero >= 0 )
678 lastFixedNonzero -= localnremovedvars;
679 assert(0 <= lastFixedNonzero && lastFixedNonzero < consdata->nvars);
684 if( consdata->nvars <= 2 )
686 SCIPdebugMsg(scip,
"Deleting constraint with <= 2 variables.\n");
697 oldnfixedvars = *nfixedvars;
700 if ( nfixednonzeros == 1 )
702 assert(0 <= lastFixedNonzero && lastFixedNonzero < consdata->nvars);
707 for( j = 0; j < lastFixedNonzero - 1; ++j )
721 for( j = lastFixedNonzero + 2; j < consdata->nvars; ++j )
736 if( *nfixedvars > oldnfixedvars )
740 else if ( nfixednonzeros == 2 )
742 assert(0 < lastFixedNonzero && lastFixedNonzero < consdata->nvars);
750 for( j = 0; j < lastFixedNonzero - 1; ++j )
764 for( j = lastFixedNonzero + 1; j < consdata->nvars; ++j )
801 assert( scip !=
NULL );
802 assert( cons !=
NULL );
803 assert( consdata !=
NULL );
804 assert( cutoff !=
NULL );
805 assert( ngen !=
NULL );
811 if ( consdata->nfixednonzeros > 2 )
813 SCIPdebugMsg(scip,
"the node is infeasible, more than 2 variables are fixed to be nonzero.\n");
820 if ( consdata->nfixednonzeros == 1 )
826 int firstFixedNonzero;
830 firstFixedNonzero = -1;
831 nvars = consdata->nvars;
832 vars = consdata->vars;
833 assert( vars !=
NULL );
836 for (j = 0; j < nvars; ++j)
840 firstFixedNonzero = j;
844 assert( firstFixedNonzero >= 0 );
846 SCIPdebugMsg(scip,
"variable <%s> is nonzero, fixing variables with distance at least 2 to 0.\n",
SCIPvarGetName(vars[firstFixedNonzero]));
849 for (j = 0; j < firstFixedNonzero-1; ++j)
853 assert( ! infeasible );
860 for (j = firstFixedNonzero+2; j < nvars; ++j)
869 SCIPdebugMsg(scip,
"the node is infeasible: variable <%s> is fixed nonzero and variable <%s> with distance at least 2 as well.\n",
881 else if ( consdata->nfixednonzeros == 2 )
888 int firstFixedNonzero;
892 firstFixedNonzero = -1;
893 nvars = consdata->nvars;
894 vars = consdata->vars;
895 assert( vars !=
NULL );
898 for (j = 0; j < nvars; ++j)
902 firstFixedNonzero = j;
906 assert( 0 <= firstFixedNonzero && firstFixedNonzero < nvars-1 );
908 SCIPdebugMsg(scip,
"variable <%s> is fixed to be nonzero, fixing variables to 0.\n",
SCIPvarGetName(vars[firstFixedNonzero]));
912 for (j = 0; j < firstFixedNonzero; ++j)
916 assert( ! infeasible );
917 allVarFixed = allVarFixed && success;
923 for (j = firstFixedNonzero+2; j < nvars; ++j)
932 SCIPdebugMsg(scip,
"the node is infeasible: variable <%s> is fixed nonzero and variable <%s> with distance at least 2 as well.\n",
937 allVarFixed = allVarFixed && success;
953 if ( *ngen > ngenold )
1012 assert( scip !=
NULL );
1013 assert( conshdlr !=
NULL );
1014 assert( conss !=
NULL );
1015 assert( result !=
NULL );
1024 for (c = 0; c < nconss; ++c)
1037 assert( cons !=
NULL );
1040 assert( consdata !=
NULL );
1042 nvars = consdata->nvars;
1043 vars = consdata->vars;
1071 for (j = 0; j < nvars; ++j)
1091 assert( 0 < lastNonzero && lastNonzero < nvars );
1096 w = weight1/weight2;
1099 assert( 0 <= ind && ind < nvars-1 );
1106 if ( cnt > maxNonzeros )
1115 if ( branchCons ==
NULL )
1117 SCIPdebugMsg(scip,
"All SOS2 constraints are feasible.\n");
1123 assert( consdata !=
NULL );
1124 nvars = consdata->nvars;
1125 vars = consdata->vars;
1127 assert( 0 < maxInd && maxInd < nvars-1 );
1136 for (j = 0; j < maxInd; ++j)
1147 for (j = 0; j < maxInd; ++j)
1150 assert( ! infeasible );
1156 for (j = maxInd+1; j < nvars; ++j)
1162 objest = objest/((
SCIP_Real) (nvars-maxInd-1));
1166 for (j = maxInd+1; j < nvars; ++j)
1169 assert( ! infeasible );
1213 assert( scip !=
NULL );
1214 assert( conshdlr !=
NULL );
1215 assert( cons !=
NULL );
1218 assert( consdata !=
NULL );
1219 assert( consdata->row ==
NULL );
1221 nvars = consdata->nvars;
1222 vars = consdata->vars;
1223 assert( vars !=
NULL );
1226 for (j = 0; j < nvars; ++j)
1262 lhs = minLb + minLb2;
1263 rhs = maxUb + maxUb2;
1279 consdata->row = row;
1294 assert( scip !=
NULL );
1295 assert( conshdlr !=
NULL );
1313 assert( scip !=
NULL );
1314 assert( conshdlr !=
NULL );
1318 assert(conshdlrdata !=
NULL);
1332 assert( scip !=
NULL );
1333 assert( conshdlr !=
NULL );
1337 for (c = 0; c < nconss; ++c)
1341 assert( conss !=
NULL );
1342 assert( conss[c] !=
NULL );
1344 assert( consdata !=
NULL );
1349 if ( consdata->row !=
NULL )
1362 assert( scip !=
NULL );
1363 assert( conshdlr !=
NULL );
1364 assert( cons !=
NULL );
1365 assert( consdata !=
NULL );
1378 assert( conshdlrdata !=
NULL );
1379 assert( conshdlrdata->eventhdlr !=
NULL );
1381 for (j = 0; j < (*consdata)->nvars; ++j)
1389 if ( (*consdata)->weights !=
NULL )
1395 if ( (*consdata)->row !=
NULL )
1399 assert( (*consdata)->row ==
NULL );
1417 assert( scip !=
NULL );
1418 assert( conshdlr !=
NULL );
1420 assert( sourcecons !=
NULL );
1421 assert( targetcons !=
NULL );
1425 assert( conshdlrdata !=
NULL );
1426 assert( conshdlrdata->eventhdlr !=
NULL );
1432 assert( sourcedata !=
NULL );
1433 assert( sourcedata->nvars > 0 );
1434 assert( sourcedata->nvars <= sourcedata->maxvars );
1439 consdata->nvars = sourcedata->nvars;
1440 consdata->maxvars = sourcedata->nvars;
1441 consdata->row =
NULL;
1442 consdata->nfixednonzeros = 0;
1446 if ( sourcedata->weights !=
NULL )
1451 consdata->weights =
NULL;
1453 for (j = 0; j < sourcedata->nvars; ++j)
1455 assert( sourcedata->vars[j] != 0 );
1460 ++(consdata->nfixednonzeros);
1473 for (j = 0; j < consdata->nvars; ++j)
1480 if ( consdata->nfixednonzeros > 0 )
1482 SCIPdebugMsg(scip,
"constraint <%s> has %d variables fixed to be nonzero.\n",
SCIPconsGetName(*targetcons), consdata->nfixednonzeros );
1502 assert( scip !=
NULL );
1503 assert( conshdlr !=
NULL );
1505 assert( result !=
NULL );
1508 SCIPdebug( oldnfixedvars = *nfixedvars; )
1513 if( nrounds == 0 || nnewfixedvars > 0 || nnewaggrvars > 0 || nnewchgcoefs > 0 )
1518 assert( eventhdlr !=
NULL );
1523 for (c = 0; c < nconss; ++c)
1530 assert( conss !=
NULL );
1531 assert( conss[c] !=
NULL );
1536 assert( consdata !=
NULL );
1537 assert( consdata->nvars >= 0 );
1538 assert( consdata->nvars <= consdata->maxvars );
1542 SCIP_CALL(
presolRoundSOS2(scip, cons, consdata, eventhdlr, &cutoff, &success, ndelconss, nfixedvars, &nremovedvars) );
1554 (*nchgcoefs) += nremovedvars;
1556 SCIPdebugMsg(scip,
"presolving fixed %d variables, removed %d variables, and deleted %d constraints.\n",
1557 *nfixedvars - oldnfixedvars, nremovedvars, *ndelconss - oldndelconss);
1569 assert( scip !=
NULL );
1570 assert( conshdlr !=
NULL );
1573 *infeasible =
FALSE;
1576 for (c = 0; c < nconss && !(*infeasible); ++c)
1580 assert( conss !=
NULL );
1581 assert( conss[c] !=
NULL );
1583 assert( consdata !=
NULL );
1588 if ( consdata->row ==
NULL )
1615 assert( scip !=
NULL );
1616 assert( conshdlr !=
NULL );
1617 assert( conss !=
NULL );
1619 assert( result !=
NULL );
1624 for (c = 0; c < nconss && ! cutoff; ++c)
1630 assert( conss[c] !=
NULL );
1632 assert( consdata !=
NULL );
1636 row = consdata->row;
1653 SCIPdebugMsg(scip,
"Separated %d SOS2 constraints.\n", ngen);
1656 else if ( ngen > 0 )
1671 assert( scip !=
NULL );
1672 assert( conshdlr !=
NULL );
1673 assert( conss !=
NULL );
1675 assert( result !=
NULL );
1680 for (c = 0; c < nconss && ! cutoff; ++c)
1686 assert( conss[c] !=
NULL );
1688 assert( consdata !=
NULL );
1692 row = consdata->row;
1709 SCIPdebugMsg(scip,
"Separated %d SOS2 constraints.\n", ngen);
1712 else if ( ngen > 0 )
1723 assert( scip !=
NULL );
1724 assert( conshdlr !=
NULL );
1725 assert( conss !=
NULL );
1727 assert( result !=
NULL );
1739 assert( scip !=
NULL );
1740 assert( conshdlr !=
NULL );
1741 assert( conss !=
NULL );
1743 assert( result !=
NULL );
1755 assert( scip !=
NULL );
1756 assert( conshdlr !=
NULL );
1757 assert( conss !=
NULL );
1759 assert( result !=
NULL );
1778 assert( scip !=
NULL );
1779 assert( conshdlr !=
NULL );
1780 assert( conss !=
NULL );
1782 assert( result !=
NULL );
1787 for (c = 0; c < nconss && (*result ==
SCIP_FEASIBLE || completely); ++c)
1794 assert( conss[c] !=
NULL );
1796 assert( consdata !=
NULL );
1800 for (j = 0; j < consdata->nvars; ++j)
1805 if ( firstNonzero < 0 )
1810 if ( j > firstNonzero+1 )
1844 assert( scip !=
NULL );
1845 assert( conshdlr !=
NULL );
1846 assert( conss !=
NULL );
1848 assert( result !=
NULL );
1854 for (c = 0; c < nconss; ++c)
1860 assert( conss[c] !=
NULL );
1863 assert( consdata !=
NULL );
1893 assert( scip !=
NULL );
1894 assert( cons !=
NULL );
1896 assert( infervar !=
NULL );
1897 assert( bdchgidx !=
NULL );
1898 assert( result !=
NULL );
1904 assert( consdata !=
NULL );
1905 assert( 0 <= inferinfo && inferinfo < consdata->nvars );
1906 var = consdata->vars[inferinfo];
1907 assert( var != infervar );
1947 assert( scip !=
NULL );
1948 assert( conshdlr !=
NULL );
1949 assert( cons !=
NULL );
1952 assert( consdata !=
NULL );
1956 vars = consdata->vars;
1957 nvars = consdata->nvars;
1958 assert( vars !=
NULL );
1960 for (j = 0; j < nvars; ++j)
1985 assert( scip !=
NULL );
1986 assert( conshdlr !=
NULL );
1987 assert( cons !=
NULL );
1991 assert( consdata !=
NULL );
1993 for (j = 0; j < consdata->nvars; ++j)
1998 if ( consdata->weights ==
NULL )
2017 const char* consname;
2021 assert( scip !=
NULL );
2022 assert( sourcescip !=
NULL );
2023 assert( sourcecons !=
NULL );
2033 SCIPdebugMsg(scip,
"Copying SOS2 constraint <%s> ...\n", consname);
2036 assert( sourceconsdata !=
NULL );
2039 nvars = sourceconsdata->nvars;
2044 sourcevars = sourceconsdata->vars;
2045 assert( sourcevars !=
NULL );
2046 sourceweights = sourceconsdata->weights;
2047 assert( sourceweights !=
NULL );
2054 for( v = 0; v < nvars && *valid; ++v )
2056 SCIP_CALL(
SCIPgetVarCopy(sourcescip, scip, sourcevars[v], &(targetvars[v]), varmap, consmap, global, valid) );
2063 initial, separate, enforce, check, propagate, local, dynamic, removable, stickingatnode) );
2087 SCIP_CALL(
SCIPcreateConsSOS2(scip, cons, name, 0,
NULL,
NULL, initial, separate, enforce, check, propagate, local, dynamic, removable, stickingatnode) );
2097 while ( *s !=
'\0' && *s !=
'(' )
2110 weight = strtod(s, &t);
2120 while ( *s !=
'\0' && ( isspace((
unsigned char)*s) || *s ==
',' || *s ==
')' ) )
2126 while ( *s !=
'\0' );
2139 assert(consdata !=
NULL);
2141 if( varssize < consdata->nvars )
2145 assert(vars !=
NULL);
2162 assert(consdata !=
NULL);
2164 (*nvars) = consdata->nvars;
2184 assert( eventhdlr !=
NULL );
2185 assert( eventdata !=
NULL );
2187 assert( event !=
NULL );
2190 assert( consdata !=
NULL );
2191 assert( 0 <= consdata->nfixednonzeros && consdata->nfixednonzeros <= consdata->nvars );
2197 switch ( eventtype )
2202 ++(consdata->nfixednonzeros);
2207 ++(consdata->nfixednonzeros);
2212 --(consdata->nfixednonzeros);
2217 --(consdata->nfixednonzeros);
2223 assert( 0 <= consdata->nfixednonzeros && consdata->nfixednonzeros <= consdata->nvars );
2226 oldbound, newbound, consdata->nfixednonzeros);
2245 conshdlrdata->eventhdlr =
NULL;
2248 eventExecSOS2,
NULL) );
2249 if ( conshdlrdata->eventhdlr ==
NULL )
2258 consEnfolpSOS2, consEnfopsSOS2, consCheckSOS2, consLockSOS2, conshdlrdata) );
2259 assert(conshdlr !=
NULL);
2327 if ( conshdlr ==
NULL )
2335 consdata->vars =
NULL;
2336 consdata->nvars = nvars;
2337 consdata->maxvars = nvars;
2338 consdata->row =
NULL;
2339 consdata->nfixednonzeros = -1;
2340 consdata->weights =
NULL;
2346 if ( weights !=
NULL )
2356 assert( weights ==
NULL );
2359 SCIP_CALL(
SCIPcreateCons(scip, cons, name, conshdlr, consdata, initial, separate, enforce, check, propagate,
2360 local, modifiable, dynamic, removable, stickingatnode) );
2382 SCIP_CALL(
SCIPcreateConsSOS2( scip, cons, name, nvars, vars, weights,
TRUE,
TRUE,
TRUE,
TRUE,
TRUE,
FALSE,
FALSE,
FALSE,
FALSE) );
2396 assert( scip !=
NULL );
2397 assert( var !=
NULL );
2398 assert( cons !=
NULL );
2421 assert( scip !=
NULL );
2422 assert( var !=
NULL );
2423 assert( cons !=
NULL );
2447 assert( scip !=
NULL );
2448 assert( cons !=
NULL );
2458 assert( consdata !=
NULL );
2460 return consdata->nvars;
2472 assert( scip !=
NULL );
2473 assert( cons !=
NULL );
2483 assert( consdata !=
NULL );
2485 return consdata->vars;
2497 assert( scip !=
NULL );
2498 assert( cons !=
NULL );
2508 assert( consdata !=
NULL );
2510 return consdata->weights;
enum SCIP_Result SCIP_RESULT
#define SCIPfreeBlockMemoryArray(scip, ptr, num)
SCIP_RETCODE SCIPaddVarsToRowSameCoef(SCIP *scip, SCIP_ROW *row, int nvars, SCIP_VAR **vars, SCIP_Real val)
SCIP_Bool SCIPisFeasZero(SCIP *scip, SCIP_Real val)
#define SCIPreallocBlockMemoryArray(scip, ptr, oldnum, newnum)
SCIP_RETCODE SCIPsetConshdlrDelete(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSDELETE((*consdelete)))
static SCIP_DECL_CONSSEPALP(consSepalpSOS2)
#define SCIPallocBlockMemoryArray(scip, ptr, num)
SCIP_Real SCIPgetVarUbAtIndex(SCIP *scip, SCIP_VAR *var, SCIP_BDCHGIDX *bdchgidx, SCIP_Bool after)
SCIP_Bool SCIPconsIsDynamic(SCIP_CONS *cons)
SCIP_RETCODE SCIPsetConshdlrTrans(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSTRANS((*constrans)))
SCIP_Bool SCIPisFeasLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Real SCIPgetVarLbAtIndex(SCIP *scip, SCIP_VAR *var, SCIP_BDCHGIDX *bdchgidx, SCIP_Bool after)
#define CONSHDLR_EAGERFREQ
static SCIP_RETCODE deleteVarSOS2(SCIP *scip, SCIP_CONS *cons, SCIP_CONSDATA *consdata, SCIP_EVENTHDLR *eventhdlr, int pos)
SCIP_RETCODE SCIPcatchVarEvent(SCIP *scip, SCIP_VAR *var, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int *filterpos)
SCIP_CONSHDLR * SCIPfindConshdlr(SCIP *scip, const char *name)
static SCIP_DECL_CONSPRESOL(consPresolSOS2)
static SCIP_RETCODE fixVariableZeroNode(SCIP *scip, SCIP_VAR *var, SCIP_NODE *node, SCIP_Bool *infeasible)
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
SCIP_RETCODE SCIPsetConshdlrGetVars(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSGETVARS((*consgetvars)))
SCIP_RETCODE SCIPsetConshdlrEnforelax(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSENFORELAX((*consenforelax)))
SCIP_RETCODE SCIPresetConsAge(SCIP *scip, SCIP_CONS *cons)
static SCIP_RETCODE presolRoundSOS2(SCIP *scip, SCIP_CONS *cons, SCIP_CONSDATA *consdata, SCIP_EVENTHDLR *eventhdlr, SCIP_Bool *cutoff, SCIP_Bool *success, int *ndelconss, int *nfixedvars, int *nremovedvars)
#define CONSHDLR_DELAYPROP
SCIP_RETCODE SCIPdelCons(SCIP *scip, SCIP_CONS *cons)
int SCIPcalcMemGrowSize(SCIP *scip, int num)
SCIP_RETCODE SCIPaddVarToRow(SCIP *scip, SCIP_ROW *row, SCIP_VAR *var, SCIP_Real val)
SCIP_RETCODE SCIPaddVarSOS2(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real weight)
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
SCIP_RETCODE SCIPchgVarLbNode(SCIP *scip, SCIP_NODE *node, SCIP_VAR *var, SCIP_Real newbound)
SCIP_RETCODE SCIPincludeEventhdlrBasic(SCIP *scip, SCIP_EVENTHDLR **eventhdlrptr, const char *name, const char *desc, SCIP_DECL_EVENTEXEC((*eventexec)), SCIP_EVENTHDLRDATA *eventhdlrdata)
SCIP_RETCODE SCIPgetTransformedVar(SCIP *scip, SCIP_VAR *var, SCIP_VAR **transvar)
SCIP_RETCODE SCIPparseVarName(SCIP *scip, const char *str, SCIP_VAR **var, char **endptr)
SCIP_Bool SCIPisFeasNegative(SCIP *scip, SCIP_Real val)
static SCIP_RETCODE unlockVariableSOS2(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var)
SCIP_Real SCIProwGetLhs(SCIP_ROW *row)
static SCIP_DECL_CONSRESPROP(consRespropSOS2)
const char * SCIPeventhdlrGetName(SCIP_EVENTHDLR *eventhdlr)
SCIP_RETCODE SCIPincludeConshdlrBasic(SCIP *scip, SCIP_CONSHDLR **conshdlrptr, const char *name, const char *desc, int enfopriority, int chckpriority, int eagerfreq, SCIP_Bool needscons, SCIP_DECL_CONSENFOLP((*consenfolp)), SCIP_DECL_CONSENFOPS((*consenfops)), SCIP_DECL_CONSCHECK((*conscheck)), SCIP_DECL_CONSLOCK((*conslock)), SCIP_CONSHDLRDATA *conshdlrdata)
static SCIP_DECL_CONSINITLP(consInitlpSOS2)
SCIP_Real SCIPinfinity(SCIP *scip)
int SCIPsnprintf(char *t, int len, const char *s,...)
enum SCIP_Retcode SCIP_RETCODE
static SCIP_RETCODE inferVariableZero(SCIP *scip, SCIP_VAR *var, SCIP_CONS *cons, int inferinfo, SCIP_Bool *infeasible, SCIP_Bool *tightened, SCIP_Bool *success)
SCIP_RETCODE SCIPaddConflictUb(SCIP *scip, SCIP_VAR *var, SCIP_BDCHGIDX *bdchgidx)
SCIP_RETCODE SCIPaddVarLocks(SCIP *scip, SCIP_VAR *var, int nlocksdown, int nlocksup)
SCIP_Bool SCIPconsIsStickingAtNode(SCIP_CONS *cons)
SCIP_Bool SCIPconsIsTransformed(SCIP_CONS *cons)
#define SCIPfreeBlockMemory(scip, ptr)
SCIP_RETCODE SCIPsetConshdlrSepa(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSSEPALP((*conssepalp)), SCIP_DECL_CONSSEPASOL((*conssepasol)), int sepafreq, int sepapriority, SCIP_Bool delaysepa)
static SCIP_RETCODE enforceSOS2(SCIP *scip, SCIP_CONSHDLR *conshdlr, int nconss, SCIP_CONS **conss, SCIP_SOL *sol, SCIP_RESULT *result)
SCIP_RETCODE SCIPchgVarUbNode(SCIP *scip, SCIP_NODE *node, SCIP_VAR *var, SCIP_Real newbound)
#define SCIPduplicateBufferArray(scip, ptr, source, num)
int SCIPgetNVarsSOS2(SCIP *scip, SCIP_CONS *cons)
#define SCIPfreeBufferArray(scip, ptr)
#define SCIPallocBlockMemory(scip, ptr)
SCIP_Bool SCIPisTransformed(SCIP *scip)
SCIP_Bool SCIPconsIsRemovable(SCIP_CONS *cons)
#define SCIP_EVENTTYPE_BOUNDCHANGED
SCIP_RETCODE SCIPsetConshdlrInitlp(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSINITLP((*consinitlp)))
#define CONSHDLR_MAXPREROUNDS
SCIP_RETCODE SCIPsetConshdlrParse(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSPARSE((*consparse)))
static SCIP_DECL_CONSLOCK(consLockSOS2)
void SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...)
SCIP_RETCODE SCIPcreateCons(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_CONSHDLR *conshdlr, SCIP_CONSDATA *consdata, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
SCIP_RETCODE SCIPaddConflictLb(SCIP *scip, SCIP_VAR *var, SCIP_BDCHGIDX *bdchgidx)
SCIP_Real SCIPfeasFloor(SCIP *scip, SCIP_Real val)
static SCIP_DECL_CONSENFOPS(consEnfopsSOS2)
SCIP_Bool SCIProwIsInLP(SCIP_ROW *row)
#define SCIP_EVENTTYPE_LBRELAXED
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
#define SCIPduplicateBlockMemoryArray(scip, ptr, source, num)
SCIP_Bool SCIPisCutEfficacious(SCIP *scip, SCIP_SOL *sol, SCIP_ROW *cut)
SCIP_Real SCIPeventGetNewbound(SCIP_EVENT *event)
SCIP_RETCODE SCIPsetConshdlrCopy(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSHDLRCOPY((*conshdlrcopy)), SCIP_DECL_CONSCOPY((*conscopy)))
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
static SCIP_DECL_CONSDELETE(consDeleteSOS2)
SCIP_RETCODE SCIPdelConsLocal(SCIP *scip, SCIP_CONS *cons)
SCIP_VAR ** SCIPgetVarsSOS2(SCIP *scip, SCIP_CONS *cons)
static SCIP_DECL_CONSEXITSOL(consExitsolSOS2)
SCIP_RETCODE SCIPincludeConshdlrSOS2(SCIP *scip)
SCIP_RETCODE SCIPgetProbvarSum(SCIP *scip, SCIP_VAR **var, SCIP_Real *scalar, SCIP_Real *constant)
SCIP_RETCODE SCIPunlockVarCons(SCIP *scip, SCIP_VAR *var, SCIP_CONS *cons, SCIP_Bool lockdown, SCIP_Bool lockup)
static SCIP_DECL_CONSGETVARS(consGetVarsSOS2)
const char * SCIPconsGetName(SCIP_CONS *cons)
SCIP_Bool SCIPconsIsPropagated(SCIP_CONS *cons)
struct SCIP_EventData SCIP_EVENTDATA
const char * SCIPvarGetName(SCIP_VAR *var)
SCIP_RETCODE SCIPsetConshdlrFree(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSFREE((*consfree)))
SCIP_CONSHDLRDATA * SCIPconshdlrGetData(SCIP_CONSHDLR *conshdlr)
#define CONSHDLR_DELAYSEPA
#define SCIP_EVENTTYPE_UBRELAXED
SCIP_RETCODE SCIPcreateChild(SCIP *scip, SCIP_NODE **node, SCIP_Real nodeselprio, SCIP_Real estimate)
static SCIP_RETCODE generateRowSOS2(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_CONS *cons, SCIP_Bool local)
#define SCIP_EVENTTYPE_LBTIGHTENED
#define CONSHDLR_ENFOPRIORITY
#define CONSHDLR_SEPAPRIORITY
SCIP_Bool SCIPisFeasGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Real SCIProwGetRhs(SCIP_ROW *row)
void SCIPverbMessage(SCIP *scip, SCIP_VERBLEVEL msgverblevel, FILE *file, const char *formatstr,...)
SCIP_Bool SCIPconsIsLocal(SCIP_CONS *cons)
static SCIP_DECL_CONSPARSE(consParseSOS2)
SCIP_RETCODE SCIPsetConshdlrResprop(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSRESPROP((*consresprop)))
SCIP_RETCODE SCIPaddCut(SCIP *scip, SCIP_SOL *sol, SCIP_ROW *cut, SCIP_Bool forcecut, SCIP_Bool *infeasible)
struct SCIP_ConsData SCIP_CONSDATA
SCIP_RETCODE SCIPcreateConsBasicSOS2(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *weights)
static SCIP_DECL_CONSFREE(consFreeSOS2)
static SCIP_DECL_CONSENFOLP(consEnfolpSOS2)
SCIP_RETCODE SCIPaddConsNode(SCIP *scip, SCIP_NODE *node, SCIP_CONS *cons, SCIP_NODE *validnode)
#define SCIPallocBufferArray(scip, ptr, num)
public data structures and miscellaneous methods
SCIP_VAR * SCIPeventGetVar(SCIP_EVENT *event)
SCIP_RETCODE SCIPchgRowRhs(SCIP *scip, SCIP_ROW *row, SCIP_Real rhs)
SCIP_EVENTTYPE SCIPeventGetType(SCIP_EVENT *event)
SCIP_RETCODE SCIPcreateEmptyRowCons(SCIP *scip, SCIP_ROW **row, SCIP_CONSHDLR *conshdlr, const char *name, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool removable)
SCIP_Real * SCIPgetWeightsSOS2(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPprintCons(SCIP *scip, SCIP_CONS *cons, FILE *file)
static SCIP_DECL_CONSHDLRCOPY(conshdlrCopySOS2)
static SCIP_RETCODE consdataEnsurevarsSizeSOS2(SCIP *scip, SCIP_CONSDATA *consdata, int num, SCIP_Bool reserveWeights)
SCIP_CONSHDLR * SCIPconsGetHdlr(SCIP_CONS *cons)
SCIP_RETCODE SCIPchgRowLhs(SCIP *scip, SCIP_ROW *row, SCIP_Real lhs)
SCIP_Bool SCIPconsIsChecked(SCIP_CONS *cons)
SCIP_Bool SCIPconsIsInitial(SCIP_CONS *cons)
static SCIP_DECL_CONSPROP(consPropSOS2)
static SCIP_RETCODE appendVarSOS2(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var)
SCIP_RETCODE SCIPdropVarEvent(SCIP *scip, SCIP_VAR *var, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int filterpos)
static SCIP_DECL_EVENTEXEC(eventExecSOS2)
SCIP_Real SCIPcalcNodeselPriority(SCIP *scip, SCIP_VAR *var, SCIP_BRANCHDIR branchdir, SCIP_Real targetvalue)
#define CONSHDLR_PROP_TIMING
SCIP_RETCODE SCIPfixVar(SCIP *scip, SCIP_VAR *var, SCIP_Real fixedval, SCIP_Bool *infeasible, SCIP_Bool *fixed)
#define BMScopyMemoryArray(ptr, source, num)
SCIP_RETCODE SCIPlockVarCons(SCIP *scip, SCIP_VAR *var, SCIP_CONS *cons, SCIP_Bool lockdown, SCIP_Bool lockup)
SCIP_RETCODE SCIPsetConshdlrPrint(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSPRINT((*consprint)))
#define SCIP_EVENTTYPE_UBTIGHTENED
Constraint handler for linear constraints in their most general form, .
static SCIP_DECL_CONSTRANS(consTransSOS2)
static SCIP_DECL_CONSENFORELAX(consEnforelaxSOS2)
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
SCIP_RETCODE SCIPinferVarLbCons(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound, SCIP_CONS *infercons, int inferinfo, SCIP_Bool force, SCIP_Bool *infeasible, SCIP_Bool *tightened)
#define CONSHDLR_PRESOLTIMING
static SCIP_DECL_CONSPRINT(consPrintSOS2)
SCIP_Real SCIPcalcChildEstimate(SCIP *scip, SCIP_VAR *var, SCIP_Real targetvalue)
SCIP_RETCODE SCIPcreateConsLinear(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *vals, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
SCIP_RETCODE SCIPreleaseRow(SCIP *scip, SCIP_ROW **row)
SCIP_RETCODE SCIPgetVarCopy(SCIP *sourcescip, SCIP *targetscip, SCIP_VAR *sourcevar, SCIP_VAR **targetvar, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, SCIP_Bool *success)
SCIP_CONSDATA * SCIPconsGetData(SCIP_CONS *cons)
SCIP_RETCODE SCIPinferVarUbCons(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound, SCIP_CONS *infercons, int inferinfo, SCIP_Bool force, SCIP_Bool *infeasible, SCIP_Bool *tightened)
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
static SCIP_DECL_CONSSEPASOL(consSepasolSOS2)
SCIP_RETCODE SCIPsetConshdlrPresol(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSPRESOL((*conspresol)), int maxprerounds, SCIP_PRESOLTIMING presoltiming)
static SCIP_RETCODE branchCons(SCIP *scip, SCIP_CONS *cons, SCIP_RESULT *result)
SCIP_Real SCIPeventGetOldbound(SCIP_EVENT *event)
SCIP_Bool SCIPisFeasPositive(SCIP *scip, SCIP_Real val)
SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
SCIP_Bool SCIPconsIsModifiable(SCIP_CONS *cons)
static SCIP_RETCODE handleNewVariableSOS2(SCIP *scip, SCIP_CONS *cons, SCIP_CONSDATA *consdata, SCIP_VAR *var, SCIP_Bool transformed)
SCIP_RETCODE SCIPsetConshdlrGetNVars(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSGETNVARS((*consgetnvars)))
SCIP_Bool SCIPconsIsEnforced(SCIP_CONS *cons)
SCIP_Bool SCIPconsIsSeparated(SCIP_CONS *cons)
SCIP_RETCODE SCIPprintRow(SCIP *scip, SCIP_ROW *row, FILE *file)
void SCIPsortRealPtr(SCIP_Real *realarray, void **ptrarray, int len)
#define CONSHDLR_PROPFREQ
#define CONSHDLR_NEEDSCONS
static SCIP_DECL_CONSGETNVARS(consGetNVarsSOS2)
SCIP_Bool SCIPisZero(SCIP *scip, SCIP_Real val)
static SCIP_RETCODE lockVariableSOS2(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var)
struct SCIP_ConshdlrData SCIP_CONSHDLRDATA
constraint handler for SOS type 2 constraints
SCIP_RETCODE SCIPcreateConsSOS2(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *weights, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
#define CONSHDLR_CHECKPRIORITY
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
SCIP_Bool SCIPvarIsTransformed(SCIP_VAR *var)
#define CONSHDLR_SEPAFREQ
static SCIP_RETCODE addVarSOS2(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real weight)
static SCIP_RETCODE propSOS2(SCIP *scip, SCIP_CONS *cons, SCIP_CONSDATA *consdata, SCIP_Bool *cutoff, int *ngen)
SCIP_RETCODE SCIPsetConshdlrExitsol(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSEXITSOL((*consexitsol)))
SCIP_RETCODE SCIPwriteVarName(SCIP *scip, FILE *file, SCIP_VAR *var, SCIP_Bool type)
SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
static SCIP_DECL_CONSCOPY(consCopySOS2)
SCIP_RETCODE SCIPappendVarSOS2(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var)
static SCIP_DECL_CONSCHECK(consCheckSOS2)
SCIP_RETCODE SCIPsetConshdlrProp(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSPROP((*consprop)), int propfreq, SCIP_Bool delayprop, SCIP_PROPTIMING proptiming)