All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
cons_pseudoboolean.c
Go to the documentation of this file.
22 * The constraint handler deals with pseudo Boolean constraints. These are constraints of the form
24 * \mbox{lhs} \leq \sum_{k=0}^m c_k \cdot x_k + \sum_{i=0}^n c_i \cdot \prod_{j \in I_i} x_j \leq \mbox{rhs}
31 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
53 #define CONSHDLR_ENFOPRIORITY -1000000 /**< priority of the constraint handler for constraint enforcing */
54 #define CONSHDLR_CHECKPRIORITY -5000000 /**< priority of the constraint handler for checking feasibility */
55 #define CONSHDLR_EAGERFREQ 100 /**< frequency for using all instead of only the useful constraints in separation,
57 #define CONSHDLR_MAXPREROUNDS -1 /**< maximal number of presolving rounds the constraint handler participates in (-1: no limit) */
58 #define CONSHDLR_DELAYPRESOL FALSE /**< should presolving method be delayed, if other presolvers found reductions? */
59 #define CONSHDLR_NEEDSCONS TRUE /**< should the constraint handler be skipped, if no constraints are available? */
61 #define DEFAULT_DECOMPOSENORMALPBCONS FALSE /**< decompose all normal pseudo boolean constraint into a "linear" constraint "and" constrainst */
62 #define DEFAULT_DECOMPOSEINDICATORPBCONS TRUE /**< decompose all indicator pseudo boolean constraint into a "linear" constraint "and" constrainst */
64 #define DEFAULT_SEPARATENONLINEAR TRUE /**< if decomposed, should the nonlinear constraints be separated during LP processing */
65 #define DEFAULT_PROPAGATENONLINEAR TRUE /**< if decomposed, should the nonlinear constraints be propagated during node processing */
66 #define DEFAULT_REMOVABLENONLINEAR TRUE /**< if decomposed, should the nonlinear constraints be removable */
72 #define HASHSIZE_PSEUDOBOOLEANNONLINEARTERMS 131101 /**< minimal size of hash table in and constraint tables */
75 /* - create special linear(knapsack, setppc, logicor, (eqknapsack)) and and-constraints with check flags FALSE, to
76 * get smaller amount of locks on the term variables, do all presolving ...?! in these constraint handlers
78 * - do the checking here, lock and-resultants in both directions and all and-variables according to their
80 * @note this only works if the and-resultant has no objective cofficient, otherwise we need to lock variables also in both directions
82 * - need to keep and constraint pointer for special propagations like if two ands are due to their variables in
86 * check/IP/PseudoBoolean/normalized-PB07/OPT-SMALLINT-NLC/submittedPB07/manquinho/bsg/normalized-bsg_1000_25_1.opb.gz
107 /* @todo - in and-constraint better count nfixed zeros in both directions and maybe nfixedones for better propagation
109 * - do better conflict analysis by choosing the earliest fixed variable which led to a conflict instead of maybe
112 * - how to make sure that we aggregate in a right way, when aggregating a resultant and a "normal" variable,
113 * maybe add in SCIPaggregateVars a check for original variables, to prefer them if the variable type is the
114 * same; probably it would be better too if we would aggregate two resultants that the one with less variables
117 * @note since product resultants are artificial, we do not care for their solution value, but this can lead to fixation
118 * of the resultant not representing the product, in 'optimization mode' we do not care, but this might make
148 SCIP_LINEARCONSTYPE linconstype; /**< type of linear constraint which represents this pseudoboolean constraint */
151 CONSANDDATA** consanddatas; /**< array of and-constraints-data-objects sorted after and-resultant of
178 CONSANDDATA** allconsanddatas; /**< array of all and-constraint data objects inside the whole problem,
190 SCIP_Bool decomposenormalpbcons;/**< decompose the pseudo boolean constraint into a "linear" constraint "and" constrainst */
191 SCIP_Bool decomposeindicatorpbcons;/**< decompose the indicator pseudo boolean constraint into a "linear" constraint "and" constrainst */
202 /** comparison method for sorting consanddatas according to the index of their corresponding resultant variables, if a
203 * consanddata object is delete it is handled like it has an inactive resultant, so this will be put in front while
275 /** returns TRUE iff both keys are equal; two non-linear terms are equal if they have the same variables */
367 /** initializes the hashmap and -table used in this constraint handler data for artificial variables and specific
389 SCIP_CALL( SCIPhashtableCreate(&((*conshdlrdata)->hashtable), SCIPblkmem(scip), (*conshdlrdata)->hashtablesize,
394 SCIP_CALL( SCIPhashmapCreate(&((*conshdlrdata)->hashmap), SCIPblkmem(scip), (*conshdlrdata)->hashmapsize) );
417 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &((*conshdlrdata)->allconsanddatas), (*conshdlrdata)->sallconsanddatas ) );
464 SCIPfreeBlockMemoryArray(scip, &((*conshdlrdata)->allconsanddatas), (*conshdlrdata)->sallconsanddatas );
587 SCIP_VAR**const vars, /**< array to store sorted (after indices) variables of linear constraint */
737 /** calculate all not artificial linear variables and all artificial and-resultants which will be ordered like the
738 * 'consanddatas' such that the and-resultant of the and-constraint is the and-resultant in the 'andress' array
748 SCIP_VAR**const linvars, /**< array to store not and-resultant variables of linear constraint, or NULL */
749 SCIP_Real*const lincoefs, /**< array to store coefficients of not and-resultant variables of linear
752 SCIP_VAR**const andress, /**< array to store and-resultant variables of linear constraint, or NULL */
781 /* @note it is necessary that the linear constraint is merged (not needed for negated variables) and sorted after
800 /* if and resultant is not a resultant anymore (meaning the corresponding and-constraint was deleted/upgraded),
807 hashmapentryexists = (((CONSANDDATA*) SCIPhashmapGetImage(conshdlrdata->hashmap, (void*)(vars[v])))->istransformed);
811 assert(((CONSANDDATA*) SCIPhashmapGetImage(conshdlrdata->hashmap, (void*)(vars[v])))->cons != NULL);
812 hashmapentryexists = !SCIPconsIsDeleted(((CONSANDDATA*) SCIPhashmapGetImage(conshdlrdata->hashmap, (void*)(vars[v])))->cons);
847 /** transforming transformed consanddata object back to original space, if an corresponding original constraint exists,
918 SCIP_CALL( SCIPduplicateBlockMemoryArray(scip, &(consanddata->vars), SCIPgetVarsAnd(scip, consanddata->origcons), consanddata->nvars) );
930 assert(consanddata == (CONSANDDATA*)(SCIPhashtableRetrieve(conshdlrdata->hashtable, (void*)consanddata)));
931 assert(SCIPhashmapExists(conshdlrdata->hashmap, (void*)SCIPgetResultantAnd(scip, consanddata->origcons)));
932 assert(consanddata == (CONSANDDATA*)(SCIPhashmapGetImage(conshdlrdata->hashmap, (void*)SCIPgetResultantAnd(scip, consanddata->origcons))));
962 assert(consanddata == (CONSANDDATA*)(SCIPhashtableRetrieve(conshdlrdata->hashtable, (void*)consanddata)));
963 assert(SCIPhashmapExists(conshdlrdata->hashmap, (void*)SCIPgetResultantAnd(scip, consanddata->origcons)));
964 assert(consanddata == (CONSANDDATA*)(SCIPhashmapGetImage(conshdlrdata->hashmap, (void*)SCIPgetResultantAnd(scip, consanddata->origcons))));
980 SCIP_CONS*const lincons, /**< linear constraint with artificial and-resultants representing this pseudoboolean constraint */
982 SCIP_CONS**const andconss, /**< array of and-constraints which occur in this pseudoboolean constraint */
988 SCIP_VAR* const intvar, /**< a artificial variable which was added only for the objective function,
1022 SCIPerrorMessage("left hand side of pseudo boolean constraint greater than right hand side\n");
1067 /* do not capture the and constraint when scip is in transformed mode; this automatically happens in
1094 SCIP_CALL( SCIPduplicateBlockMemoryArray(scip, &((*consdata)->andcoefs), andcoefs, nandconss) );
1113 (*consdata)->consanddatas[c] = (CONSANDDATA*) SCIPhashmapGetImage(conshdlrdata->hashmap, (void*)andress[c]);
1115 assert((*consdata)->consanddatas[c]->origcons == andconss[c] || (*consdata)->consanddatas[c]->cons == andconss[c]);
1120 if( (*consdata)->consanddatas[c]->origcons != NULL && (*consdata)->consanddatas[c]->cons == NULL )
1126 /* do not capture the and constraint when scip is in transformed mode; this automatically happens in
1129 SCIP_CALL( SCIPtransformCons(scip, (*consdata)->consanddatas[c]->origcons, &((*consdata)->consanddatas[c]->cons)) );
1143 /* resort variables in transformed problem, because the order might change while tranforming */
1166 SCIPsortPtrPtrReal((void**)andress, (void**)((*consdata)->consanddatas), (*consdata)->andcoefs, SCIPvarComp, nandconss);
1230 /* count down uses and if necessary release constraints and delete data from hashtable and -map */
1246 /* if the consanddata is not used anymore, release the constraint and clear the hashmap- and table */
1260 assert(SCIPhashmapExists(conshdlrdata->hashmap, (void*)SCIPgetResultantAnd(scip, consanddatas[c]->cons)));
1261 SCIP_CALL( SCIPhashmapRemove(conshdlrdata->hashmap, (void*)SCIPgetResultantAnd(scip, consanddatas[c]->cons)) );
1281 conshdlrdata->allconsanddatas[d] = conshdlrdata->allconsanddatas[conshdlrdata->nallconsanddatas];
1301 /* if the consanddata is not used anymore, release the constraint and clear the hashmap- and table */
1314 assert(SCIPhashmapExists(conshdlrdata->hashmap, (void*)SCIPgetResultantAnd(scip, consanddatas[c]->origcons)));
1315 SCIP_CALL( SCIPhashmapRemove(conshdlrdata->hashmap, (void*)SCIPgetResultantAnd(scip, consanddatas[c]->origcons)) );
1347 conshdlrdata->allconsanddatas[d] = conshdlrdata->allconsanddatas[conshdlrdata->nallconsanddatas];
1414 assert(consanddatas[c] == (CONSANDDATA*)(SCIPhashtableRetrieve(conshdlrdata->hashtable, (void*)consanddatas[c])));
1415 assert(SCIPhashmapExists(conshdlrdata->hashmap, (void*)SCIPgetResultantAnd(scip, consanddatas[c]->origcons)));
1416 assert(consanddatas[c] == (CONSANDDATA*)(SCIPhashmapGetImage(conshdlrdata->hashmap, (void*)SCIPgetResultantAnd(scip, consanddatas[c]->origcons))));
1435 CONSANDDATA*const consanddata, /**< CONSANDDATA object for which we want to delete the locks and the
1457 /* choose correct variable array to add locks for, we only add locks for now valid variables */
1504 CONSANDDATA*const consanddata, /**< CONSANDDATA object for which we want to delete the locks and the
1605 /* more than one and-constraint is needed, otherwise this pseudoboolean constraint should be upgraded to a linear constraint */
1626 SCIP_CALL( getLinearConsVarsData(scip, consdata->lincons, consdata->linconstype, vars, coefs, &nvars) );
1629 /* calculate all not artificial linear variables and all artificial and-resultants which will be ordered like the
1630 * 'consanddatas' such that the and-resultant of the and-constraint is the and-resultant in the 'andress' array
1633 SCIP_CALL( getLinVarsAndAndRess(scip, cons, vars, coefs, nvars, linvars, lincoefs, &nlinvars, andress, andcoefs, &nandress) );
1636 /* number of variables should be consistent, number of 'real' linear variables plus number of and-constraints should
1772 SCIP_Bool const stickingatnode, /**< should the constraint always be kept at the node where it was added, even
1862 (void)SCIPsnprintf(name, SCIP_MAXSTRLEN, ARTIFICIALVARNAMEPREFIX"%d", conshdlrdata->nallconsanddatas);
1866 #if 1 /* @todo: check whether we want to branch on artificial variables, the test results show that it is of advantage */
1874 #if 0 /* does not work for since the value of artificial resultants must not be equal to the value computed by their
1894 if( (SCIPvarIsOriginal(resultant) || SCIPvarIsTransformedOrigvar(resultant)) && !SCIPisFeasEQ(scip, debugsolval, val) )
1896 SCIPerrorMessage("computed solution value %g for resultant <%s> violates debug solution value %g\n", val, SCIPvarGetName(resultant), debugsolval);
1932 SCIP_CALL( SCIPensureBlockMemoryArray(scip, &(conshdlrdata->allconsanddatas), &(conshdlrdata->sallconsanddatas), SCIPcalcMemGrowSize(scip, conshdlrdata->sallconsanddatas + 1)) );
2019 SCIPconsIsInitial(cons), SCIPconsIsEnforced(cons), SCIPconsIsChecked(cons), SCIPconsIsLocal(cons),
2027 SCIP_CALL( SCIPensureBlockMemoryArray(scip, &(consdata->consanddatas), &(consdata->sconsanddatas), consdata->sconsanddatas + 1) );
2034 consdata->consanddatas[consdata->nconsanddatas] = (CONSANDDATA*) SCIPhashmapGetImage(conshdlrdata->hashmap, (void*)res);
2076 SCIP_CALL( lockRoundingAndCons(scip, cons, consdata->consanddatas[consdata->nconsanddatas - 1], val, consdata->lhs, consdata->rhs) );
2183 SCIP_CALL( getLinearConsSides(scip, consdata->lincons, consdata->linconstype, &oldlhs, &oldrhs) );
2204 SCIP_CALL( getLinearConsVarsData(scip, consdata->lincons, consdata->linconstype, vars, coefs, &nvars) );
2207 /* calculate all not artificial linear variables and all artificial and-resultants which will be ordered like the
2208 * 'consanddatas' such that the and-resultant of the and-constraint is the and-resultant in the 'andress' array
2211 SCIP_CALL( getLinVarsAndAndRess(scip, cons, vars, coefs, nvars, linvars, lincoefs, &nlinvars, andress, andcoefs, &nandress) );
2297 /* check whether the left hand side is increased, if and only if that's the case we maybe can propagate, tighten and add more cliques */
2353 SCIP_CALL( getLinearConsSides(scip, consdata->lincons, consdata->linconstype, &oldlhs, &oldrhs) );
2374 SCIP_CALL( getLinearConsVarsData(scip, consdata->lincons, consdata->linconstype, vars, coefs, &nvars) );
2377 /* calculate all not artificial linear variables and all artificial and-resultants which will be ordered like the
2378 * 'consanddatas' such that the and-resultant of the and-constraint is the and-resultant in the 'andress' array
2381 SCIP_CALL( getLinVarsAndAndRess(scip, cons, vars, coefs, nvars, linvars, lincoefs, &nlinvars, andress, andcoefs, &nandress) );
2467 /* check whether the right hand side is decreased, if and only if that's the case we maybe can propagate, tighten and add more cliques */
2516 SCIP_Bool const stickingatnode, /**< should the constraint always be kept at the node where it was added, even
2590 SCIP_Bool const removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
2593 SCIP_Bool const stickingatnode, /**< should the constraint always be kept at the node where it was added, even
2598 SCIP_LINEARCONSTYPE*const linconstype /**< pointer to store the type of the linear constraint */
2709 SCIPdebugMessage("While cretaing the linear constraint of the pseudoboolean constraint we found %d zero coefficients that were removed\n", nzero);
2724 * - logic or constraints have left hand side of +1.0, and right hand side of +infinity: x(S) >= 1.0
2736 /* check, if we have to multiply with -1 (negate the positive vars) or with +1 (negate the negative vars) */
2769 initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode) );
2783 /* check, if linear constraint can be upgraded to set partitioning, packing, or covering constraint
2784 * - all set partitioning / packing / covering constraints consist only of binary variables with a
2791 * - a set partitioning constraint has left hand side of +1.0, and right hand side of +1.0 : x(S) == 1.0
2793 * - a set packing constraint has left hand side of -infinity, and right hand side of +1.0 : x(S) <= 1.0
2795 * - a set covering constraint has left hand side of +1.0, and right hand side of +infinity: x(S) >= 1.0
2803 if( SCIPisEQ(scip, *lhs, *rhs) && (SCIPisEQ(scip, *lhs, 1.0 - ncoeffsnone) || SCIPisEQ(scip, *lhs, ncoeffspone - 1.0)) )
2807 /* check, if we have to multiply with -1 (negate the positive vars) or with +1 (negate the negative vars) */
2840 initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode) );
2856 /* check, if we have to multiply with -1 (negate the positive vars) or with +1 (negate the negative vars) */
2889 initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode) );
2907 SCIPwarningMessage(scip, "Does not expect this, because this constraint should be a set packing constraint.\n");
2911 SCIPwarningMessage(scip, "Does not expect this, because this constraint should be a logicor constraint.\n");
2916 /* check, if we have to multiply with -1 (negate the positive vars) or with +1 (negate the negative vars) */
2949 initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode) );
2969 if( upgrconshdlr != NULL && !created && (ncoeffspone + ncoeffsnone + ncoeffspint + ncoeffsnint == nvars) && (SCIPisInfinity(scip, -*lhs) != SCIPisInfinity(scip, *rhs)) )
2983 /* if the right hand side is non-infinite, we have to negate all variables with negative coefficient;
2984 * otherwise, we have to negate all variables with positive coefficient and multiply the row with -1
3036 initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode) );
3057 if( upgrconshdlr != NULL && !created && (ncoeffspone + ncoeffsnone + ncoeffspint + ncoeffsnint == nvars) && SCIPisEQ(scip, *lhs, *rhs) )
3123 initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode) );
3145 initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode) );
3243 SCIP_CALL( getLinearConsVarsData(scip, consdata->lincons, consdata->linconstype, vars, coefs, &nvars) );
3246 /* number of variables should be consistent, number of 'real' linear variables plus number of and-constraints should
3263 /* split variables into original and artificial variables and compute activity on normal linear variables(without
3301 /* if after during or before presolving a solution will be transformed into original space and will be checked
3302 * there, but origcons was already removed and only the pointer to the transformed and-constraint is existing
3338 SCIPinfoMessage(scip, NULL, "violation: left hand side is violated by %.15g\n", lhs - activity);
3354 SCIPinfoMessage(scip, NULL, "violation: right hand side is violated by %.15g\n", activity - rhs);
3371 /** checks all and-constraints inside the pseudoboolean constraint handler for feasibility of given solution or current
3454 SCIP_HASHMAP*const varmap, /**< a SCIP_HASHMAP mapping variables of the source SCIP to corresponding
3456 SCIP_HASHMAP*const consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
3466 SCIP_Bool const removable, /**< should the relaxation be removed from the LP due to aging or cleanup? */
3467 SCIP_Bool const stickingatnode, /**< should the constraint always be kept at the node where it was added, even
3543 SCIP_CALL( SCIPgetConsCopy(sourcescip, targetscip, sourcelincons, &targetlincons, conshdlrlinear, varmap, consmap, SCIPconsGetName(sourcelincons),
3544 SCIPconsIsInitial(sourcelincons), SCIPconsIsSeparated(sourcelincons), SCIPconsIsEnforced(sourcelincons), SCIPconsIsChecked(sourcelincons),
3545 SCIPconsIsPropagated(sourcelincons), SCIPconsIsLocal(sourcelincons), SCIPconsIsModifiable(sourcelincons), SCIPconsIsDynamic(sourcelincons),
3552 /* @note due to copying special linear constraints, now leads only to simple linear constraints, we check that
3553 * our target constraint handler is the same as our source constraint handler of the linear constraint,
3596 SCIP_CALL( SCIPgetConsCopy(sourcescip, targetscip, oldcons, &targetandconss[ntargetandconss], conshdlrand, varmap, consmap, SCIPconsGetName(oldcons),
3597 SCIPconsIsInitial(oldcons), SCIPconsIsSeparated(oldcons), SCIPconsIsEnforced(oldcons), SCIPconsIsChecked(oldcons),
3598 SCIPconsIsPropagated(oldcons), SCIPconsIsLocal(oldcons), SCIPconsIsModifiable(oldcons), SCIPconsIsDynamic(oldcons),
3614 SCIPdebugMessage("no and-constraints copied for pseudoboolean constraint <%s>\n", SCIPconsGetName(sourcecons));
3633 SCIP_CALL( SCIPgetVarCopy(sourcescip, targetscip, indvar, &indvar, varmap, consmap, global, valid) );
3639 SCIP_CALL( SCIPgetVarCopy(sourcescip, targetscip, intvar, &intvar, varmap, consmap, global, valid) );
3653 initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode) );
3657 SCIPverbMessage(sourcescip, SCIP_VERBLEVEL_MINIMAL, NULL, "could not copy constraint <%s>\n", SCIPconsGetName(sourcecons));
3733 assert(consanddata->nnewvars == 0 && ((consanddata->snewvars > 0) == (consanddata->newvars != NULL)));
3771 /* check for changings, if and-constraint did not change we do not need to copy all variables */
3795 SCIP_CALL( SCIPensureBlockMemoryArray(scip, &(consanddata->newvars), &(consanddata->snewvars), nnewvars) );
3819 CONSANDDATA*const consanddata, /**< CONSANDDATA object for which we want to delete the locks and the
3847 CONSANDDATA*const consanddata, /**< CONSANDDATA object for which we want to delete the locks and the
3879 SCIP_Real*const andcoefs, /**< current and-resultants-coeffcients in pseudoboolean constraint */
3908 SCIPsortPtrReal((void**)(consdata->consanddatas), consdata->andcoefs, resvarCompWithInactive, consdata->nconsanddatas);
3922 /* check that consanddata objects are sorted due to the index of the corresponding resultants, and coefficents are
3996 SCIP_CALL( unlockRoundingAndCons(scip, cons, consanddatas[c], oldandcoefs[c], consdata->lhs, consdata->rhs) );
4014 /* collect new consanddata objects in sorted order due to the variable index of corresponding and-resultants */
4021 SCIP_CALL( removeOldLocks(scip, cons, consanddatas[c], oldandcoefs[c], consdata->lhs, consdata->rhs) );
4030 newconsanddatas[nnewconsanddatas] = (CONSANDDATA*) SCIPhashmapGetImage(conshdlrdata->hashmap, (void*)res2);
4035 SCIP_CALL( addNewLocks(scip, cons, newconsanddatas[nnewconsanddatas], newandcoefs[nnewconsanddatas], newlhs, newrhs) );
4061 coefsignchanged = (oldandcoefs[c] < 0 && andcoefs[c1] > 0) || (oldandcoefs[c] > 0 && andcoefs[c1] < 0);
4062 lhschanged = (SCIPisInfinity(scip, -consdata->lhs) && !SCIPisInfinity(scip, -newlhs)) || (!SCIPisInfinity(scip, -consdata->lhs) && SCIPisInfinity(scip, -newlhs))
4064 rhschanged = (SCIPisInfinity(scip, consdata->rhs) && !SCIPisInfinity(scip, newrhs)) || (!SCIPisInfinity(scip, consdata->rhs) && SCIPisInfinity(scip, newrhs))
4073 SCIP_CALL( removeOldLocks(scip, cons, newconsanddatas[nnewconsanddatas], oldandcoefs[c], consdata->lhs, consdata->rhs) );
4074 SCIP_CALL( addNewLocks(scip, cons, newconsanddatas[nnewconsanddatas], newandcoefs[nnewconsanddatas], newlhs, newrhs) );
4085 SCIP_CALL( removeOldLocks(scip, cons, newconsanddatas[nnewconsanddatas], oldandcoefs[c], consdata->lhs, consdata->rhs) );
4086 SCIP_CALL( addNewLocks(scip, cons, newconsanddatas[nnewconsanddatas], newandcoefs[nnewconsanddatas], newlhs, newrhs) );
4133 SCIP_CALL( removeOldLocks(scip, cons, consanddatas[c], oldandcoefs[c], consdata->lhs, consdata->rhs) );
4150 newconsanddatas[nnewconsanddatas] = (CONSANDDATA*) SCIPhashmapGetImage(conshdlrdata->hashmap, (void*)res2);
4155 SCIP_CALL( addNewLocks(scip, cons, newconsanddatas[nnewconsanddatas], newandcoefs[nnewconsanddatas], newlhs, newrhs) );
4185 SCIP_CALL( getLinearConsNVars(scip, consdata->lincons, consdata->linconstype, &(consdata->nlinvars)) );
4202 /* check that consanddata objects are sorted due to the index of the corresponding resultants */
4260 /* if we have no and-constraints left, we should not be here and this constraint should be deleted (only the linaer should survive) */
4290 SCIP_CALL( getLinearConsVarsData(scip, consdata->lincons, consdata->linconstype, vars, coefs, &nvars) );
4293 /* calculate all not artificial linear variables and all artificial and-resultants which will be ordered like the
4294 * 'consanddatas' such that the and-resultant of the and-constraint is the and-resultant in the 'andress' array
4297 SCIP_CALL( getLinVarsAndAndRess(scip, cons, vars, coefs, nvars, linvars, lincoefs, &nlinvars, andress, andcoefs, &nandress) );
4332 if( !SCIPvarIsActive(var1) && (!SCIPvarIsNegated(var1) || !SCIPvarIsActive(SCIPvarGetNegationVar(var1))) )
4349 if( !SCIPvarIsActive(var2) && (!SCIPvarIsNegated(var2) || !SCIPvarIsActive(SCIPvarGetNegationVar(var2))) )
4361 /* if variable in and-constraint1 is the negated variable of a normal linear variable, than we can add a
4362 * clique between the and-resultant and the normal linear variable, negated variables are not save in
4384 /* @todo: check whether it is better to only add the clique or to add the setppc constraint or do both */
4393 (void) SCIPsnprintf(consname, SCIP_MAXSTRLEN, "%s_clq_%s_%s", SCIPconsGetName(cons), SCIPvarGetName(clqvars[0]), SCIPvarGetName(clqvars[1]) );
4406 /* if a variable in an and-constraint is in a clique with another normal linear variable, we can add the
4427 /* @todo: check whether it is better to only add the clique or to add the setppc constraint or do both */
4436 (void) SCIPsnprintf(consname, SCIP_MAXSTRLEN, "%s_clq_%s_%s", SCIPconsGetName(cons), SCIPvarGetName(clqvars[0]), SCIPvarGetName(clqvars[1]) );
4502 if( !SCIPvarIsActive(var1) && (!SCIPvarIsNegated(var1) || !SCIPvarIsActive(SCIPvarGetNegationVar(var1))) )
4519 if( !SCIPvarIsActive(var2) && (!SCIPvarIsNegated(var2) || !SCIPvarIsActive(SCIPvarGetNegationVar(var2))) )
4531 /* if a variable in and-constraint1 is the negated variable of a variable in and-constraint2, than we can
4553 /* @todo: check whether it is better to only add the clique or to add the setppc constraint or do both */
4562 (void) SCIPsnprintf(consname, SCIP_MAXSTRLEN, "%s_clq_%s_%s", SCIPconsGetName(cons), SCIPvarGetName(clqvars[0]), SCIPvarGetName(clqvars[1]) );
4575 /* if a variable in an and-constraint is in a clique with a variable in another and-constraint, we can add
4597 /* @todo: check whether it is better to only add the clique or to add the setppc constraint or do both */
4606 (void) SCIPsnprintf(consname, SCIP_MAXSTRLEN, "%s_clq_%s_%s", SCIPconsGetName(cons), SCIPvarGetName(clqvars[0]), SCIPvarGetName(clqvars[1]) );
4749 assert(consanddata->nnewvars == 0 || (consanddata->newvars != NULL && consanddata->snewvars > 0));
4795 /* the consanddata object is not used anymore, so extract the and constraint and delete other data */
4821 /* @note due to aggregations or fixings the resultant may need to be propagated later on, so we can only
4843 /* all inactive variables have a loose, column, fixed or multi-aggregated variable as counterpart, but
4847 * @todo for multi-aggregated variables check also all active representatives for this resultant
4851 assert(SCIPvarGetStatus(fixedvars[w]) == SCIP_VARSTATUS_LOOSE || SCIPvarGetStatus(fixedvars[w]) == SCIP_VARSTATUS_COLUMN || SCIPvarGetStatus(fixedvars[w]) == SCIP_VARSTATUS_FIXED);
4856 if( SCIPsortedvecFindPtr((void**)fixedvars, SCIPvarComp, SCIPgetResultantAnd(scip, consanddata->cons), nfixedvars, &pos) )
4888 assert(SCIPhashmapExists(conshdlrdata->hashmap, (void*)SCIPgetResultantAnd(scip, consanddata->cons)));
4889 SCIP_CALL( SCIPhashmapRemove(conshdlrdata->hashmap, (void*)SCIPgetResultantAnd(scip, consanddata->cons)) );
4954 /** update the uses counter of consandata objects which are used in pseudoboolean constraint, that were deleted and
5000 SCIP_CALL( removeOldLocks(scip, cons, consanddata, consdata->andcoefs[c], consdata->lhs, consdata->rhs) );
5034 /* @note due to aggregations or fixings the resultant may need to be propagated later on, so we can only
5055 /* all inactive variables have a loose, column, fixed or multi-aggregated variable as counterpart, but
5059 * @todo for multi-aggregated variables check also all active representatives for this resultant
5066 assert(SCIPvarGetStatus(fixedvars[w]) == SCIP_VARSTATUS_LOOSE || SCIPvarGetStatus(fixedvars[w]) == SCIP_VARSTATUS_COLUMN || SCIPvarGetStatus(fixedvars[w]) == SCIP_VARSTATUS_FIXED);
5079 /* we can only delete and constraints if the resultant is an artificial variable and also active, because
5080 * then the assigned value is not of interest and the artificial and constraint does not need to be
5083 * if this variable is not such an artificial variable we need the IRRELEVANT vartype which should be the
5089 strncmp(SCIPvarGetName(resvar)+2, ARTIFICIALVARNAMEPREFIX, strlen(ARTIFICIALVARNAMEPREFIX)) == 0
5100 /* @note due to aggregations or fixings the resultant may need to be propagated later on, so we can only
5129 assert(SCIPhashmapExists(conshdlrdata->hashmap, (void*)SCIPgetResultantAnd(scip, consanddata->cons)));
5130 SCIP_CALL( SCIPhashmapRemove(conshdlrdata->hashmap, (void*)SCIPgetResultantAnd(scip, consanddata->cons)) );
5143 /* maximal number to enumerate solutions for one pseudoboolean constraint to check for an upgrade to an XOR constraint */
5146 /** calculate result for a given pseudoboolean constraint with given values, this is used to decide whether a
5203 if( SCIPsortedvecFindPtr((void**)vars, SCIPvarCompActiveAndNegated, linvars[v], nvars, &pos) ) /*lint !e613*/
5229 /* choose correct variable array to add locks for, we only add locks for now valid variables */
5252 assert(!negated[v] || (SCIPvarIsNegated(repvars[v]) && SCIPvarGetNegatedVar(repvars[v]) != NULL));
5317 /** try upgrading pseudoboolean linear constraint to an XOR constraint and/or remove possible and-constraints
5319 * @note An XOR(x_1,..,x_n) = 1 <=> XOR(x1,..,~x_j,..,x_n) = 0, for j in {1,..,n}, which is not yet checked while
5384 assert(consdata->linconstype == SCIP_LINEARCONSTYPE_LINEAR || consdata->linconstype == SCIP_LINEARCONSTYPE_SETPPC);
5385 /*assert(consdata->linconstype == SCIP_LINEARCONSTYPE_LINEAR || consdata->linconstype == SCIP_LINEARCONSTYPE_EQKNAPSACK);*/
5388 if( !SCIPisEQ(scip, consdata->lhs, consdata->rhs) || (!SCIPisEQ(scip, consdata->lhs, 1.0) && !SCIPisZero(scip, consdata->lhs)) )
5415 SCIP_CALL( getLinearConsVarsData(scip, lincons, consdata->linconstype, allvars, allcoefs, &nallvars) );
5419 SCIP_CALL( getLinVarsAndAndRess(scip, cons, allvars, allcoefs, nallvars, linvars, lincoefs, &nlinvars, andress, andcoefs, &nandress) );
5426 SCIP_CALL( SCIPgetProbvarLinearSum(scip, linvars, lincoefs, &nlinvars, MAXNVARS, &constant, &requiredsize, TRUE) );
5443 /* choose correct variable array to add locks for, we only add locks for now valid variables */
5467 /* determine all dieffernet variables over the linear variables and all variables in all and constraints */
5477 assert(SCIPvarIsActive(repvars[v]) || (SCIPvarIsNegated(repvars[v]) && SCIPvarIsActive(SCIPvarGetNegationVar(repvars[v]))));
5516 assert(SCIPvarIsActive(repvars[v]) || (SCIPvarIsNegated(repvars[v]) && SCIPvarIsActive(SCIPvarGetNegationVar(repvars[v]))));
5544 /* check values for variables which result in solutions which in the end lead to an XOR upgrade */
5560 SCIP_CALL( checkSolution(scip, linvars, nlinvars, values, activelinvars, lincoefs, firstnlinvars, constant, consdata->lhs, consanddatas, andcoefs, nconsanddatas, cnt, &xortype) );
5573 SCIP_CALL( SCIPcreateConsXor(scip, &newcons, newname, (unsigned int) xortype, nlinvars, linvars,
5574 SCIPconsIsInitial(lincons), SCIPconsIsSeparated(lincons), SCIPconsIsEnforced(lincons), SCIPconsIsChecked(lincons),
5576 SCIPconsIsDynamic(lincons), SCIPconsIsRemovable(lincons), SCIPconsIsStickingAtNode(lincons)) );
5611 /** try upgrading pseudoboolean logicor constraint to a linear constraint and/or remove possible and-constraints */
5676 /* if we have only one term left in the logicor constraint, the presolving should be done by the logicor
5684 /* for every old logicor constraint: sum_i (x_i) + res >= 1 , with an and-constraint of res as the resultant,
5697 /* choose correct variable array to add locks for, we only add locks for now valid variables */
5716 SCIPconsIsInitial(lincons), SCIPconsIsSeparated(lincons), SCIPconsIsEnforced(lincons), SCIPconsIsChecked(lincons),
5718 SCIPconsIsDynamic(lincons), SCIPconsIsRemovable(lincons), SCIPconsIsStickingAtNode(lincons)) );
5733 SCIP_CALL( getLinearConsVarsData(scip, consdata->lincons, consdata->linconstype, allvars, allcoefs, &nallvars) );
5737 SCIP_CALL( getLinVarsAndAndRess(scip, cons, allvars, allcoefs, nallvars, linvars, lincoefs, &nlinvars, NULL, NULL, NULL) );
5816 /* choose correct variable array to add locks for, we only add locks for now valid variables */
5891 /* if all and-constraints in pseudoboolean constraint have some equal variables we can extract them and create a new
5892 * linear constraint; iff the number of equal variables is equal to the number of variables - 1 in all consanddata
5893 * objects then the new constraint will not contain any products; if no normal linear variables exist we can fix all
5903 * => x1 = 1 /\ x2 * x3 + x4 >= 1 (constraint is created indirectly, caused by the fixing of x1)
5924 /* if we have no normal linear variable in the logicor constraint, we can fix all equal variables */
5930 /* fix all equal variable in logicor constraints which have to be one to fulfill the constraint */
5945 /* if a complete consanddata object have all variables in common with all other consanddata objects, than we can
5976 SCIPconsIsInitial(lincons), SCIPconsIsSeparated(lincons), SCIPconsIsEnforced(lincons), SCIPconsIsChecked(lincons),
5978 SCIPconsIsDynamic(lincons), SCIPconsIsRemovable(lincons), SCIPconsIsStickingAtNode(lincons)) );
5980 /* if createcons == TRUE add all variables which are not in the eqvars array to the new constraint with
5993 /* choose correct variable array to add locks for, we only add locks for now valid variables */
6044 /* if we have normal linear variable in the logicor constraint, we did not fix all equal variables and we have to
6046 * we have to add also all normal linear variables with a coefficient of 'nconsanddatas * neqvars + 1'
6074 SCIP_CALL( getLinearConsVarsData(scip, consdata->lincons, consdata->linconstype, vars, coefs, &nvars) );
6083 SCIP_CALL( getLinVarsAndAndRess(scip, cons, vars, coefs, nvars, linvars, lincoefs, &nlinvars, NULL, NULL, NULL) );
6089 SCIP_CALL( SCIPaddCoefLinear(scip, newcons, linvars[v], (SCIP_Real)(nconsanddatas * neqvars + 1)) ); /*lint !e732 !e790*/
6093 SCIP_CALL( SCIPchgLhsLinear(scip, newcons, (SCIP_Real)(nconsanddatas * neqvars + 1)) ); /*lint !e732 !e790*/
6127 /** try upgrading pseudoboolean setppc constraint to a linear constraint and/or remove possible and-constraints */
6192 /* if we have only one term left in the setppc constraint, the presolving should be done by the setppc constraint handler */
6201 * sum_i (x_i) + res <= 1 , with and-constraint of res as the resultant like res = y_1 * ... * y_n
6266 /* choose correct variable array to add locks for, we only add locks for now valid variables */
6334 /* if all and-constraints in pseudoboolean constraint have the same length and some equal variables we can upgrade
6350 * => x1 = 1 /\ x2 * x3 + x4 == 1 (constraint is created indirectly, caused by the fixing of x1)
6364 if( neqvars > 0 && ((nminvars == nmaxvars && nminvars == neqvars + 1) || (nminvars == neqvars) || (type == SCIP_SETPPCTYPE_PARTITIONING)) )
6391 /* if one and-constraint was completely contained in all other and-constraints, we have to reduced the right hand
6397 createcons = (SCIPisLE(scip, lhs, rhs) && ((nminvars == nmaxvars && nminvars == neqvars + 1) || (nminvars == neqvars)));
6409 SCIPconsIsInitial(lincons), SCIPconsIsSeparated(lincons), SCIPconsIsEnforced(lincons), SCIPconsIsChecked(lincons),
6411 SCIPconsIsDynamic(lincons), SCIPconsIsRemovable(lincons), SCIPconsIsStickingAtNode(lincons)) );
6414 /* if createcons == TRUE add all variables which are not in the eqvars array to the new constraint with
6417 * otherwise (if createcons == FALSE) fix all variables to zero which are not in the eqvars array and if we have a
6430 /* choose correct variable array to add locks for, we only add locks for now valid variables */
6443 /* if the consanddata object has at least two more different variables then the equal variables we have to fix the resultant to zero */
6449 SCIP_CALL( SCIPfixVar(scip, SCIPgetResultantAnd(scip, consanddata->cons), 0.0, &infeasible, &fixed) );
6462 /* if the consanddata object has at exactly one more different variable then the equal variables we have to fix it to zero */
6535 /* fix all equal variable in set-partitioning constraints which have to be one, in set-packing constraint we have
6566 SCIP_CALL( SCIPchgRhsLinear(scip, newcons, rhs + (SCIP_Real)((nconsanddatas - 1) * neqvars)) ); /*lint !e790*/
6603 /** try upgrading pseudoboolean constraint to a linear constraint and/or remove possible and-constraints */
6642 /* if no consanddata-objects in pseudoboolean constraint are left, create the corresponding linear constraint */
6648 /* @TODO: maybe it is better to create everytime a standard linear constraint instead of letting the special
6664 SCIP_CALL( tryUpgradingXor(scip, cons, conshdlrdata, ndelconss, naddconss, nfixedvars, nchgcoefs, nchgsides, cutoff) );
6667 SCIP_CALL( tryUpgradingLogicor(scip, cons, conshdlrdata, ndelconss, naddconss, nfixedvars, nchgcoefs, nchgsides, cutoff) );
6672 SCIP_CALL( tryUpgradingSetppc(scip, cons, conshdlrdata, ndelconss, naddconss, nfixedvars, nchgcoefs, nchgsides, cutoff) );
6675 SCIP_CALL( tryUpgradingXor(scip, cons, conshdlrdata, ndelconss, naddconss, nfixedvars, nchgcoefs, nchgsides, cutoff) );
6680 SCIP_CALL( tryUpgradingXor(scip, cons, conshdlrdata, ndelconss, naddconss, nfixedvars, nchgcoefs, nchgsides, cutoff) );
6690 /* update the uses counter of consandata objects which are used in pseudoboolean constraint, which was deleted and
6749 if( consdata->linconstype != SCIP_LINEARCONSTYPE_SETPPC || SCIPgetTypeSetppc(scip, consdata->lincons) != SCIP_SETPPCTYPE_PARTITIONING )
6817 assert(SCIPvarIsActive(repvars[v]) || (SCIPvarIsNegated(repvars[v]) && SCIPvarIsActive(SCIPvarGetNegationVar(repvars[v]))));
6818 assert(SCIPvarIsActive(repvars[v-1]) || (SCIPvarIsNegated(repvars[v-1]) && SCIPvarIsActive(SCIPvarGetNegationVar(repvars[v-1]))));
6835 assert(SCIPvarIsActive(repvars[v]) || (SCIPvarIsNegated(repvars[v]) && SCIPvarIsActive(SCIPvarGetNegationVar(repvars[v]))));
6875 assert(SCIPvarIsActive(repvars[v]) || (SCIPvarIsNegated(repvars[v]) && SCIPvarIsActive(SCIPvarGetNegationVar(repvars[v]))));
6876 assert(SCIPvarIsActive(repvars[v-1]) || (SCIPvarIsNegated(repvars[v-1]) && SCIPvarIsActive(SCIPvarGetNegationVar(repvars[v-1]))));
6893 assert(SCIPvarIsActive(repvars[v]) || (SCIPvarIsNegated(repvars[v]) && SCIPvarIsActive(SCIPvarGetNegationVar(repvars[v]))));
6897 if( SCIPsortedvecFindPtr((void**)allvars, SCIPvarCompActiveAndNegated, repvars[v], nvars, &pos) )
6951 SCIP_CALL( getLinearConsVarsData(scip, consdata->lincons, consdata->linconstype, consvars, conscoefs, &nconsvars) );
6964 SCIP_CALL( getLinVarsAndAndRess(scip, cons, consvars, conscoefs, nconsvars, &linvar, &lincoef, &nlinvars, NULL, NULL, NULL) );
7003 SCIPdebugMessage("aggregating variables <%s> == 1 - <%s> in pseudoboolean <%s>\n", SCIPvarGetName(linvar), SCIPvarGetName(var), SCIPconsGetName(cons));
7005 SCIP_CALL( SCIPaggregateVars(scip, linvar, var, 1.0, 1.0, 1.0, &infeasible, &redundant, &aggregated) );
7008 SCIPdebugMessage("aggregation of variables: <%s> == 1 - <%s>, infeasible = %u, aggregated = %u\n", SCIPvarGetName(linvar), SCIPvarGetName(var), infeasible, aggregated);
7027 /* delete allvars[samepos] from all and-constraints which appear in this pseudoboolean constraint, and delete
7030 * it is the same like aggregating linvar with the resultant of the product, which is the same in all and-
7041 * @todo: implement more general step, that one combination of the variables in the and constraints is missing in
7042 * the pseudoboolean constraint, which leads to the same result, that the only linear variable is the
7063 SCIP_CALL( getLinearConsVarsData(scip, consdata->lincons, consdata->linconstype, consvars, conscoefs, &nconsvars) );
7076 SCIP_CALL( getLinVarsAndAndRess(scip, cons, consvars, conscoefs, nconsvars, &linvar, &lincoef, &nlinvars, NULL, NULL, NULL) );
7113 (void)SCIPsnprintf(name, SCIP_MAXSTRLEN, "andcons_%s_%s", SCIPconsGetName(cons), SCIPvarGetName(linvar));
7129 /* update the uses counter of consandata objects which are used in pseudoboolean constraint, which was deleted and
7192 SCIP_CALL( getLinearConsSides(scip, consdata->lincons, consdata->linconstype, &newlhs, &newrhs) );
7214 SCIP_CALL( getLinearConsVarsData(scip, consdata->lincons, consdata->linconstype, vars, coefs, &nvars) );
7217 /* calculate all not artificial linear variables and all artificial and-resultants which will be ordered like the
7218 * 'consanddatas' such that the and-resultant of the and-constraint is the and-resultant in the 'andress' array
7221 SCIP_CALL( getLinVarsAndAndRess(scip, cons, vars, coefs, nvars, linvars, lincoefs, &nlinvars, andress, andcoefs, &nandress) );
7237 assert(SCIPvarIsActive(res) || (SCIPvarIsNegated(res) && SCIPvarIsActive(SCIPvarGetNegationVar(res))));
7240 /* all and-resultants should be merged, so it is only allowed that each variable exists one time */
7282 /** destructor of constraint handler to free constraint handler data (called when SCIP is exiting) */
7352 SCIP_CALL( SCIPhashmapInsert(conshdlrdata->hashmap, (void*)resultant, (void*)(conshdlrdata->allconsanddatas[c])) );
7358 /** presolving initialization method of constraint handler (called when presolving is about to begin) */
7372 /* decompose all pseudo boolean constraints into a "linear" constraint and "and" constraints */
7401 SCIP_CALL( getLinearConsVarsData(scip, consdata->lincons, consdata->linconstype, vars, coefs, &nvars) );
7473 SCIP_CALL( SCIPcreateConsLinear(scip, &lincons, name, nvars, vars, coefs, lhs, SCIPinfinity(scip),
7489 /* second we are modelling the implication that if the slack variable is on( negation is off), the constraint
7496 SCIP_CALL( SCIPcreateConsLinear(scip, &lincons, name, nvars, vars, coefs, -SCIPinfinity(scip), lhs - 1,
7518 SCIP_CALL( SCIPcreateConsLinear(scip, &lincons, name, nvars, vars, coefs, -SCIPinfinity(scip), rhs,
7536 /* second we are modelling the implication that if the slack variable is on( negation is off), the constraint
7543 SCIP_CALL( SCIPcreateConsLinear(scip, &lincons, name, nvars, vars, coefs, rhs + 1, SCIPinfinity(scip),
7561 /* first we are modelling the implication that if the negation of the indicator variable is on, the constraint
7583 /* second we are modelling the implication that if the negation of the indicator variable is on, the constraint
7608 /* remove pseudo boolean and corresponding linear constraint, new linear constraints were created,
7632 /* remove pseudo boolean constraint, old linear constraint is still active, and-constraints too */
7675 assert((*consdata)->consanddatas[c]->noriguses == 0 || ((*consdata)->consanddatas[c]->origcons != NULL && SCIPconsIsOriginal((*consdata)->consanddatas[c]->origcons)));
7722 SCIP_CALL( consdataCreate(scip, conshdlr, &targetdata, sourcedata->lincons, sourcedata->linconstype,
7723 andconss, sourcedata->andcoefs, sourcedata->nconsanddatas, sourcedata->indvar, sourcedata->weight,
7724 sourcedata->issoftcons, sourcedata->intvar, sourcedata->lhs, sourcedata->rhs, SCIPconsIsChecked(sourcecons),
7732 SCIPconsIsInitial(sourcecons), SCIPconsIsSeparated(sourcecons), SCIPconsIsEnforced(sourcecons),
7735 SCIPconsIsDynamic(sourcecons), SCIPconsIsRemovable(sourcecons), SCIPconsIsStickingAtNode(sourcecons)) );
7919 SCIP_CALL( getLinearConsSides(scip, consdata->lincons, consdata->linconstype, &newlhs, &newrhs) );
7936 SCIP_CALL( getLinearConsVarsData(scip, consdata->lincons, consdata->linconstype, vars, coefs, &nvars) );
7939 /* calculate all not artificial linear variables and all artificial and-resultants which will be ordered like the
7940 * 'consanddatas' such that the and-resultant of the and-constraint is the and-resultant in the 'andress' array
7943 SCIP_CALL( getLinVarsAndAndRess(scip, cons, vars, coefs, nvars, linvars, lincoefs, &nlinvars, andress, andcoefs, &nandress) );
7946 SCIP_CALL( correctLocksAndCaptures(scip, cons, conshdlrdata, newlhs, newrhs, andress, andcoefs, nandress) );
7971 /* try upgrading pseudoboolean constraint to a linear constraint and/or remove possible and-constraints */
7972 SCIP_CALL( tryUpgrading(scip, cons, conshdlrdata, ndelconss, naddconss, nfixedvars, nchgcoefs, nchgsides, &cutoff) );
7981 /* remember the first constraint that was not yet tried to be upgraded, to begin the next upgrading round with */
8024 else if( *nfixedvars > oldnfixedvars || *naggrvars > oldnaggrvars || *nchgbds > oldnchgbds || *ndelconss > oldndelconss
8069 SCIPdebugMessage("%socking constraint <%s> by [%d;%d].\n", (nlocksneg < 0) || (nlockspos < 0) ? "Unl" : "L", SCIPconsGetName(cons), nlocksneg, nlockspos);
8118 /* probably we need to store the resultant too, now it's not possible to remove the resultant from the and-constraint */
8205 SCIP_CALL( copyConsPseudoboolean(scip, cons, sourcescip, sourcecons, consname, varmap, consmap,
8206 initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode, global,
8263 SCIP_CALL( getLinearConsNVars(scip, consdata->lincons, consdata->linconstype, &nlinconsvars) );
8287 SCIP_CALL( getLinearConsVarsData(scip, consdata->lincons, consdata->linconstype, linconsvars, NULL, &nlinconsvars) );
8289 /* calculate all non-artificial linear variables and all artificial and-resultants which will be ordered like the
8290 * 'consanddatas' such that the and-resultant of the and-constraint is the and-resultant in the 'andress' array
8293 SCIP_CALL( getLinVarsAndAndRess(scip, cons, linconsvars, NULL, nlinconsvars, linvars, NULL, &nlinvars, andress, NULL, &nandress) );
8380 /** constraint method of constraint handler which returns the number of variables (if possible) */
8425 SCIP_CALL( getLinearConsNVars(scip, consdata->lincons, consdata->linconstype, &nlinconsvars) );
8442 SCIP_CALL( getLinearConsVarsData(scip, consdata->lincons, consdata->linconstype, linconsvars, NULL, &nlinconsvars) );
8444 /* calculate all non-artificial linear variables and all artificial and-resultants which will be ordered like the
8445 * 'consanddatas' such that the and-resultant of the and-constraint is the and-resultant in the 'andress' array
8448 SCIP_CALL( getLinVarsAndAndRess(scip, cons, linconsvars, NULL, nlinconsvars, linvars, NULL, &nlinvars, andress, NULL, &nandress) );
8521 consEnfolpPseudoboolean, consEnfopsPseudoboolean, consCheckPseudoboolean, consLockPseudoboolean,
8526 SCIP_CALL( SCIPsetConshdlrCopy(scip, conshdlr, conshdlrCopyPseudoboolean, consCopyPseudoboolean) );
8533 SCIP_CALL( SCIPsetConshdlrPresol(scip, conshdlr, consPresolPseudoboolean, CONSHDLR_MAXPREROUNDS,
8541 "decompose all normal pseudo boolean constraint into a \"linear\" constraint \"and\" constraints",
8545 "decompose all indicator pseudo boolean constraint into a \"linear\" constraint \"and\" constraints",
8546 &conshdlrdata->decomposeindicatorpbcons, TRUE, DEFAULT_DECOMPOSEINDICATORPBCONS, NULL, NULL) );
8549 "constraints/"CONSHDLR_NAME"/nlcseparate", "should the nonlinear constraints be separated during LP processing?",
8552 "constraints/"CONSHDLR_NAME"/nlcpropagate", "should the nonlinear constraints be propagated during node processing?",
8567 SCIP_LINEARCONSTYPE linconstype, /**< linear constraint type of associated linear constraint */
8597 SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
8599 SCIP_Bool stickingatnode /**< should the constraint always be kept at the node where it was added, even
8660 /* if allocated memory in this for loop was already used, allocate a new block, otherwise we only need to copy the variables */
8725 SCIPwarningMessage(scip, "Another and-constraint with the same variables but different and-resultant is added to the global and-constraint hashtable of pseudoboolean constraint handler.\n");
8731 SCIP_CALL( SCIPensureBlockMemoryArray(scip, &(conshdlrdata->allconsanddatas), &(conshdlrdata->sallconsanddatas), SCIPcalcMemGrowSize(scip, conshdlrdata->sallconsanddatas + 1)) );
8803 /* todo: make the constraint upgrade flag global, now it works only for the common linear constraint */
8808 /* checking for and-constraints will be FALSE, we check all information in this constraint handler */
8809 SCIP_CALL( consdataCreate(scip, conshdlr, &consdata, lincons, linconstype, andconss, andcoefs, nandconss,
8814 SCIP_CALL( SCIPcreateCons(scip, cons, name, conshdlr, consdata, initial, separate, enforce, check, propagate,
8822 * @note linear and nonlinear terms can be added using SCIPaddCoefPseudoboolean() and SCIPaddTermPseudoboolean(),
8825 * @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
8864 SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
8866 SCIP_Bool stickingatnode /**< should the constraint always be kept at the node where it was added, even
8939 /* checking for original linear constraint will be FALSE, transformed linear constraints get the check flag like this
8942 SCIP_CALL( createAndAddLinearCons(scip, conshdlr, linvars, nlinvars, linvals, andress, nandconss, andcoefs, &lhs, &rhs,
8943 initial, separate, enforce, FALSE/*check*/, propagate, local, modifiable, dynamic, removable, stickingatnode,
8949 /* checking for and-constraints will be FALSE, we check all information in this constraint handler */
8950 SCIP_CALL( consdataCreate(scip, conshdlr, &consdata, lincons, linconstype, andconss, andcoefs, nandconss,
8960 SCIP_CALL( SCIPcreateCons(scip, cons, name, conshdlr, consdata, initial, separate, enforce, check, propagate,
8969 * @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
9003 * @todo if adding a coefficient would change the type of the special linear constraint, we need to erase it and
9080 * @todo if adding a coefficient would change the type of the special linear constraint, we need to erase it and
9179 /** gets number of linear variables without artificial terms variables of pseudoboolean constraint */
9261 SCIP_CALL( getLinearConsVarsData(scip, consdata->lincons, consdata->linconstype, vars, coefs, &nvars) );
9264 SCIP_CALL( getLinVarsAndAndRess(scip, cons, vars, coefs, nvars, linvars, lincoefs, nlinvars, NULL, NULL, NULL) );
9322 assert(consdata->consanddatas[c]->istransformed ? (consdata->consanddatas[c]->cons != NULL) : TRUE);
9323 assert(consdata->consanddatas[c]->isoriginal ? (consdata->consanddatas[c]->origcons != NULL) : TRUE);
9324 assert(consdata->consanddatas[c]->cons != NULL || consdata->consanddatas[c]->origcons != NULL);
9325 assert(isorig ? consdata->consanddatas[c]->origcons != NULL : consdata->consanddatas[c]->cons != NULL);
9327 andconss[c] = (isorig ? consdata->consanddatas[c]->origcons : consdata->consanddatas[c]->cons);
9371 * @note you can only change the left hand side if the special type of linear constraint won't changed
9373 * @todo if changing the left hand side would change the type of the special linear constraint, we need to erase it
9424 * @note you can only change the right hand side if the special type of linear constraint won't changed
|