44 #define CONSHDLR_NAME "cardinality" 45 #define CONSHDLR_DESC "cardinality constraint handler" 46 #define CONSHDLR_SEPAPRIORITY 10 47 #define CONSHDLR_ENFOPRIORITY 100 48 #define CONSHDLR_CHECKPRIORITY -10 49 #define CONSHDLR_SEPAFREQ 10 50 #define CONSHDLR_PROPFREQ 1 51 #define CONSHDLR_EAGERFREQ 100 53 #define CONSHDLR_MAXPREROUNDS -1 55 #define CONSHDLR_DELAYSEPA FALSE 56 #define CONSHDLR_DELAYPROP FALSE 57 #define CONSHDLR_NEEDSCONS TRUE 59 #define CONSHDLR_PROP_TIMING SCIP_PROPTIMING_BEFORELP 60 #define CONSHDLR_PRESOLTIMING SCIP_PRESOLTIMING_FAST 63 #define DEFAULT_BRANCHBALANCED FALSE 64 #define DEFAULT_BALANCEDDEPTH 20 65 #define DEFAULT_BALANCEDCUTOFF 2.0 69 #define EVENTHDLR_NAME "cardinality" 70 #define EVENTHDLR_DESC "bound change event handler for cardinality constraints" 84 int neventdatascurrent;
95 struct SCIP_ConshdlrData
106 struct SCIP_EventData
112 unsigned int varmarked:1;
113 unsigned int indvarmarked:1;
128 assert(eventhdlr !=
NULL);
129 assert(consdata !=
NULL);
131 assert(indvar !=
NULL);
137 (*eventdata)->consdata = consdata;
138 (*eventdata)->var = var;
139 (*eventdata)->indvar = indvar;
140 (*eventdata)->varmarked =
FALSE;
141 (*eventdata)->indvarmarked =
FALSE;
142 (*eventdata)->pos = (
unsigned int)pos;
162 assert(eventhdlr !=
NULL);
163 assert(consdata !=
NULL);
165 assert(indvar !=
NULL);
166 assert(eventdata !=
NULL);
212 SCIP_CALL(
SCIPcreateConsLinear(scip, &cons,
"branch", 1, &var, &val, 0.0, 0.0,
TRUE,
TRUE,
TRUE,
TRUE,
TRUE,
250 assert(scip !=
NULL);
252 assert(infeasible !=
NULL);
253 assert(tightened !=
NULL);
278 for( i = 0; i < naggrvars; ++i )
283 allnonnegative =
FALSE;
291 for( i = 0; i < naggrvars; ++i )
297 *tightened = *tightened || fixed;
319 assert(scip !=
NULL);
320 assert(cons !=
NULL);
340 assert(scip !=
NULL);
341 assert(cons !=
NULL);
361 assert(consdata !=
NULL);
362 assert(consdata->nvars <= consdata->maxvars);
364 if( num > consdata->maxvars )
375 if ( reserveweights )
379 consdata->maxvars = newsize;
381 assert(num <= consdata->maxvars);
409 assert(scip !=
NULL);
410 assert(cons !=
NULL);
411 assert(consdata !=
NULL);
412 assert(conshdlrdata !=
NULL);
420 assert(eventdata !=
NULL );
423 assert(consdata->ntreatnonzeros >= 0 );
425 ++consdata->ntreatnonzeros;
469 assert(cons !=
NULL);
470 assert(conshdlrdata !=
NULL);
473 assert(consdata !=
NULL );
475 if( consdata->weights ==
NULL && consdata->maxvars > 0 )
477 SCIPerrorMessage(
"cannot add variable to cardinality constraint <%s> that does not contain weights.\n",
485 if( conshdlrdata->varhash ==
NULL )
496 assert(indvar !=
NULL);
516 assert(indvar !=
NULL);
535 assert(indvar !=
NULL);
541 assert(consdata->weights !=
NULL);
542 assert(consdata->maxvars >= consdata->nvars+1);
545 for( pos = consdata->nvars; pos >= 1; --pos )
547 if( consdata->weights[pos-1] > weight )
549 consdata->vars[pos] = consdata->vars[pos-1];
550 consdata->indvars[pos] = consdata->indvars[pos-1];
551 consdata->eventdatas[pos] = consdata->eventdatas[pos-1];
552 consdata->weights[pos] = consdata->weights[pos-1];
554 if( consdata->eventdatas[pos] !=
NULL )
556 consdata->eventdatas[pos]->pos = (
unsigned int)pos;
562 assert(0 <= pos && pos <= consdata->nvars);
566 assert(! transformed || eventdata !=
NULL);
569 consdata->vars[pos] = var;
570 consdata->indvars[pos] = indvar;
571 consdata->eventdatas[pos] = eventdata;
572 consdata->weights[pos] = weight;
594 assert(cons !=
NULL);
595 assert(conshdlrdata !=
NULL);
598 assert(consdata !=
NULL);
603 if( conshdlrdata->varhash ==
NULL )
614 assert(indvar !=
NULL);
634 assert(indvar !=
NULL);
653 assert(indvar !=
NULL);
663 assert(!transformed || eventdata !=
NULL);
666 consdata->vars[consdata->nvars] = var;
667 consdata->indvars[consdata->nvars] = indvar;
668 consdata->eventdatas[consdata->nvars] = eventdata;
670 if( consdata->weights !=
NULL && consdata->nvars > 0 )
671 consdata->weights[consdata->nvars] = consdata->weights[consdata->nvars-1] + 1.0;
674 assert(consdata->weights !=
NULL || consdata->nvars > 0);
691 assert(0 <= pos && pos < consdata->nvars);
698 &consdata->eventdatas[pos]) );
702 --(consdata->ntreatnonzeros);
705 for( j = pos; j < consdata->nvars-1; ++j )
707 consdata->vars[j] = consdata->vars[j+1];
708 consdata->indvars[j] = consdata->indvars[j+1];
709 consdata->eventdatas[j] = consdata->eventdatas[j+1];
710 if( consdata->weights !=
NULL )
711 consdata->weights[j] = consdata->weights[j+1];
713 consdata->eventdatas[j]->pos = (
unsigned int)j;
737 for( c = 0; c < nconss; ++c )
743 assert(cons !=
NULL);
745 assert(consdata !=
NULL);
747 nvars = consdata->nvars;
748 vars = consdata->vars;
749 indvars = consdata->indvars;
751 for( j = 0; j < nvars; ++j )
777 eventdatas = consdata->eventdatas;
778 nvars = consdata->nvars;
779 assert(eventdatas !=
NULL);
781 for( j = 0; j < nvars; ++j )
785 eventdata = eventdatas[j];
786 eventdata->varmarked =
FALSE;
787 eventdata->indvarmarked =
FALSE;
825 assert(scip !=
NULL);
826 assert(cons !=
NULL);
827 assert(consdata !=
NULL);
828 assert(eventhdlr !=
NULL);
829 assert(cutoff !=
NULL);
830 assert(success !=
NULL);
831 assert(ndelconss !=
NULL);
832 assert(nfixedvars !=
NULL);
833 assert(nremovedvars !=
NULL);
842 consdata->neventdatascurrent = 0;
846 allvarsbinary =
TRUE;
847 vars = consdata->vars;
848 indvars = consdata->indvars;
851 while ( j < consdata->nvars )
881 &consdata->eventdatas[j]) );
883 &consdata->eventdatas[j]) );
884 assert(consdata->eventdatas[j] !=
NULL);
891 consdata->eventdatas[j]->var = var;
895 assert(var == vars[j]);
898 for( l = j+1; l < consdata->nvars; ++l )
900 if( var == vars[l] || oldvar == vars[l] )
954 assert(indub == 1.0);
958 SCIPdebugMsg(scip,
"deleting variable <%s> from constraint <%s>, since it may be treated as nonzero.\n",
960 --(consdata->cardval);
966 assert(indlb == 0.0);
991 allvarsbinary =
FALSE;
998 if( consdata->cardval < 0 )
1000 SCIPdebugMsg(scip,
"The problem is infeasible: more variables have bounds that keep them from being 0 than allowed.\n");
1006 else if( consdata->cardval == 0 )
1009 for( j = 0; j < consdata->nvars; ++j )
1026 if( consdata->nvars <= consdata->cardval )
1028 SCIPdebugMsg(scip,
"Deleting cardinality constraint <%s> with <%d> variables and cardinality value <%d>.\n",
1047 for( j = 0; j < consdata->nvars; ++j )
1100 assert(scip !=
NULL);
1101 assert(cons !=
NULL);
1102 assert(consdata !=
NULL);
1103 assert(cutoff !=
NULL);
1104 assert(nchgdomain !=
NULL);
1109 if( consdata->ntreatnonzeros > consdata->cardval )
1111 SCIPdebugMsg(scip,
"the node is infeasible, more than %d variables are fixed to be nonzero.\n", consdata->cardval);
1119 if( consdata->ntreatnonzeros == consdata->cardval )
1130 nvars = consdata->nvars;
1131 vars = consdata->vars;
1132 indvars = consdata->indvars;
1133 assert(vars !=
NULL);
1134 assert(indvars !=
NULL);
1138 for( j = 0; j < nvars; ++j )
1156 SCIPdebugMsg(scip,
"the node is infeasible, more than %d variables are fixed to be nonzero.\n",
1166 SCIPdebugMsg(scip,
"fixed variable <%s> to 0, since constraint <%s> with cardinality value %d is \ 1171 allvarfixed =
FALSE;
1175 assert(cnt == consdata->ntreatnonzeros);
1178 if( *nchgdomain > 0 )
1194 if( consdata->neventdatascurrent > 0 )
1201 neventdatas = consdata->neventdatascurrent;
1202 eventvars = consdata->eventvarscurrent;
1203 eventdatas = consdata->eventdatascurrent;
1204 assert(eventdatas !=
NULL && eventvars !=
NULL);
1206 for( j = 0; j < neventdatas; ++j )
1213 eventdata = eventdatas[j];
1215 assert(var !=
NULL && eventdata !=
NULL);
1216 assert(eventdata->var !=
NULL);
1217 assert(eventdata->indvar !=
NULL);
1218 assert(var == eventdata->var || var == eventdata->indvar);
1222 if( eventdata->indvar == var )
1224 assert(eventdata->indvarmarked);
1231 implvar = eventdata->var;
1241 SCIPdebugMsg(scip,
"the node is infeasible, indicator variable %s is fixed to zero although implied " 1251 SCIPdebugMsg(scip,
"fixed variable <%s> to 0, since indicator variable %s is 0.\n",
1257 eventdata->indvarmarked =
FALSE;
1262 assert(eventdata->var == var);
1263 assert(eventdata->varmarked);
1270 indvar = eventdata->indvar;
1279 SCIPdebugMsg(scip,
"the node is infeasible, implied variable %s is fixed to nonzero " 1287 SCIPdebugMsg(scip,
"fixed variable <%s> to 1.0, since implied variable %s is nonzero.\n",
1292 eventdata->varmarked =
FALSE;
1296 consdata->neventdatascurrent = 0;
1325 SCIPdebugMsg(scip,
"apply unbalanced branching on variable <%s> of constraint <%s>.\n",
1336 assert(! infeasible);
1342 assert(branchnnonzero + 1 <= cardval);
1343 if( branchnnonzero + 1 == cardval )
1354 for( j = 0; j < nvars; ++j )
1366 assert(cnt == nvars - (1 + branchnnonzero));
1379 for( j = 0; j < nvars; ++j )
1388 assert(!infeasible);
1441 SCIPerrorMessage(
"balanced branching is only possible if separation frequency of constraint handler is 1.\n");
1456 nbuffer = nvars-branchnnonzero;
1461 for( j = 0; j < nvars; ++j )
1476 weight1 += val * (
SCIP_Real) (j - (nnonzero + nzero));
1478 branchindvars[nbranchvars] = indvars[j];
1479 branchvars[nbranchvars++] = var;
1490 assert(nnonzero == branchnnonzero);
1491 assert(nbranchvars <= nvars - branchnnonzero);
1493 assert(cnt >= cardval-nnonzero);
1495 w = weight1/weight2;
1498 assert(0 <= ind && ind < nbranchvars-1);
1501 for( j = 0; j <= ind; ++j )
1518 for( j = ind+1; j < nbranchvars; ++j )
1537 newcardval = cardval - nnonzero;
1538 splitval1 = sum1 + (
SCIP_Real)newcardval - sum2 - 1.0;
1539 splitval1 =
SCIPfloor(scip, splitval1/2);
1540 splitval1 =
MAX(splitval1, 0);
1541 assert((
int)splitval1 >= 0);
1542 assert((
int)splitval1 <=
MIN(newcardval-1, ind));
1544 splitval2 -= splitval1;
1552 branchnnonzero, branchpos) );
1574 for( j = 0; j <= ind; ++j )
1586 for( j = 0; j <= ind; ++j )
1589 assert(!infeasible);
1619 for( j = ind+1; j < nbranchvars; ++j )
1624 assert(nbranchvars - (ind + 1) > 0);
1627 objest = objest/((
SCIP_Real)(nbranchvars - (ind + 1)));
1632 for( j = ind+1; j < nbranchvars; ++j )
1635 assert(!infeasible);
1645 for( j = ind+1; j < nbranchvars; ++j )
1647 branchvars[cnt] = branchvars[j];
1648 branchindvars[cnt++] = branchindvars[j];
1650 assert(cnt == nbranchvars - (ind + 1));
1722 assert(scip !=
NULL);
1723 assert(conshdlr !=
NULL);
1724 assert(conss !=
NULL);
1725 assert(result !=
NULL);
1729 branchnnonzero = -1;
1737 assert(conshdlrdata !=
NULL);
1740 for( c = 0; c < nconss; ++c )
1755 assert(cons !=
NULL);
1757 assert(consdata !=
NULL);
1763 nvars = consdata->nvars;
1764 vars = consdata->vars;
1765 indvars = consdata->indvars;
1766 cardval = consdata->cardval;
1775 SCIPdebugMsg(scip,
"propagating <%s> in enforcing (cutoff: %u, domain reductions: %d).\n",
1782 if( nchgdomain > 0 )
1787 assert(nchgdomain == 0);
1793 for( j = 0; j < nvars; ++j )
1848 if( nnonzero > cardval )
1850 SCIPdebugMsg(scip,
"Detected cut off: constraint <%s> has %d many variables that can be treated as nonzero, \ 1851 although only %d many are feasible.\n",
SCIPconsGetName(cons), nnonzero, cardval);
1856 else if( cnt > 0 && nnonzero + 1 > cardval )
1861 for( v = 0; v < nvars; ++v )
1874 assert(!infeasible);
1884 if( cnt > cardval - nnonzero && weight > maxweight )
1888 branchnnonzero = nnonzero;
1890 branchallneg = allneg;
1891 branchallpos = allpos;
1896 if( branchcons ==
NULL )
1907 SCIPdebugMsg(scip,
"All cardinality constraints are feasible.\n");
1910 assert(branchnnonzero >= 0);
1911 assert(branchpos >= 0);
1915 assert(consdata !=
NULL);
1916 nvars = consdata->nvars;
1917 vars = consdata->vars;
1918 indvars = consdata->indvars;
1919 cardval = consdata->cardval;
1923 if( conshdlrdata->branchbalanced && !
SCIPisFeasNegative(scip, maxweight) && ( branchallneg || branchallpos )
1924 && (conshdlrdata->balanceddepth == -1 ||
SCIPgetDepth(scip) <= conshdlrdata->balanceddepth)
1927 branchbalanced =
TRUE;
1931 if( branchbalanced )
1933 SCIP_CALL(
branchBalancedCardinality(scip, conshdlr, sol, branchcons, vars, indvars, nvars, cardval, branchnnonzero, branchpos,
1934 conshdlrdata->balancedcutoff) );
1984 assert(scip !=
NULL);
1985 assert(conshdlr !=
NULL);
1986 assert(cons !=
NULL);
1989 assert(consdata !=
NULL);
1990 assert(consdata->vars !=
NULL);
1991 assert(consdata->indvars !=
NULL);
1993 nvars = consdata->nvars;
2003 cardval = consdata->cardval;
2004 for( j = 0; j < nvars; ++j )
2020 assert(consdata->vars[j] !=
NULL);
2021 vars[cnt] = consdata->vars[j];
2022 vals[cnt++] = 1.0/val;
2025 assert(cardval >= 0);
2045 cardval = consdata->cardval;
2046 for( j = 0; j < nvars; ++j )
2062 assert(consdata->vars[j] !=
NULL);
2063 vars[cnt] = consdata->vars[j];
2064 vals[cnt++] = 1.0/val;
2067 assert(cardval >= 0);
2105 assert(scip !=
NULL);
2106 assert(conss !=
NULL);
2110 for( c = nconss-1; c >= 0; --c )
2117 assert(conss !=
NULL);
2118 assert(conss[c] !=
NULL);
2120 assert(consdata !=
NULL);
2136 if( consdata->rowub ==
NULL || consdata->rowlb ==
NULL )
2139 (consdata->rowlb ==
NULL) ? &consdata->rowlb :
NULL,
2140 (consdata->rowub == NULL) ? &consdata->rowub : NULL) );
2142 rowub = consdata->rowub;
2143 rowlb = consdata->rowlb;
2216 assert(scip !=
NULL);
2217 assert(conshdlr !=
NULL);
2218 assert(conss !=
NULL);
2219 assert(result !=
NULL);
2243 SCIPdebugMsg(scip,
"Separated %d bound inequalities.\n", ngen);
2254 assert(scip !=
NULL);
2272 assert(scip !=
NULL);
2273 assert(conshdlr !=
NULL);
2277 assert(conshdlrdata !=
NULL);
2280 if( conshdlrdata->varhash !=
NULL )
2297 assert(scip !=
NULL);
2298 assert(conshdlr !=
NULL);
2302 assert(conshdlrdata !=
NULL);
2305 for( c = 0; c < nconss; ++c )
2309 assert(conss !=
NULL);
2310 assert(conss[c] !=
NULL);
2312 assert(consdata !=
NULL);
2317 if( consdata->rowub !=
NULL )
2321 if( consdata->rowlb !=
NULL )
2328 if( conshdlrdata->varhash !=
NULL )
2340 assert(scip !=
NULL);
2342 assert(cons !=
NULL);
2343 assert(consdata !=
NULL);
2356 assert(conshdlrdata !=
NULL);
2357 assert(conshdlrdata->eventhdlr !=
NULL);
2359 for( j = 0; j < (*consdata)->nvars; ++j )
2362 (*consdata)->indvars[j], &(*consdata)->eventdatas[j]) );
2363 assert((*consdata)->eventdatas[j] ==
NULL);
2367 if( (*consdata)->weights !=
NULL )
2378 if( (*consdata)->rowub !=
NULL )
2382 if( (*consdata)->rowlb !=
NULL )
2386 assert((*consdata)->rowub ==
NULL);
2387 assert((*consdata)->rowlb ==
NULL);
2404 assert(scip !=
NULL);
2405 assert(conshdlr !=
NULL);
2407 assert(sourcecons !=
NULL);
2408 assert(targetcons !=
NULL);
2412 assert(conshdlrdata !=
NULL);
2413 assert(conshdlrdata->eventhdlr !=
NULL);
2419 assert(sourcedata !=
NULL);
2420 assert(sourcedata->nvars > 0);
2421 assert(sourcedata->nvars <= sourcedata->maxvars);
2426 consdata->cons =
NULL;
2427 consdata->nvars = sourcedata->nvars;
2428 consdata->maxvars = sourcedata->nvars;
2429 consdata->cardval = sourcedata->cardval;
2430 consdata->rowub =
NULL;
2431 consdata->rowlb =
NULL;
2432 consdata->eventdatascurrent =
NULL;
2433 consdata->neventdatascurrent = 0;
2434 consdata->ntreatnonzeros = 0;
2442 if( sourcedata->weights !=
NULL )
2447 consdata->weights =
NULL;
2449 for( j = 0; j < sourcedata->nvars; ++j )
2451 assert(sourcedata->vars[j] != 0);
2452 assert(sourcedata->indvars[j] != 0);
2458 ++(consdata->ntreatnonzeros);
2470 consdata->cons = *targetcons;
2471 assert(consdata->cons !=
NULL);
2474 for( j = 0; j < consdata->nvars; ++j )
2477 consdata->vars[j], consdata->indvars[j], j, &consdata->eventdatas[j]) );
2478 assert(consdata->eventdatas[j] !=
NULL);
2484 SCIPdebugMsg(scip,
"constraint <%s> has %d variables fixed to be nonzero, allthough the constraint allows \ 2485 only %d nonzero variables\n",
SCIPconsGetName(*targetcons), consdata->ntreatnonzeros, consdata->cardval);
2503 assert(scip !=
NULL);
2504 assert(conshdlr !=
NULL);
2506 assert(result !=
NULL);
2508 SCIPdebugMsg(scip,
"Presolving cardinality constraints.\n");
2511 SCIPdebug( oldnfixedvars = *nfixedvars; )
2513 SCIPdebug( oldnupgdconss = *nupgdconss; )
2517 if( nrounds == 0 || nnewfixedvars > 0 || nnewaggrvars > 0 )
2522 assert(eventhdlr !=
NULL);
2527 for( c = 0; c < nconss; ++c )
2534 assert(conss !=
NULL);
2535 assert(conss[c] !=
NULL);
2539 assert(consdata !=
NULL);
2540 assert(consdata->nvars >= 0);
2541 assert(consdata->nvars <= consdata->maxvars);
2546 ndelconss, nupgdconss, nfixedvars, &nremovedvars) );
2559 (*nchgcoefs) += nremovedvars;
2561 SCIPdebugMsg(scip,
"presolving fixed %d variables, removed %d variables, deleted %d constraints, \ 2562 and upgraded %d constraints.\n", *nfixedvars - oldnfixedvars, nremovedvars, *ndelconss - oldndelconss,
2563 *nupgdconss - oldnupgdconss);
2574 assert(scip !=
NULL);
2575 assert(conshdlr !=
NULL);
2588 assert(scip !=
NULL);
2590 assert(conss !=
NULL);
2591 assert(result !=
NULL);
2602 assert(scip !=
NULL);
2604 assert(conss !=
NULL);
2605 assert(result !=
NULL);
2616 assert(scip !=
NULL);
2618 assert(conss !=
NULL);
2620 assert(result !=
NULL);
2631 assert( scip !=
NULL );
2633 assert( conss !=
NULL );
2635 assert( result !=
NULL );
2646 assert(scip !=
NULL);
2648 assert(conss !=
NULL);
2650 assert(result !=
NULL);
2666 assert(scip !=
NULL);
2667 assert(conshdlr !=
NULL);
2668 assert(conss !=
NULL);
2670 assert(result !=
NULL);
2673 for( c = 0; c < nconss; ++c )
2681 assert(conss[c] !=
NULL);
2683 assert(consdata !=
NULL);
2684 cardval = consdata->cardval;
2688 for( j = 0; j < consdata->nvars; ++j )
2708 for( l = 0; l < consdata->nvars; ++l )
2736 assert(scip !=
NULL);
2737 assert(conshdlr !=
NULL);
2738 assert(conss !=
NULL);
2740 assert(result !=
NULL);
2746 for( c = 0; c < nconss; ++c )
2753 assert(conss[c] !=
NULL);
2756 assert(consdata !=
NULL);
2767 SCIPdebugMsg(scip,
"Propagated %d domains.\n", nchgdomain);
2768 if( nchgdomain > 0 )
2795 assert(scip !=
NULL);
2796 assert(conshdlr !=
NULL);
2797 assert(cons !=
NULL);
2800 assert(consdata !=
NULL);
2804 vars = consdata->vars;
2805 indvars = consdata->indvars;
2806 nvars = consdata->nvars;
2807 assert(vars !=
NULL);
2809 for( j = 0; j < nvars; ++j )
2814 indvar = indvars[j];
2842 assert(scip !=
NULL);
2843 assert(conshdlr !=
NULL);
2844 assert(cons !=
NULL);
2848 assert(consdata !=
NULL);
2851 for( j = 0; j < consdata->nvars; ++j )
2856 if( consdata->weights ==
NULL )
2877 const char* consname;
2881 assert(scip !=
NULL);
2882 assert(sourcescip !=
NULL);
2883 assert(sourcecons !=
NULL);
2894 SCIPdebugMsg(scip,
"Copying cardinality constraint <%s> ...\n", consname);
2897 assert(sourceconsdata !=
NULL);
2900 nvars = sourceconsdata->nvars;
2905 sourcevars = sourceconsdata->vars;
2906 assert(sourcevars !=
NULL);
2907 sourceindvars = sourceconsdata->indvars;
2908 assert(sourceindvars !=
NULL);
2909 sourceweights = sourceconsdata->weights;
2910 assert(sourceweights !=
NULL);
2918 for( v = 0; v < nvars && *valid; ++v )
2920 assert(sourcevars[v] !=
NULL);
2921 assert(sourceindvars[v] !=
NULL);
2923 SCIP_CALL(
SCIPgetVarCopy(sourcescip, scip, sourcevars[v], &(targetvars[v]), varmap, consmap, global, valid) );
2926 SCIP_CALL(
SCIPgetVarCopy(sourcescip, scip, sourceindvars[v], &(targetindvars[v]), varmap, consmap, global, valid) );
2934 targetweights, initial, separate, enforce, check, propagate, local, dynamic, removable, stickingatnode) );
2952 assert(consdata !=
NULL);
2954 if( varssize < consdata->nvars )
2958 assert(vars !=
NULL);
2974 assert(consdata !=
NULL);
2976 (*nvars) = consdata->nvars;
2998 assert(eventhdlr !=
NULL);
2999 assert(eventdata !=
NULL);
3001 assert(event !=
NULL);
3003 consdata = eventdata->consdata;
3004 assert(consdata !=
NULL);
3005 assert(0 <= consdata->ntreatnonzeros && consdata->ntreatnonzeros <= consdata->nvars);
3006 assert(consdata->eventdatascurrent !=
NULL);
3007 assert(consdata->eventvarscurrent !=
NULL);
3010 assert(var !=
NULL);
3016 if( ( eventdata->varmarked && var == eventdata->var) || ( eventdata->indvarmarked && var == eventdata->indvar) )
3020 for( i = 0; i < consdata->neventdatascurrent; ++i )
3022 if( var == consdata->eventvarscurrent[i] )
3027 assert(i < consdata->neventdatascurrent);
3032 if( var == eventdata->indvar )
3035 assert(consdata->cons !=
NULL);
3040 ++(consdata->ntreatnonzeros);
3042 --(consdata->ntreatnonzeros);
3044 assert(0 <= consdata->ntreatnonzeros && consdata->ntreatnonzeros <= consdata->nvars);
3048 assert(oldbound == 1.0 && newbound == 0.0 );
3051 consdata->eventdatascurrent[consdata->neventdatascurrent] = eventdata;
3052 consdata->eventvarscurrent[consdata->neventdatascurrent] = var;
3053 ++consdata->neventdatascurrent;
3054 eventdata->indvarmarked =
TRUE;
3055 assert(consdata->neventdatascurrent <= 4 * consdata->maxvars);
3056 assert(var == eventdata->indvar );
3062 if( var == eventdata->var && ! eventdata->varmarked )
3070 consdata->eventdatascurrent[consdata->neventdatascurrent] = eventdata;
3071 consdata->eventvarscurrent[consdata->neventdatascurrent] = var;
3072 ++consdata->neventdatascurrent;
3073 eventdata->varmarked =
TRUE;
3074 assert(consdata->neventdatascurrent <= 4 * consdata->maxvars );
3075 assert(var == eventdata->var );
3084 consdata->eventdatascurrent[consdata->neventdatascurrent] = eventdata;
3085 consdata->eventvarscurrent[consdata->neventdatascurrent] = var;
3086 ++consdata->neventdatascurrent;
3087 eventdata->varmarked =
TRUE;
3088 assert(consdata->neventdatascurrent <= 4 * consdata->maxvars );
3089 assert(var == eventdata->var);
3093 assert(0 <= consdata->ntreatnonzeros && consdata->ntreatnonzeros <= consdata->nvars);
3095 SCIPdebugMsg(scip,
"event exec cons <%s>: changed bound of variable <%s> from %f to %f (ntreatnonzeros: %d).\n",
3097 oldbound, newbound, consdata->ntreatnonzeros);
3114 conshdlrdata->eventhdlr =
NULL;
3115 conshdlrdata->varhash =
NULL;
3119 eventExecCardinality,
NULL) );
3120 if( conshdlrdata->eventhdlr ==
NULL )
3122 SCIPerrorMessage(
"event handler for cardinality constraints not found.\n");
3129 consEnfolpCardinality, consEnfopsCardinality, consCheckCardinality, consLockCardinality, conshdlrdata) );
3130 assert(conshdlr !=
NULL);
3152 "whether to use balanced instead of unbalanced branching",
3156 "maximum depth for using balanced branching (-1: no limit)",
3160 "determines that balanced branching is only used if the branching cut off value \ 3161 w.r.t. the current LP solution is greater than a given value",
3220 if( conshdlr ==
NULL )
3228 assert(conshdlrdata !=
NULL);
3235 consdata->cons =
NULL;
3236 consdata->vars =
NULL;
3237 consdata->indvars =
NULL;
3238 consdata->eventdatas =
NULL;
3239 consdata->nvars = nvars;
3240 consdata->cardval = cardval;
3241 consdata->maxvars = nvars;
3242 consdata->rowub =
NULL;
3243 consdata->rowlb =
NULL;
3244 consdata->eventdatascurrent =
NULL;
3245 consdata->eventvarscurrent =
NULL;
3246 consdata->neventdatascurrent = 0;
3247 consdata->ntreatnonzeros = transformed ? 0 : -1;
3248 consdata->weights =
NULL;
3256 if( indvars !=
NULL )
3262 if( conshdlrdata->varhash ==
NULL )
3269 for( v = 0; v < nvars; ++v )
3274 assert(implvar !=
NULL);
3286 consdata->indvars[v] = implvar;
3296 consdata->indvars[v] = var;
3314 if( weights !=
NULL )
3324 for( v = 0; v < nvars; ++v )
3328 SCIPsortRealPtrPtrInt(consdata->weights, (
void**)consdata->vars, (
void**)consdata->indvars, dummy, nvars);
3335 assert(weights ==
NULL);
3339 SCIP_CALL(
SCIPcreateCons(scip, cons, name, conshdlr, consdata, initial, separate, enforce, check, propagate,
3340 local, modifiable, dynamic, removable, stickingatnode) );
3342 consdata->cons = *cons;
3343 assert(consdata->cons !=
NULL);
3346 for( v = nvars - 1; v >= 0; --v )
3354 assert(consdata->vars[v] !=
NULL);
3355 assert(consdata->indvars[v] !=
NULL);
3361 consdata->indvars[v], v, transformed, &consdata->eventdatas[v]) );
3362 assert(! transformed || consdata->eventdatas[v] !=
NULL);
3389 SCIP_CALL(
SCIPcreateConsCardinality(scip, cons, name, nvars, vars, cardval, indvars, weights,
TRUE,
TRUE,
TRUE,
TRUE,
3404 assert(scip !=
NULL);
3405 assert(cons !=
NULL);
3414 assert(consdata !=
NULL);
3416 SCIPdebugMsg(scip,
"modify right hand side of cardinality constraint from <%i> to <%i>\n", consdata->cardval, cardval);
3419 consdata->cardval = cardval;
3438 assert(scip !=
NULL);
3439 assert(var !=
NULL);
3440 assert(cons !=
NULL);
3446 assert(conshdlr !=
NULL);
3454 assert(conshdlrdata !=
NULL);
3474 assert(scip !=
NULL);
3475 assert(var !=
NULL);
3476 assert(cons !=
NULL);
3481 assert(conshdlr !=
NULL);
3489 assert(conshdlrdata !=
NULL);
3504 assert(scip !=
NULL);
3505 assert(cons !=
NULL);
3515 assert(consdata !=
NULL);
3517 return consdata->nvars;
3528 assert(scip !=
NULL);
3529 assert(cons !=
NULL);
3539 assert(consdata !=
NULL);
3541 return consdata->vars;
3552 assert(scip !=
NULL);
3553 assert(cons !=
NULL);
3562 assert(consdata !=
NULL);
3564 return consdata->cardval;
3575 assert(scip !=
NULL);
3576 assert(cons !=
NULL);
3586 assert(consdata !=
NULL);
3588 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)
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 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)
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)
SCIP_Bool SCIPconsIsLocal(SCIP_CONS *cons)
SCIP_RETCODE SCIPaddCut(SCIP *scip, SCIP_SOL *sol, SCIP_ROW *cut, 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)
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)