45 #define CONSHDLR_NAME "cardinality" 46 #define CONSHDLR_DESC "cardinality constraint handler" 47 #define CONSHDLR_SEPAPRIORITY 10 48 #define CONSHDLR_ENFOPRIORITY 100 49 #define CONSHDLR_CHECKPRIORITY -10 50 #define CONSHDLR_SEPAFREQ 10 51 #define CONSHDLR_PROPFREQ 1 52 #define CONSHDLR_EAGERFREQ 100 54 #define CONSHDLR_MAXPREROUNDS -1 56 #define CONSHDLR_DELAYSEPA FALSE 57 #define CONSHDLR_DELAYPROP FALSE 58 #define CONSHDLR_NEEDSCONS TRUE 60 #define CONSHDLR_PROP_TIMING SCIP_PROPTIMING_BEFORELP 61 #define CONSHDLR_PRESOLTIMING SCIP_PRESOLTIMING_FAST 64 #define DEFAULT_BRANCHBALANCED FALSE 65 #define DEFAULT_BALANCEDDEPTH 20 66 #define DEFAULT_BALANCEDCUTOFF 2.0 70 #define EVENTHDLR_NAME "cardinality" 71 #define EVENTHDLR_DESC "bound change event handler for cardinality constraints" 85 int neventdatascurrent;
96 struct SCIP_ConshdlrData
107 struct SCIP_EventData
113 unsigned int varmarked:1;
114 unsigned int indvarmarked:1;
129 assert(eventhdlr != NULL);
130 assert(consdata != NULL);
132 assert(indvar != NULL);
138 (*eventdata)->consdata = consdata;
139 (*eventdata)->var = var;
140 (*eventdata)->indvar = indvar;
141 (*eventdata)->varmarked =
FALSE;
142 (*eventdata)->indvarmarked =
FALSE;
143 (*eventdata)->pos = (
unsigned int)pos;
163 assert(eventhdlr != NULL);
164 assert(consdata != NULL);
166 assert(indvar != NULL);
167 assert(eventdata != NULL);
213 SCIP_CALL(
SCIPcreateConsLinear(scip, &cons,
"branch", 1, &var, &val, 0.0, 0.0,
TRUE,
TRUE,
TRUE,
TRUE,
TRUE,
251 assert(scip != NULL);
253 assert(infeasible != NULL);
254 assert(tightened != NULL);
279 for( i = 0; i < naggrvars; ++i )
284 allnonnegative =
FALSE;
292 for( i = 0; i < naggrvars; ++i )
298 *tightened = *tightened || fixed;
320 assert(scip != NULL);
321 assert(cons != NULL);
341 assert(scip != NULL);
342 assert(cons != NULL);
362 assert(consdata != NULL);
363 assert(consdata->nvars <= consdata->maxvars);
365 if( num > consdata->maxvars )
376 if ( reserveweights )
380 consdata->maxvars = newsize;
382 assert(num <= consdata->maxvars);
410 assert(scip != NULL);
411 assert(cons != NULL);
412 assert(consdata != NULL);
413 assert(conshdlrdata != NULL);
421 assert(eventdata != NULL );
424 assert(consdata->ntreatnonzeros >= 0 );
426 ++consdata->ntreatnonzeros;
470 assert(cons != NULL);
471 assert(conshdlrdata != NULL);
474 assert(consdata != NULL );
476 if( consdata->weights == NULL && consdata->maxvars > 0 )
478 SCIPerrorMessage(
"cannot add variable to cardinality constraint <%s> that does not contain weights.\n",
486 if( conshdlrdata->varhash == NULL )
497 assert(indvar != NULL);
511 NULL, NULL, NULL, NULL, NULL) );
517 assert(indvar != NULL);
536 assert(indvar != NULL);
542 assert(consdata->weights != NULL);
543 assert(consdata->maxvars >= consdata->nvars+1);
546 for( pos = consdata->nvars; pos >= 1; --pos )
548 if( consdata->weights[pos-1] > weight )
550 consdata->vars[pos] = consdata->vars[pos-1];
551 consdata->indvars[pos] = consdata->indvars[pos-1];
552 consdata->eventdatas[pos] = consdata->eventdatas[pos-1];
553 consdata->weights[pos] = consdata->weights[pos-1];
555 if( consdata->eventdatas[pos] != NULL )
557 consdata->eventdatas[pos]->pos = (
unsigned int)pos;
563 assert(0 <= pos && pos <= consdata->nvars);
567 assert(! transformed || eventdata != NULL);
570 consdata->vars[pos] = var;
571 consdata->indvars[pos] = indvar;
572 consdata->eventdatas[pos] = eventdata;
573 consdata->weights[pos] = weight;
595 assert(cons != NULL);
596 assert(conshdlrdata != NULL);
599 assert(consdata != NULL);
604 if( conshdlrdata->varhash == NULL )
615 assert(indvar != NULL);
629 NULL, NULL, NULL, NULL, NULL) );
635 assert(indvar != NULL);
654 assert(indvar != NULL);
664 assert(!transformed || eventdata != NULL);
667 consdata->vars[consdata->nvars] = var;
668 consdata->indvars[consdata->nvars] = indvar;
669 consdata->eventdatas[consdata->nvars] = eventdata;
671 if( consdata->weights != NULL && consdata->nvars > 0 )
672 consdata->weights[consdata->nvars] = consdata->weights[consdata->nvars-1] + 1.0;
675 assert(consdata->weights != NULL || consdata->nvars > 0);
692 assert(0 <= pos && pos < consdata->nvars);
699 &consdata->eventdatas[pos]) );
703 --(consdata->ntreatnonzeros);
706 for( j = pos; j < consdata->nvars-1; ++j )
708 consdata->vars[j] = consdata->vars[j+1];
709 consdata->indvars[j] = consdata->indvars[j+1];
710 consdata->eventdatas[j] = consdata->eventdatas[j+1];
711 if( consdata->weights != NULL )
712 consdata->weights[j] = consdata->weights[j+1];
714 consdata->eventdatas[j]->pos = (
unsigned int)j;
738 for( c = 0; c < nconss; ++c )
744 assert(cons != NULL);
746 assert(consdata != NULL);
748 nvars = consdata->nvars;
749 vars = consdata->vars;
750 indvars = consdata->indvars;
752 for( j = 0; j < nvars; ++j )
778 eventdatas = consdata->eventdatas;
779 nvars = consdata->nvars;
780 assert(eventdatas != NULL);
782 for( j = 0; j < nvars; ++j )
786 eventdata = eventdatas[j];
787 eventdata->varmarked =
FALSE;
788 eventdata->indvarmarked =
FALSE;
826 assert(scip != NULL);
827 assert(cons != NULL);
828 assert(consdata != NULL);
829 assert(eventhdlr != NULL);
830 assert(cutoff != NULL);
831 assert(success != NULL);
832 assert(ndelconss != NULL);
833 assert(nfixedvars != NULL);
834 assert(nremovedvars != NULL);
843 consdata->neventdatascurrent = 0;
847 allvarsbinary =
TRUE;
848 vars = consdata->vars;
849 indvars = consdata->indvars;
852 while ( j < consdata->nvars )
882 &consdata->eventdatas[j]) );
884 &consdata->eventdatas[j]) );
885 assert(consdata->eventdatas[j] != NULL);
892 consdata->eventdatas[j]->var = var;
896 assert(var == vars[j]);
899 for( l = j+1; l < consdata->nvars; ++l )
901 if( var == vars[l] || oldvar == vars[l] )
955 assert(indub == 1.0);
959 SCIPdebugMsg(scip,
"deleting variable <%s> from constraint <%s>, since it may be treated as nonzero.\n",
961 --(consdata->cardval);
967 assert(indlb == 0.0);
992 allvarsbinary =
FALSE;
999 if( consdata->cardval < 0 )
1001 SCIPdebugMsg(scip,
"The problem is infeasible: more variables have bounds that keep them from being 0 than allowed.\n");
1007 else if( consdata->cardval == 0 )
1010 for( j = 0; j < consdata->nvars; ++j )
1027 if( consdata->nvars <= consdata->cardval )
1029 SCIPdebugMsg(scip,
"Deleting cardinality constraint <%s> with <%d> variables and cardinality value <%d>.\n",
1048 for( j = 0; j < consdata->nvars; ++j )
1101 assert(scip != NULL);
1102 assert(cons != NULL);
1103 assert(consdata != NULL);
1104 assert(cutoff != NULL);
1105 assert(nchgdomain != NULL);
1110 if( consdata->ntreatnonzeros > consdata->cardval )
1112 SCIPdebugMsg(scip,
"the node is infeasible, more than %d variables are fixed to be nonzero.\n", consdata->cardval);
1120 if( consdata->ntreatnonzeros == consdata->cardval )
1131 nvars = consdata->nvars;
1132 vars = consdata->vars;
1133 indvars = consdata->indvars;
1134 assert(vars != NULL);
1135 assert(indvars != NULL);
1139 for( j = 0; j < nvars; ++j )
1157 SCIPdebugMsg(scip,
"the node is infeasible, more than %d variables are fixed to be nonzero.\n",
1167 SCIPdebugMsg(scip,
"fixed variable <%s> to 0, since constraint <%s> with cardinality value %d is \ 1172 allvarfixed =
FALSE;
1176 assert(cnt == consdata->ntreatnonzeros);
1179 if( *nchgdomain > 0 )
1195 if( consdata->neventdatascurrent > 0 )
1202 neventdatas = consdata->neventdatascurrent;
1203 eventvars = consdata->eventvarscurrent;
1204 eventdatas = consdata->eventdatascurrent;
1205 assert(eventdatas != NULL && eventvars != NULL);
1207 for( j = 0; j < neventdatas; ++j )
1214 eventdata = eventdatas[j];
1216 assert(var != NULL && eventdata != NULL);
1217 assert(eventdata->var != NULL);
1218 assert(eventdata->indvar != NULL);
1219 assert(var == eventdata->var || var == eventdata->indvar);
1223 if( eventdata->indvar == var )
1225 assert(eventdata->indvarmarked);
1232 implvar = eventdata->var;
1242 SCIPdebugMsg(scip,
"the node is infeasible, indicator variable %s is fixed to zero although implied " 1252 SCIPdebugMsg(scip,
"fixed variable <%s> to 0, since indicator variable %s is 0.\n",
1258 eventdata->indvarmarked =
FALSE;
1263 assert(eventdata->var == var);
1264 assert(eventdata->varmarked);
1271 indvar = eventdata->indvar;
1280 SCIPdebugMsg(scip,
"the node is infeasible, implied variable %s is fixed to nonzero " 1288 SCIPdebugMsg(scip,
"fixed variable <%s> to 1.0, since implied variable %s is nonzero.\n",
1293 eventdata->varmarked =
FALSE;
1297 consdata->neventdatascurrent = 0;
1326 SCIPdebugMsg(scip,
"apply unbalanced branching on variable <%s> of constraint <%s>.\n",
1337 assert(! infeasible);
1343 assert(branchnnonzero + 1 <= cardval);
1344 if( branchnnonzero + 1 == cardval )
1355 for( j = 0; j < nvars; ++j )
1367 assert(cnt == nvars - (1 + branchnnonzero));
1380 for( j = 0; j < nvars; ++j )
1389 assert(!infeasible);
1442 SCIPerrorMessage(
"balanced branching is only possible if separation frequency of constraint handler is 1.\n");
1457 nbuffer = nvars-branchnnonzero;
1462 for( j = 0; j < nvars; ++j )
1477 weight1 += val * (
SCIP_Real) (j - (nnonzero + nzero));
1479 branchindvars[nbranchvars] = indvars[j];
1480 branchvars[nbranchvars++] = var;
1491 assert(nnonzero == branchnnonzero);
1492 assert(nbranchvars <= nvars - branchnnonzero);
1494 assert(cnt >= cardval-nnonzero);
1496 w = weight1/weight2;
1499 assert(0 <= ind && ind < nbranchvars-1);
1502 for( j = 0; j <= ind; ++j )
1519 for( j = ind+1; j < nbranchvars; ++j )
1538 newcardval = cardval - nnonzero;
1539 splitval1 = sum1 + (
SCIP_Real)newcardval - sum2 - 1.0;
1540 splitval1 =
SCIPfloor(scip, splitval1/2);
1541 splitval1 =
MAX(splitval1, 0);
1542 assert((
int)splitval1 >= 0);
1543 assert((
int)splitval1 <= MIN(newcardval-1, ind));
1545 splitval2 -= splitval1;
1553 branchnnonzero, branchpos) );
1575 for( j = 0; j <= ind; ++j )
1587 for( j = 0; j <= ind; ++j )
1590 assert(!infeasible);
1620 for( j = ind+1; j < nbranchvars; ++j )
1625 assert(nbranchvars - (ind + 1) > 0);
1628 objest = objest/((
SCIP_Real)(nbranchvars - (ind + 1)));
1633 for( j = ind+1; j < nbranchvars; ++j )
1636 assert(!infeasible);
1646 for( j = ind+1; j < nbranchvars; ++j )
1648 branchvars[cnt] = branchvars[j];
1649 branchindvars[cnt++] = branchindvars[j];
1651 assert(cnt == nbranchvars - (ind + 1));
1723 assert(scip != NULL);
1724 assert(conshdlr != NULL);
1725 assert(conss != NULL);
1726 assert(result != NULL);
1730 branchnnonzero = -1;
1738 assert(conshdlrdata != NULL);
1741 for( c = 0; c < nconss; ++c )
1756 assert(cons != NULL);
1758 assert(consdata != NULL);
1764 nvars = consdata->nvars;
1765 vars = consdata->vars;
1766 indvars = consdata->indvars;
1767 cardval = consdata->cardval;
1776 SCIPdebugMsg(scip,
"propagating <%s> in enforcing (cutoff: %u, domain reductions: %d).\n",
1783 if( nchgdomain > 0 )
1788 assert(nchgdomain == 0);
1794 for( j = 0; j < nvars; ++j )
1849 if( nnonzero > cardval )
1851 SCIPdebugMsg(scip,
"Detected cut off: constraint <%s> has %d many variables that can be treated as nonzero, \ 1852 although only %d many are feasible.\n",
SCIPconsGetName(cons), nnonzero, cardval);
1857 else if( cnt > 0 && nnonzero + 1 > cardval )
1862 for( v = 0; v < nvars; ++v )
1875 assert(!infeasible);
1885 if( cnt > cardval - nnonzero && weight > maxweight )
1889 branchnnonzero = nnonzero;
1891 branchallneg = allneg;
1892 branchallpos = allpos;
1897 if( branchcons == NULL )
1908 SCIPdebugMsg(scip,
"All cardinality constraints are feasible.\n");
1911 assert(branchnnonzero >= 0);
1912 assert(branchpos >= 0);
1916 assert(consdata != NULL);
1917 nvars = consdata->nvars;
1918 vars = consdata->vars;
1919 indvars = consdata->indvars;
1920 cardval = consdata->cardval;
1924 if( conshdlrdata->branchbalanced && !
SCIPisFeasNegative(scip, maxweight) && ( branchallneg || branchallpos )
1925 && (conshdlrdata->balanceddepth == -1 ||
SCIPgetDepth(scip) <= conshdlrdata->balanceddepth)
1928 branchbalanced =
TRUE;
1932 if( branchbalanced )
1934 SCIP_CALL(
branchBalancedCardinality(scip, conshdlr, sol, branchcons, vars, indvars, nvars, cardval, branchnnonzero, branchpos,
1935 conshdlrdata->balancedcutoff) );
1985 assert(scip != NULL);
1986 assert(conshdlr != NULL);
1987 assert(cons != NULL);
1990 assert(consdata != NULL);
1991 assert(consdata->vars != NULL);
1992 assert(consdata->indvars != NULL);
1994 nvars = consdata->nvars;
2004 cardval = consdata->cardval;
2005 for( j = 0; j < nvars; ++j )
2021 assert(consdata->vars[j] != NULL);
2022 vars[cnt] = consdata->vars[j];
2023 vals[cnt++] = 1.0/val;
2026 assert(cardval >= 0);
2046 cardval = consdata->cardval;
2047 for( j = 0; j < nvars; ++j )
2063 assert(consdata->vars[j] != NULL);
2064 vars[cnt] = consdata->vars[j];
2065 vals[cnt++] = 1.0/val;
2068 assert(cardval >= 0);
2106 assert(scip != NULL);
2107 assert(conss != NULL);
2111 for( c = nconss-1; c >= 0; --c )
2118 assert(conss != NULL);
2119 assert(conss[c] != NULL);
2121 assert(consdata != NULL);
2137 if( consdata->rowub == NULL || consdata->rowlb == NULL )
2140 (consdata->rowlb == NULL) ? &consdata->rowlb : NULL,
2141 (consdata->rowub == NULL) ? &consdata->rowub : NULL) );
2143 rowub = consdata->rowub;
2144 rowlb = consdata->rowlb;
2217 assert(scip != NULL);
2218 assert(conshdlr != NULL);
2219 assert(conss != NULL);
2220 assert(result != NULL);
2244 SCIPdebugMsg(scip,
"Separated %d bound inequalities.\n", ngen);
2255 assert(scip != NULL);
2256 assert(conshdlr != NULL);
2273 assert(scip != NULL);
2274 assert(conshdlr != NULL);
2278 assert(conshdlrdata != NULL);
2281 if( conshdlrdata->varhash != NULL )
2298 assert(scip != NULL);
2299 assert(conshdlr != NULL);
2303 assert(conshdlrdata != NULL);
2306 for( c = 0; c < nconss; ++c )
2310 assert(conss != NULL);
2311 assert(conss[c] != NULL);
2313 assert(consdata != NULL);
2318 if( consdata->rowub != NULL )
2322 if( consdata->rowlb != NULL )
2329 if( conshdlrdata->varhash != NULL )
2341 assert(scip != NULL);
2342 assert(conshdlr != NULL);
2343 assert(cons != NULL);
2344 assert(consdata != NULL);
2357 assert(conshdlrdata != NULL);
2358 assert(conshdlrdata->eventhdlr != NULL);
2360 for( j = 0; j < (*consdata)->nvars; ++j )
2363 (*consdata)->indvars[j], &(*consdata)->eventdatas[j]) );
2364 assert((*consdata)->eventdatas[j] == NULL);
2368 if( (*consdata)->weights != NULL )
2379 if( (*consdata)->rowub != NULL )
2383 if( (*consdata)->rowlb != NULL )
2387 assert((*consdata)->rowub == NULL);
2388 assert((*consdata)->rowlb == NULL);
2405 assert(scip != NULL);
2406 assert(conshdlr != NULL);
2408 assert(sourcecons != NULL);
2409 assert(targetcons != NULL);
2413 assert(conshdlrdata != NULL);
2414 assert(conshdlrdata->eventhdlr != NULL);
2420 assert(sourcedata != NULL);
2421 assert(sourcedata->nvars > 0);
2422 assert(sourcedata->nvars <= sourcedata->maxvars);
2427 consdata->cons = NULL;
2428 consdata->nvars = sourcedata->nvars;
2429 consdata->maxvars = sourcedata->nvars;
2430 consdata->cardval = sourcedata->cardval;
2431 consdata->rowub = NULL;
2432 consdata->rowlb = NULL;
2433 consdata->eventdatascurrent = NULL;
2434 consdata->neventdatascurrent = 0;
2435 consdata->ntreatnonzeros = 0;
2443 if( sourcedata->weights != NULL )
2448 consdata->weights = NULL;
2450 for( j = 0; j < sourcedata->nvars; ++j )
2452 assert(sourcedata->vars[j] != 0);
2453 assert(sourcedata->indvars[j] != 0);
2459 ++(consdata->ntreatnonzeros);
2471 consdata->cons = *targetcons;
2472 assert(consdata->cons != NULL);
2475 for( j = 0; j < consdata->nvars; ++j )
2478 consdata->vars[j], consdata->indvars[j], j, &consdata->eventdatas[j]) );
2479 assert(consdata->eventdatas[j] != NULL);
2485 SCIPdebugMsg(scip,
"constraint <%s> has %d variables fixed to be nonzero, allthough the constraint allows \ 2486 only %d nonzero variables\n",
SCIPconsGetName(*targetcons), consdata->ntreatnonzeros, consdata->cardval);
2507 assert(scip != NULL);
2508 assert(conshdlr != NULL);
2510 assert(result != NULL);
2512 SCIPdebugMsg(scip,
"Presolving cardinality constraints.\n");
2515 SCIPdebug( oldnfixedvars = *nfixedvars; )
2517 SCIPdebug( oldnupgdconss = *nupgdconss; )
2521 if( nrounds == 0 || nnewfixedvars > 0 || nnewaggrvars > 0 )
2526 assert(eventhdlr != NULL);
2531 for( c = 0; c < nconss; ++c )
2538 assert(conss != NULL);
2539 assert(conss[c] != NULL);
2543 assert(consdata != NULL);
2544 assert(consdata->nvars >= 0);
2545 assert(consdata->nvars <= consdata->maxvars);
2550 ndelconss, nupgdconss, nfixedvars, &nremovedvars) );
2563 (*nchgcoefs) += nremovedvars;
2565 SCIPdebugMsg(scip,
"presolving fixed %d variables, removed %d variables, deleted %d constraints, \ 2566 and upgraded %d constraints.\n", *nfixedvars - oldnfixedvars, nremovedvars, *ndelconss - oldndelconss,
2567 *nupgdconss - oldnupgdconss);
2578 assert(scip != NULL);
2579 assert(conshdlr != NULL);
2592 assert(scip != NULL);
2593 assert(conshdlr != NULL);
2594 assert(conss != NULL);
2595 assert(result != NULL);
2606 assert(scip != NULL);
2607 assert(conshdlr != NULL);
2608 assert(conss != NULL);
2609 assert(result != NULL);
2620 assert(scip != NULL);
2621 assert(conshdlr != NULL);
2622 assert(conss != NULL);
2624 assert(result != NULL);
2635 assert( scip != NULL );
2636 assert( conshdlr != NULL );
2637 assert( conss != NULL );
2639 assert( result != NULL );
2650 assert(scip != NULL);
2651 assert(conshdlr != NULL);
2652 assert(conss != NULL);
2654 assert(result != NULL);
2670 assert(scip != NULL);
2671 assert(conshdlr != NULL);
2672 assert(conss != NULL);
2674 assert(result != NULL);
2677 for( c = 0; c < nconss; ++c )
2685 assert(conss[c] != NULL);
2687 assert(consdata != NULL);
2688 cardval = consdata->cardval;
2692 for( j = 0; j < consdata->nvars; ++j )
2712 for( l = 0; l < consdata->nvars; ++l )
2742 assert(scip != NULL);
2743 assert(conshdlr != NULL);
2744 assert(conss != NULL);
2746 assert(result != NULL);
2752 for( c = 0; c < nconss; ++c )
2759 assert(conss[c] != NULL);
2762 assert(consdata != NULL);
2773 SCIPdebugMsg(scip,
"Propagated %d domains.\n", nchgdomain);
2774 if( nchgdomain > 0 )
2801 assert(scip != NULL);
2802 assert(conshdlr != NULL);
2803 assert(cons != NULL);
2806 assert(consdata != NULL);
2810 vars = consdata->vars;
2811 indvars = consdata->indvars;
2812 nvars = consdata->nvars;
2813 assert(vars != NULL);
2815 for( j = 0; j < nvars; ++j )
2820 indvar = indvars[j];
2848 assert(scip != NULL);
2849 assert(conshdlr != NULL);
2850 assert(cons != NULL);
2854 assert(consdata != NULL);
2856 for( j = 0; j < consdata->nvars; ++j )
2861 if( consdata->weights == NULL )
2882 const char* consname;
2886 assert(scip != NULL);
2887 assert(sourcescip != NULL);
2888 assert(sourcecons != NULL);
2899 SCIPdebugMsg(scip,
"Copying cardinality constraint <%s> ...\n", consname);
2902 assert(sourceconsdata != NULL);
2905 nvars = sourceconsdata->nvars;
2910 sourcevars = sourceconsdata->vars;
2911 assert(sourcevars != NULL);
2912 sourceindvars = sourceconsdata->indvars;
2913 assert(sourceindvars != NULL);
2914 sourceweights = sourceconsdata->weights;
2915 assert(sourceweights != NULL);
2923 for( v = 0; v < nvars && *valid; ++v )
2925 assert(sourcevars[v] != NULL);
2926 assert(sourceindvars[v] != NULL);
2928 SCIP_CALL(
SCIPgetVarCopy(sourcescip, scip, sourcevars[v], &(targetvars[v]), varmap, consmap, global, valid) );
2931 SCIP_CALL(
SCIPgetVarCopy(sourcescip, scip, sourceindvars[v], &(targetindvars[v]), varmap, consmap, global, valid) );
2939 targetweights, initial, separate, enforce, check, propagate, local, dynamic, removable, stickingatnode) );
2960 assert(scip != NULL);
2961 assert(conshdlr != NULL);
2963 assert(cons != NULL);
2964 assert(success != NULL);
2970 SCIP_CALL(
SCIPcreateConsCardinality(scip, cons, name, 0, NULL, 0, NULL, NULL, initial, separate, enforce, check, propagate, local, dynamic, removable, stickingatnode) );
2980 while ( *s !=
'\0' && *s !=
'(' )
2993 weight = strtod(s, &t);
3003 while ( *s !=
'\0' && ( isspace((
unsigned char)*s) || *s ==
',' || *s ==
')' ) )
3010 if ( *s ==
'<' && *(s+1) ==
'=' )
3015 while ( isspace((
unsigned char)*s) )
3018 cardval = (int)strtod(s, &t);
3030 while ( *s !=
'\0' );
3042 assert(consdata != NULL);
3044 if( varssize < consdata->nvars )
3048 assert(vars != NULL);
3064 assert(consdata != NULL);
3066 (*nvars) = consdata->nvars;
3088 assert(eventhdlr != NULL);
3089 assert(eventdata != NULL);
3091 assert(event != NULL);
3093 consdata = eventdata->consdata;
3094 assert(consdata != NULL);
3095 assert(0 <= consdata->ntreatnonzeros && consdata->ntreatnonzeros <= consdata->nvars);
3096 assert(consdata->eventdatascurrent != NULL);
3097 assert(consdata->eventvarscurrent != NULL);
3100 assert(var != NULL);
3106 if( ( eventdata->varmarked && var == eventdata->var) || ( eventdata->indvarmarked && var == eventdata->indvar) )
3110 for( i = 0; i < consdata->neventdatascurrent; ++i )
3112 if( var == consdata->eventvarscurrent[i] )
3117 assert(i < consdata->neventdatascurrent);
3122 if( var == eventdata->indvar )
3125 assert(consdata->cons != NULL);
3130 ++(consdata->ntreatnonzeros);
3132 --(consdata->ntreatnonzeros);
3134 assert(0 <= consdata->ntreatnonzeros && consdata->ntreatnonzeros <= consdata->nvars);
3138 assert(oldbound == 1.0 && newbound == 0.0 );
3141 consdata->eventdatascurrent[consdata->neventdatascurrent] = eventdata;
3142 consdata->eventvarscurrent[consdata->neventdatascurrent] = var;
3143 ++consdata->neventdatascurrent;
3144 eventdata->indvarmarked =
TRUE;
3145 assert(consdata->neventdatascurrent <= 4 * consdata->maxvars);
3146 assert(var == eventdata->indvar );
3152 if( var == eventdata->var && ! eventdata->varmarked )
3160 consdata->eventdatascurrent[consdata->neventdatascurrent] = eventdata;
3161 consdata->eventvarscurrent[consdata->neventdatascurrent] = var;
3162 ++consdata->neventdatascurrent;
3163 eventdata->varmarked =
TRUE;
3164 assert(consdata->neventdatascurrent <= 4 * consdata->maxvars );
3165 assert(var == eventdata->var );
3174 consdata->eventdatascurrent[consdata->neventdatascurrent] = eventdata;
3175 consdata->eventvarscurrent[consdata->neventdatascurrent] = var;
3176 ++consdata->neventdatascurrent;
3177 eventdata->varmarked =
TRUE;
3178 assert(consdata->neventdatascurrent <= 4 * consdata->maxvars );
3179 assert(var == eventdata->var);
3183 assert(0 <= consdata->ntreatnonzeros && consdata->ntreatnonzeros <= consdata->nvars);
3185 SCIPdebugMsg(scip,
"event exec cons <%s>: changed bound of variable <%s> from %f to %f (ntreatnonzeros: %d).\n",
3187 oldbound, newbound, consdata->ntreatnonzeros);
3204 conshdlrdata->eventhdlr = NULL;
3205 conshdlrdata->varhash = NULL;
3209 eventExecCardinality, NULL) );
3210 if( conshdlrdata->eventhdlr == NULL )
3212 SCIPerrorMessage(
"event handler for cardinality constraints not found.\n");
3219 consEnfolpCardinality, consEnfopsCardinality, consCheckCardinality, consLockCardinality, conshdlrdata) );
3220 assert(conshdlr != NULL);
3243 "whether to use balanced instead of unbalanced branching",
3247 "maximum depth for using balanced branching (-1: no limit)",
3251 "determines that balanced branching is only used if the branching cut off value \ 3252 w.r.t. the current LP solution is greater than a given value",
3311 if( conshdlr == NULL )
3319 assert(conshdlrdata != NULL);
3326 consdata->cons = NULL;
3327 consdata->vars = NULL;
3328 consdata->indvars = NULL;
3329 consdata->eventdatas = NULL;
3330 consdata->nvars = nvars;
3331 consdata->cardval = cardval;
3332 consdata->maxvars = nvars;
3333 consdata->rowub = NULL;
3334 consdata->rowlb = NULL;
3335 consdata->eventdatascurrent = NULL;
3336 consdata->eventvarscurrent = NULL;
3337 consdata->neventdatascurrent = 0;
3338 consdata->ntreatnonzeros = transformed ? 0 : -1;
3339 consdata->weights = NULL;
3347 if( indvars != NULL )
3353 if( conshdlrdata->varhash == NULL )
3360 for( v = 0; v < nvars; ++v )
3365 assert(implvar != NULL);
3377 consdata->indvars[v] = implvar;
3385 NULL, NULL, NULL, NULL, NULL) );
3387 consdata->indvars[v] = var;
3405 if( weights != NULL )
3415 for( v = 0; v < nvars; ++v )
3419 SCIPsortRealPtrPtrInt(consdata->weights, (
void**)consdata->vars, (
void**)consdata->indvars, dummy, nvars);
3426 assert(weights == NULL);
3430 SCIP_CALL(
SCIPcreateCons(scip, cons, name, conshdlr, consdata, initial, separate, enforce, check, propagate,
3431 local, modifiable, dynamic, removable, stickingatnode) );
3433 consdata->cons = *cons;
3434 assert(consdata->cons != NULL);
3437 for( v = nvars - 1; v >= 0; --v )
3445 assert(consdata->vars[v] != NULL);
3446 assert(consdata->indvars[v] != NULL);
3452 consdata->indvars[v], v, transformed, &consdata->eventdatas[v]) );
3453 assert(! transformed || consdata->eventdatas[v] != NULL);
3480 SCIP_CALL(
SCIPcreateConsCardinality(scip, cons, name, nvars, vars, cardval, indvars, weights,
TRUE,
TRUE,
TRUE,
TRUE,
3495 assert(scip != NULL);
3496 assert(cons != NULL);
3505 assert(consdata != NULL);
3507 SCIPdebugMsg(scip,
"modify right hand side of cardinality constraint from <%i> to <%i>\n", consdata->cardval, cardval);
3510 consdata->cardval = cardval;
3529 assert(scip != NULL);
3530 assert(var != NULL);
3531 assert(cons != NULL);
3537 assert(conshdlr != NULL);
3545 assert(conshdlrdata != NULL);
3565 assert(scip != NULL);
3566 assert(var != NULL);
3567 assert(cons != NULL);
3572 assert(conshdlr != NULL);
3580 assert(conshdlrdata != NULL);
3595 assert(scip != NULL);
3596 assert(cons != NULL);
3606 assert(consdata != NULL);
3608 return consdata->nvars;
3619 assert(scip != NULL);
3620 assert(cons != NULL);
3630 assert(consdata != NULL);
3632 return consdata->vars;
3643 assert(scip != NULL);
3644 assert(cons != NULL);
3653 assert(consdata != NULL);
3655 return consdata->cardval;
3666 assert(scip != NULL);
3667 assert(cons != NULL);
3677 assert(consdata != NULL);
3679 return consdata->weights;
enum SCIP_Result SCIP_RESULT
#define SCIPfreeBlockMemoryArray(scip, ptr, num)
SCIP_Bool SCIPisFeasZero(SCIP *scip, SCIP_Real val)
static SCIP_RETCODE handleNewVariableCardinality(SCIP *scip, SCIP_CONS *cons, SCIP_CONSDATA *consdata, SCIP_CONSHDLRDATA *conshdlrdata, SCIP_VAR *var, SCIP_VAR *indvar, int pos, SCIP_Bool transformed, SCIP_EVENTDATA **eventdata)
#define SCIPreallocBlockMemoryArray(scip, ptr, oldnum, newnum)
#define CONSHDLR_SEPAPRIORITY
SCIP_RETCODE SCIPflattenVarAggregationGraph(SCIP *scip, SCIP_VAR *var)
SCIP_RETCODE SCIPsetConshdlrDelete(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSDELETE((*consdelete)))
#define SCIPallocBlockMemoryArray(scip, ptr, num)
SCIP_Bool SCIPisFeasEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_NODE * SCIPgetCurrentNode(SCIP *scip)
SCIP_STAGE SCIPgetStage(SCIP *scip)
SCIP_Bool SCIPconsIsDynamic(SCIP_CONS *cons)
SCIP_Real * SCIPvarGetMultaggrScalars(SCIP_VAR *var)
SCIP_RETCODE SCIPsetConshdlrTrans(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSTRANS((*constrans)))
SCIP_Bool SCIPisFeasLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
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)
void SCIPsortRealPtrPtrInt(SCIP_Real *realarray, void **ptrarray1, void **ptrarray2, int *intarray, int len)
static SCIP_DECL_CONSSEPASOL(consSepasolCardinality)
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
SCIP_RETCODE SCIPsetConshdlrGetVars(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSGETVARS((*consgetvars)))
SCIP_Real SCIPgetLocalTransEstimate(SCIP *scip)
SCIP_RETCODE SCIPaddVarCardinality(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_VAR *indvar, SCIP_Real weight)
static SCIP_DECL_CONSGETVARS(consGetVarsCardinality)
SCIP_RETCODE SCIPsetConshdlrEnforelax(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSENFORELAX((*consenforelax)))
SCIP_RETCODE SCIPresetConsAge(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPdelCons(SCIP *scip, SCIP_CONS *cons)
int SCIPcalcMemGrowSize(SCIP *scip, int num)
SCIP_VAR ** SCIPvarGetMultaggrVars(SCIP_VAR *var)
SCIP_RETCODE SCIPaddVarToRow(SCIP *scip, SCIP_ROW *row, SCIP_VAR *var, SCIP_Real val)
static SCIP_DECL_CONSPRESOL(consPresolCardinality)
SCIP_Bool SCIPisPositive(SCIP *scip, SCIP_Real val)
static SCIP_RETCODE fixVariableZeroNode(SCIP *scip, SCIP_VAR *var, SCIP_NODE *node, SCIP_Bool *infeasible)
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
static SCIP_DECL_CONSPARSE(consParseCardinality)
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)
static SCIP_DECL_CONSEXITSOL(consExitsolCardinality)
SCIP_RETCODE SCIPgetTransformedVar(SCIP *scip, SCIP_VAR *var, SCIP_VAR **transvar)
static SCIP_RETCODE enforceCardinality(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_SOL *sol, int nconss, SCIP_CONS **conss, SCIP_RESULT *result)
SCIP_RETCODE SCIPparseVarName(SCIP *scip, const char *str, SCIP_VAR **var, char **endptr)
SCIP_RETCODE SCIPreleaseVar(SCIP *scip, SCIP_VAR **var)
SCIP_Bool SCIPvarIsBinary(SCIP_VAR *var)
SCIP_Bool SCIPisFeasNegative(SCIP *scip, SCIP_Real val)
static SCIP_RETCODE deleteVarCardinality(SCIP *scip, SCIP_CONS *cons, SCIP_CONSDATA *consdata, SCIP_EVENTHDLR *eventhdlr, int pos)
SCIP_Real SCIProwGetLhs(SCIP_ROW *row)
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
const char * SCIPeventhdlrGetName(SCIP_EVENTHDLR *eventhdlr)
static SCIP_RETCODE generateRowCardinality(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_CONS *cons, SCIP_Bool local, SCIP_ROW **rowlb, SCIP_ROW **rowub)
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)
SCIP_Real SCIPinfinity(SCIP *scip)
int SCIPsnprintf(char *t, int len, const char *s,...)
SCIP_Bool SCIPisNegative(SCIP *scip, SCIP_Real val)
enum SCIP_Retcode SCIP_RETCODE
#define DEFAULT_BRANCHBALANCED
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)
SCIP_RETCODE SCIPchgVarUbNode(SCIP *scip, SCIP_NODE *node, SCIP_VAR *var, SCIP_Real newbound)
#define SCIPduplicateBufferArray(scip, ptr, source, num)
int SCIPconshdlrGetSepaFreq(SCIP_CONSHDLR *conshdlr)
SCIP_RETCODE SCIPchgVarLb(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin)
static SCIP_DECL_CONSTRANS(consTransCardinality)
#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)))
SCIP_RETCODE SCIPaddIntParam(SCIP *scip, const char *name, const char *desc, int *valueptr, SCIP_Bool isadvanced, int defaultvalue, int minvalue, int maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
SCIP_RETCODE SCIPsetConshdlrParse(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSPARSE((*consparse)))
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)
static SCIP_RETCODE addVarCardinality(SCIP *scip, SCIP_CONS *cons, SCIP_CONSHDLRDATA *conshdlrdata, SCIP_VAR *var, SCIP_VAR *indvar, SCIP_Real weight)
#define CONSHDLR_DELAYPROP
static SCIP_DECL_CONSPROP(consPropCardinality)
static SCIP_RETCODE appendVarCardinality(SCIP *scip, SCIP_CONS *cons, SCIP_CONSHDLRDATA *conshdlrdata, SCIP_VAR *var, SCIP_VAR *indvar)
SCIP_Bool SCIProwIsInLP(SCIP_ROW *row)
SCIP_Bool SCIPhashmapExists(SCIP_HASHMAP *hashmap, void *origin)
#define SCIP_EVENTTYPE_LBRELAXED
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
static SCIP_RETCODE fixVariableZero(SCIP *scip, SCIP_VAR *var, SCIP_Bool *infeasible, SCIP_Bool *tightened)
#define SCIPduplicateBlockMemoryArray(scip, ptr, source, num)
SCIP_Bool SCIPisCutEfficacious(SCIP *scip, SCIP_SOL *sol, SCIP_ROW *cut)
Constraint handler for knapsack constraints of the form , x binary and .
SCIP_Real SCIPeventGetNewbound(SCIP_EVENT *event)
SCIP_RETCODE SCIPcreateSolCopy(SCIP *scip, SCIP_SOL **sol, SCIP_SOL *sourcesol)
static SCIP_RETCODE catchVarEventCardinality(SCIP *scip, SCIP_EVENTHDLR *eventhdlr, SCIP_CONSDATA *consdata, SCIP_VAR *var, SCIP_VAR *indvar, int pos, SCIP_EVENTDATA **eventdata)
SCIP_RETCODE SCIPincludeConshdlrCardinality(SCIP *scip)
SCIP_RETCODE SCIPsetConshdlrCopy(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSHDLRCOPY((*conshdlrcopy)), SCIP_DECL_CONSCOPY((*conscopy)))
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
SCIP_RETCODE SCIPaddCons(SCIP *scip, SCIP_CONS *cons)
static SCIP_RETCODE lockVariableCardinality(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_VAR *indvar)
static SCIP_DECL_CONSINITLP(consInitlpCardinality)
SCIP_RETCODE SCIPdelConsLocal(SCIP *scip, SCIP_CONS *cons)
#define CONSHDLR_MAXPREROUNDS
SCIP_RETCODE SCIPgetProbvarSum(SCIP *scip, SCIP_VAR **var, SCIP_Real *scalar, SCIP_Real *constant)
static SCIP_RETCODE branchUnbalancedCardinality(SCIP *scip, SCIP_SOL *sol, SCIP_CONS *branchcons, SCIP_VAR **vars, SCIP_VAR **indvars, int nvars, int cardval, int branchnnonzero, int branchpos)
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
SCIP_RETCODE SCIPunlockVarCons(SCIP *scip, SCIP_VAR *var, SCIP_CONS *cons, SCIP_Bool lockdown, SCIP_Bool lockup)
static SCIP_DECL_CONSHDLRCOPY(conshdlrCopyCardinality)
const char * SCIPconsGetName(SCIP_CONS *cons)
SCIP_RETCODE SCIPmarkDoNotMultaggrVar(SCIP *scip, SCIP_VAR *var)
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)))
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
SCIP_CONSHDLRDATA * SCIPconshdlrGetData(SCIP_CONSHDLR *conshdlr)
static SCIP_DECL_CONSENFORELAX(consEnforelaxCardinality)
SCIP_RETCODE SCIPcreateConsKnapsack(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Longint *weights, SCIP_Longint capacity, 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 SCIPcreateChild(SCIP *scip, SCIP_NODE **node, SCIP_Real nodeselprio, SCIP_Real estimate)
static SCIP_DECL_CONSLOCK(consLockCardinality)
#define CONSHDLR_DELAYSEPA
#define SCIP_EVENTTYPE_LBTIGHTENED
int SCIPgetNTotalVars(SCIP *scip)
SCIP_Bool SCIPisFeasGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Real SCIPvarGetMultaggrConstant(SCIP_VAR *var)
static SCIP_DECL_CONSFREE(consFreeCardinality)
SCIP_Real SCIProwGetRhs(SCIP_ROW *row)
void SCIPverbMessage(SCIP *scip, SCIP_VERBLEVEL msgverblevel, FILE *file, const char *formatstr,...)
SCIP_Bool SCIPconsIsLocal(SCIP_CONS *cons)
SCIP_RETCODE SCIPaddRow(SCIP *scip, SCIP_ROW *row, SCIP_Bool forcecut, SCIP_Bool *infeasible)
struct SCIP_ConsData SCIP_CONSDATA
static SCIP_RETCODE polishPrimalSolution(SCIP *scip, SCIP_CONS **conss, int nconss, SCIP_SOL *sol, SCIP_SOL *primsol)
static SCIP_RETCODE presolRoundCardinality(SCIP *scip, SCIP_CONS *cons, SCIP_CONSDATA *consdata, SCIP_EVENTHDLR *eventhdlr, SCIP_Bool *cutoff, SCIP_Bool *success, int *ndelconss, int *nupgdconss, int *nfixedvars, int *nremovedvars)
SCIP_RETCODE SCIPaddConsNode(SCIP *scip, SCIP_NODE *node, SCIP_CONS *cons, SCIP_NODE *validnode)
int SCIPgetCardvalCardinality(SCIP *scip, SCIP_CONS *cons)
static SCIP_DECL_CONSENFOLP(consEnfolpCardinality)
#define SCIPallocBufferArray(scip, ptr, num)
SCIP_RETCODE SCIPsetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real val)
static SCIP_DECL_CONSSEPALP(consSepalpCardinality)
static SCIP_RETCODE dropVarEventCardinality(SCIP *scip, SCIP_EVENTHDLR *eventhdlr, SCIP_CONSDATA *consdata, SCIP_VAR *var, SCIP_VAR *indvar, SCIP_EVENTDATA **eventdata)
SCIP_VAR * SCIPeventGetVar(SCIP_EVENT *event)
static SCIP_DECL_CONSPRINT(consPrintCardinality)
static SCIP_DECL_CONSGETNVARS(consGetNVarsCardinality)
SCIP_EVENTTYPE SCIPeventGetType(SCIP_EVENT *event)
static SCIP_RETCODE separateCardinality(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_SOL *sol, int nconss, SCIP_CONS **conss, SCIP_RESULT *result)
#define DEFAULT_BALANCEDDEPTH
SCIP_Real * SCIPgetWeightsCardinality(SCIP *scip, SCIP_CONS *cons)
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)
int SCIPgetDepth(SCIP *scip)
SCIP_RETCODE SCIPprintCons(SCIP *scip, SCIP_CONS *cons, FILE *file)
static SCIP_DECL_CONSENFOPS(consEnfopsCardinality)
SCIP_CONSHDLR * SCIPconsGetHdlr(SCIP_CONS *cons)
SCIP_RETCODE SCIPfreeSol(SCIP *scip, SCIP_SOL **sol)
SCIP_Bool SCIPconsIsChecked(SCIP_CONS *cons)
SCIP_Bool SCIPconsIsInitial(SCIP_CONS *cons)
SCIP_RETCODE SCIPdropVarEvent(SCIP *scip, SCIP_VAR *var, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int filterpos)
SCIP_Real SCIPcalcNodeselPriority(SCIP *scip, SCIP_VAR *var, SCIP_BRANCHDIR branchdir, SCIP_Real targetvalue)
SCIP_RETCODE SCIPcreateVar(SCIP *scip, SCIP_VAR **var, const char *name, SCIP_Real lb, SCIP_Real ub, SCIP_Real obj, SCIP_VARTYPE vartype, SCIP_Bool initial, SCIP_Bool removable, SCIP_DECL_VARDELORIG((*vardelorig)), SCIP_DECL_VARTRANS((*vartrans)), SCIP_DECL_VARDELTRANS((*vardeltrans)), SCIP_DECL_VARCOPY((*varcopy)), SCIP_VARDATA *vardata)
static SCIP_RETCODE unlockVariableCardinality(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_VAR *indvar)
#define CONSHDLR_SEPAFREQ
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)
#define CONSHDLR_PROP_TIMING
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, .
int SCIPvarGetMultaggrNVars(SCIP_VAR *var)
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
SCIP_RETCODE SCIPtrySol(SCIP *scip, SCIP_SOL *sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
SCIP_Real SCIPcalcChildEstimate(SCIP *scip, SCIP_VAR *var, SCIP_Real targetvalue)
static SCIP_RETCODE consdataEnsurevarsSizeCardinality(SCIP *scip, SCIP_CONSDATA *consdata, int num, SCIP_Bool reserveweights)
static SCIP_RETCODE consdataUnmarkEventdataVars(SCIP_CONSDATA *consdata)
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)
#define CONSHDLR_EAGERFREQ
SCIP_RETCODE SCIPreleaseRow(SCIP *scip, SCIP_ROW **row)
#define CONSHDLR_PRESOLTIMING
SCIP_RETCODE SCIPcreateConsCardinality(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, int cardval, SCIP_VAR **indvars, 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)
SCIP_Bool SCIPisGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
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_RETCODE SCIPaddVar(SCIP *scip, SCIP_VAR *var)
SCIP_CONSDATA * SCIPconsGetData(SCIP_CONS *cons)
#define CONSHDLR_PROPFREQ
constraint handler for cardinality constraints
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
#define CONSHDLR_NEEDSCONS
SCIP_RETCODE SCIPcreateConsBasicCardinality(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, int cardval, SCIP_VAR **indvars, SCIP_Real *weights)
SCIP_RETCODE SCIPsetConshdlrPresol(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSPRESOL((*conspresol)), int maxprerounds, SCIP_PRESOLTIMING presoltiming)
void SCIPupdateSolConsViolation(SCIP *scip, SCIP_SOL *sol, SCIP_Real absviol, SCIP_Real relviol)
SCIP_Real SCIPeventGetOldbound(SCIP_EVENT *event)
SCIP_Bool SCIPisFeasPositive(SCIP *scip, SCIP_Real val)
static SCIP_RETCODE propCardinality(SCIP *scip, SCIP_CONS *cons, SCIP_CONSDATA *consdata, SCIP_Bool *cutoff, int *nchgdomain)
#define DEFAULT_BALANCEDCUTOFF
SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
SCIP_Bool SCIPconsIsModifiable(SCIP_CONS *cons)
SCIP_RETCODE SCIPaddVarsToRow(SCIP *scip, SCIP_ROW *row, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
int SCIPgetNVarsCardinality(SCIP *scip, SCIP_CONS *cons)
SCIP_Bool SCIPisStopped(SCIP *scip)
SCIP_RETCODE SCIPsetConshdlrGetNVars(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSGETNVARS((*consgetnvars)))
SCIP_RETCODE SCIPchgCardvalCardinality(SCIP *scip, SCIP_CONS *cons, int cardval)
static SCIP_RETCODE initsepaBoundInequalityFromCardinality(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_CONS **conss, int nconss, SCIP_SOL *sol, SCIP_Bool solvedinitlp, int *ngen, SCIP_Bool *cutoff)
SCIP_Bool SCIPconsIsEnforced(SCIP_CONS *cons)
SCIP_RETCODE SCIPappendVarCardinality(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_VAR *indvar)
SCIP_Bool SCIPconsIsSeparated(SCIP_CONS *cons)
SCIP_RETCODE SCIPprintRow(SCIP *scip, SCIP_ROW *row, FILE *file)
static SCIP_DECL_CONSCOPY(consCopyCardinality)
SCIP_Bool SCIPisZero(SCIP *scip, SCIP_Real val)
SCIP_VAR ** SCIPgetVarsCardinality(SCIP *scip, SCIP_CONS *cons)
SCIP_Bool SCIPisLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
#define CONSHDLR_CHECKPRIORITY
struct SCIP_ConshdlrData SCIP_CONSHDLRDATA
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
SCIP_Bool SCIPvarIsTransformed(SCIP_VAR *var)
static SCIP_DECL_EVENTEXEC(eventExecCardinality)
SCIP_RETCODE SCIPhashmapInsert(SCIP_HASHMAP *hashmap, void *origin, void *image)
static SCIP_DECL_CONSCHECK(consCheckCardinality)
SCIP_RETCODE SCIPsetConshdlrExitsol(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSEXITSOL((*consexitsol)))
SCIP_Longint SCIPgetNNodes(SCIP *scip)
static SCIP_RETCODE branchBalancedCardinality(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_SOL *sol, SCIP_CONS *branchcons, SCIP_VAR **vars, SCIP_VAR **indvars, int nvars, int cardval, int branchnnonzero, int branchpos, SCIP_Real balancedcutoff)
SCIP_RETCODE SCIPwriteVarName(SCIP *scip, FILE *file, SCIP_VAR *var, SCIP_Bool type)
SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
SCIP_RETCODE SCIPaddRealParam(SCIP *scip, const char *name, const char *desc, SCIP_Real *valueptr, SCIP_Bool isadvanced, SCIP_Real defaultvalue, SCIP_Real minvalue, SCIP_Real maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
SCIP_Real SCIPfloor(SCIP *scip, SCIP_Real val)
#define CONSHDLR_ENFOPRIORITY
SCIP_RETCODE SCIPaddBoolParam(SCIP *scip, const char *name, const char *desc, SCIP_Bool *valueptr, SCIP_Bool isadvanced, SCIP_Bool defaultvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
static SCIP_DECL_CONSDELETE(consDeleteCardinality)
SCIP_RETCODE SCIPsetConshdlrProp(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSPROP((*consprop)), int propfreq, SCIP_Bool delayprop, SCIP_PROPTIMING proptiming)