/** separation method of constraint handler for LP solutions */ static SCIP_DECL_CONSSEPALP(consSepalpStp) { /*lint --e{715}*/ SCIP_CONSHDLRDATA* conshdlrdata; int maxcuts; int ncuts = 0; int i; *result = SCIP_DIDNOTRUN; conshdlrdata = SCIPconshdlrGetData(conshdlr); assert(conshdlrdata != NULL); maxcuts = SCIPnodeGetDepth(SCIPgetCurrentNode(scip)) == 0 ? conshdlrdata->maxsepacutsroot : conshdlrdata->maxsepacuts; for( i = 0; i < nconss; ++i ) { SCIP_CONSDATA* consdata; consdata = SCIPconsGetData(conss[i]); SCIP_CALL( sep_flow(scip, conshdlr, conshdlrdata, consdata, maxcuts, &ncuts) ); SCIP_CALL( sep_2cut(scip, conshdlr, conshdlrdata, consdata, maxcuts, &ncuts) ); } if( ncuts > 0 ) *result = SCIP_SEPARATED; return SCIP_OKAY; }
/** constraint activation notification method of constraint handler */ static SCIP_DECL_CONSACTIVE(consActiveSamediff) { /*lint --e{715}*/ SCIP_CONSDATA* consdata; assert(scip != NULL); assert(strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0); assert(cons != NULL); consdata = SCIPconsGetData(cons); assert(consdata != NULL); assert(consdata->npropagatedvars <= SCIPprobdataGetNVars(SCIPgetProbData(scip))); SCIPdebugMessage("activate constraint <%s> at node <%"SCIP_LONGINT_FORMAT"> in depth <%d>: ", SCIPconsGetName(cons), SCIPnodeGetNumber(consdata->node), SCIPnodeGetDepth(consdata->node)); SCIPdebug( consdataPrint(scip, consdata, NULL) ); if( consdata->npropagatedvars != SCIPprobdataGetNVars(SCIPgetProbData(scip)) ) { SCIPdebugMessage("-> mark constraint to be repropagated\n"); consdata->propagated = FALSE; SCIP_CALL( SCIPrepropagateNode(scip, consdata->node) ); } return SCIP_OKAY; }
/** constraint display method of constraint handler */ static SCIP_DECL_CONSPRINT(consPrintConjunction) { /*lint --e{715}*/ SCIP_CONSDATA* consdata; int i; assert( scip != NULL ); assert( conshdlr != NULL ); assert( cons != NULL ); consdata = SCIPconsGetData(cons); assert(consdata != NULL); SCIPinfoMessage(scip, file, "conjunction("); for( i = 0; i < consdata->nconss; ++i ) { if( i > 0 ) SCIPinfoMessage(scip, file, ", "); SCIP_CALL( SCIPprintCons(scip, consdata->conss[i], file) ); } SCIPinfoMessage(scip, file, ")"); return SCIP_OKAY; }
/** constraint deactivation notification method of constraint handler */ static SCIP_DECL_CONSDEACTIVE(consDeactiveOrigbranch) { /*lint --e{715}*/ SCIP_CONSHDLRDATA* conshdlrData; assert(scip != NULL); assert(conshdlr != NULL); assert(strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0); assert(cons != NULL); conshdlrData = SCIPconshdlrGetData(conshdlr); assert(conshdlrData != NULL); assert(conshdlrData->stack != NULL || conshdlrData->nstack <= 1); assert(conshdlrData->nstack <= 1 || cons == conshdlrData->stack[conshdlrData->nstack-1]); assert(SCIPconsGetData(cons) != NULL); SCIPdebugMessage("Deactivating branch orig constraint: <%s> [stack size: %d].\n", SCIPconsGetName(cons), conshdlrData->nstack-1); /* remove constraint from the stack */ if( conshdlrData->nstack > 0 ) --(conshdlrData->nstack); return SCIP_OKAY; }
/** adds constraint to the disjunction of constraints */ SCIP_RETCODE SCIPaddConsElemDisjunction( SCIP* scip, /**< SCIP data structure */ SCIP_CONS* cons, /**< disjunction constraint */ SCIP_CONS* addcons /**< additional constraint in disjunction */ ) { SCIP_CONSDATA* consdata; assert(cons != NULL); assert(addcons != NULL); if( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(cons)), CONSHDLR_NAME) != 0 ) { SCIPerrorMessage("constraint is not a disjunction constraint\n"); return SCIP_INVALIDDATA; } consdata = SCIPconsGetData(cons); assert(consdata != NULL); SCIP_CALL( consdataAddCons(scip, consdata, addcons) ); return SCIP_OKAY; }
/** constraint deactivation notification method of constraint handler */ static SCIP_DECL_CONSDEACTIVE(consDeactiveSamediff) { /*lint --e{715}*/ SCIP_CONSDATA* consdata; SCIP_PROBDATA* probdata; assert(scip != NULL); assert(strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0); assert(cons != NULL); consdata = SCIPconsGetData(cons); assert(consdata != NULL); assert(consdata->propagated || SCIPgetNChildren(scip) == 0); probdata = SCIPgetProbData(scip); assert(probdata != NULL); /* check if all variables which are not fixed locally to zero are valid for this constraint/node */ assert( consdataCheck(scip, probdata, consdata) ); SCIPdebugMessage("deactivate constraint <%s> at node <%"SCIP_LONGINT_FORMAT"> in depth <%d>: ", SCIPconsGetName(cons), SCIPnodeGetNumber(consdata->node), SCIPnodeGetDepth(consdata->node)); SCIPdebug( consdataPrint(scip, consdata, NULL) ); /* set the number of propagated variables to current number of variables is SCIP */ consdata->npropagatedvars = SCIPprobdataGetNVars(probdata); /* check if all variables are valid for this constraint */ assert( consdataCheck(scip, probdata, consdata) ); return SCIP_OKAY; }
/** transforms constraint data into data belonging to the transformed problem */ static SCIP_DECL_CONSTRANS(consTransSamediff) { /*lint --e{715}*/ SCIP_CONSDATA* sourcedata; SCIP_CONSDATA* targetdata; assert(conshdlr != NULL); assert(strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0); assert(SCIPgetStage(scip) == SCIP_STAGE_TRANSFORMING); assert(sourcecons != NULL); assert(targetcons != NULL); sourcedata = SCIPconsGetData(sourcecons); assert(sourcedata != NULL); /* create constraint data for target constraint */ SCIP_CALL( consdataCreate(scip, &targetdata, sourcedata->itemid1, sourcedata->itemid2, sourcedata->type, sourcedata->node) ); /* create target constraint */ SCIP_CALL( SCIPcreateCons(scip, targetcons, SCIPconsGetName(sourcecons), conshdlr, targetdata, SCIPconsIsInitial(sourcecons), SCIPconsIsSeparated(sourcecons), SCIPconsIsEnforced(sourcecons), SCIPconsIsChecked(sourcecons), SCIPconsIsPropagated(sourcecons), SCIPconsIsLocal(sourcecons), SCIPconsIsModifiable(sourcecons), SCIPconsIsDynamic(sourcecons), SCIPconsIsRemovable(sourcecons), SCIPconsIsStickingAtNode(sourcecons)) ); return SCIP_OKAY; }
/** returns the array of bound changes on original variables found by propagation in the original problem * at the node corresponding to the given origbranch constraint */ SCIP_RETCODE GCGconsOrigbranchGetPropBoundChgs( SCIP* scip, /**< SCIP data structure */ SCIP_CONS* cons, /**< origbranch constraint for which the bound changes are requested */ SCIP_VAR*** vars, /**< pointer to store array of variables corresponding to the bound changes */ SCIP_BOUNDTYPE** boundtypes, /**< pointer to store array of the types of the bound changes */ SCIP_Real** newbounds, /**< pointer to store array of the new bounds */ int* npropbounds /**< pointer to store the number of bound changes stored at the constraint */ ) { SCIP_CONSDATA* consdata; assert(scip != NULL); assert(cons != NULL); consdata = SCIPconsGetData(cons); assert(consdata != NULL); *vars = consdata->propvars; *boundtypes = consdata->propboundtypes; *newbounds = consdata->propbounds; *npropbounds = consdata->npropbounds; consdata->npropbounds = 0; return SCIP_OKAY; }
/** returns the branching data for a given origbranch constraint */ GCG_BRANCHDATA* GCGconsOrigbranchGetBranchdata( SCIP_CONS* cons /**< origbranch constraint for which the branching data is requested */ ) { SCIP_CONSDATA* consdata; consdata = SCIPconsGetData(cons); assert(consdata != NULL); return consdata->branchdata; }
/** returns the node in the B&B tree at which the given origbranch constraint is sticking */ SCIP_NODE* GCGconsOrigbranchGetNode( SCIP_CONS* cons /**< origbranch constraint for which the corresponding node is requested */ ) { SCIP_CONSDATA* consdata; assert(cons != NULL); consdata = SCIPconsGetData(cons); assert(consdata != NULL); return consdata->node; }
/** presolving method of constraint handler */ static SCIP_DECL_CONSPRESOL(consPresolConjunction) { /*lint --e{715}*/ SCIP_CONSDATA* consdata; int c; int i; assert(result != NULL); *result = SCIP_DIDNOTFIND; /* all constraints in a conjunction constraint of the global problem can be added directly to the problem and * removed from the conjunction constraint; * an unmodifiable conjunction constraint can be deleted */ for( c = 0; c < nconss; ++c ) { consdata = SCIPconsGetData(conss[c]); assert(consdata != NULL); /* add all inactive constraints to the global problem */ for( i = 0; i < consdata->nconss; ++i ) { /* update check flag for sub constraints when upgrade takes place */ if( SCIPconsIsChecked(conss[c]) ) { /* make sure, the constraint is checked for feasibility */ SCIP_CALL( SCIPsetConsChecked(scip, consdata->conss[i], TRUE) ); } /* add constraint, if it is not active yet */ if( !SCIPconsIsActive(consdata->conss[i]) ) { SCIPdebugMessage("adding constraint <%s> from add conjunction <%s>\n", SCIPconsGetName(consdata->conss[i]), SCIPconsGetName(conss[c])); SCIP_CALL( SCIPaddCons(scip, consdata->conss[i]) ); *result = SCIP_SUCCESS; } /* release constraint because it will be removed from the conjunction constraint */ SCIP_CALL( SCIPreleaseCons(scip, &(consdata->conss[i])) ); } /* all constraints where removed, so we need to clear the array */ consdata->nconss = 0; /* delete conjunction constraint, if it is unmodifiable */ if( !SCIPconsIsModifiable(conss[c]) ) { SCIP_CALL( SCIPdelCons(scip, conss[c]) ); } } return SCIP_OKAY; }
/** constraint display method of constraint handler */ static SCIP_DECL_CONSPRINT(consPrintSamediff) { /*lint --e{715}*/ SCIP_CONSDATA* consdata; consdata = SCIPconsGetData(cons); assert(consdata != NULL); consdataPrint(scip, consdata, file); return SCIP_OKAY; }
/** returns the branchrule for a given origbranch constraint */ SCIP_BRANCHRULE* GCGconsOrigbranchGetBranchrule( SCIP_CONS* cons /**< origbranch constraint for which the branchrule is requested */ ) { SCIP_CONSDATA* consdata; assert(cons != NULL); consdata = SCIPconsGetData(cons); assert(consdata != NULL); return consdata->branchrule; }
/** returns the origbranch constraint of the second child of the node at which the given origbranch constraint is sticking */ SCIP_CONS* GCGconsOrigbranchGetChild2cons( SCIP_CONS* cons /**< origbranch constraint for which the origbranch constraint of * the second child node is requested */ ) { SCIP_CONSDATA* consdata; assert(cons != NULL); consdata = SCIPconsGetData(cons); assert(consdata != NULL); return consdata->child2cons; }
/** returns the origbranch constraint of the B&B father of the node at which the given origbranch constraint is sticking */ SCIP_CONS* GCGconsOrigbranchGetParentcons( SCIP_CONS* cons /**< origbranch constraint for which the origbranch constraint of * the father node is requested */ ) { SCIP_CONSDATA* consdata; assert(cons != NULL); consdata = SCIPconsGetData(cons); assert(consdata != NULL); return consdata->parentcons; }
/** branches on disjunctive constraint */ static SCIP_RETCODE branchCons( SCIP* scip, /**< SCIP data structure */ SCIP_CONS* cons, /**< active disjunction constraint */ SCIP_RESULT* result /**< pointer to store the result */ ) { SCIP_CONSDATA* consdata; SCIP_CONS** conss; SCIP_NODE* child; SCIP_Real estimate; int nconss; int i; assert(result != NULL); /* cannot branch on modifiable constraint */ if( SCIPconsIsModifiable(cons) ) return SCIP_OKAY; consdata = SCIPconsGetData(cons); assert(consdata != NULL); conss = consdata->conss; assert(conss != NULL); nconss = consdata->nconss; assert(nconss > 0); estimate = SCIPgetLocalTransEstimate(scip); /* add all inactive constraints to local subproblem */ for( i = 0; i < nconss; ++i ) { /* create the branch-and-bound tree child nodes of the current node */ SCIP_CALL( SCIPcreateChild(scip, &child, 0.0, estimate) ); /* add constraints to nodes */ SCIP_CALL( SCIPaddConsNode(scip, child, conss[i], NULL) ); /* remove disjunction constraint, from child node */ SCIP_CALL( SCIPdelConsNode(scip, child, cons) ); } /* reset constraint age */ SCIP_CALL( SCIPresetConsAge(scip, cons) ); *result = SCIP_BRANCHED; return SCIP_OKAY; }
/** returns the masterbranch constraint of the node in the master program corresponding to the node at which the given origbranchbranch constraint is sticking */ SCIP_CONS* GCGconsOrigbranchGetMastercons( SCIP_CONS* cons /**< origbranch constraint for which the corresponding masterbranch * constraint is requested */ ) { SCIP_CONSDATA* consdata; assert(cons != NULL); consdata = SCIPconsGetData(cons); assert(consdata != NULL); assert(consdata->mastercons != NULL); return consdata->mastercons; }
/** return constraint type SAME or DIFFER */ CONSTYPE SCIPgetTypeSamediff( SCIP* scip, /**< SCIP data structure */ SCIP_CONS* cons /**< samediff constraint */ ) { SCIP_CONSDATA* consdata; assert(cons != NULL); consdata = SCIPconsGetData(cons); assert(consdata != NULL); return consdata->type; }
/** returns item id two */ int SCIPgetItemid2Samediff( SCIP* scip, /**< SCIP data structure */ SCIP_CONS* cons /**< samediff constraint */ ) { SCIP_CONSDATA* consdata; assert(cons != NULL); consdata = SCIPconsGetData(cons); assert(consdata != NULL); return consdata->itemid2; }
/** constraint activation notification method of constraint handler */ static SCIP_DECL_CONSACTIVE(consActiveOrigbranch) { /*lint --e{715}*/ SCIP_CONSHDLRDATA* conshdlrData; assert(scip != NULL); assert(conshdlr != NULL); assert(strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0); assert(cons != NULL); conshdlrData = SCIPconshdlrGetData(conshdlr); assert(conshdlrData != NULL); assert(conshdlrData->stack != NULL); assert(SCIPconsGetData(cons) != NULL); if( SCIPconsGetData(cons)->node == NULL ) SCIPconsGetData(cons)->node = SCIPgetRootNode(scip); SCIPdebugMessage("Activating branch orig constraint: <%s>[stack size: %d].\n", SCIPconsGetName(cons), conshdlrData->nstack+1); /* put constraint on the stack */ if( conshdlrData->nstack >= conshdlrData->maxstacksize ) { SCIP_CALL( SCIPreallocMemoryArray(scip, &(conshdlrData->stack), 2*(conshdlrData->maxstacksize)) ); conshdlrData->maxstacksize = 2*(conshdlrData->maxstacksize); SCIPdebugMessage("reallocating Memory for stack! %d --> %d\n", conshdlrData->maxstacksize/2, conshdlrData->maxstacksize); } /* put constraint on the stack */ assert(conshdlrData->stack != NULL); conshdlrData->stack[conshdlrData->nstack] = cons; ++(conshdlrData->nstack); return SCIP_OKAY; }
/** returns the number of bound changes on original variables found by propagation in the original problem * at the node corresponding to the given origbranch constraint */ int GCGconsOrigbranchGetNPropBoundChgs( SCIP* scip, /**< SCIP data structure */ SCIP_CONS* cons /**< origbranch constraint for which the bound changes are requested */ ) { SCIP_CONSDATA* consdata; assert(scip != NULL); assert(cons != NULL); consdata = SCIPconsGetData(cons); assert(consdata != NULL); return consdata->npropbounds; }
/** sets the masterbranch constraint of the node in the master program corresponding to the node at which the given origbranchbranch constraint is sticking */ void GCGconsOrigbranchSetMastercons( SCIP_CONS* cons, /**< origbranch constraint for which the masterbranch constraint should be set */ SCIP_CONS* mastercons /**< masterbranch constraint corresponding to the given origbranch constraint */ ) { SCIP_CONSDATA* consdata; assert(cons != NULL); consdata = SCIPconsGetData(cons); assert(consdata != NULL); // if( consdata->mastercons != mastercons ) // assert(consdata->mastercons == NULL || mastercons == NULL); consdata->mastercons = mastercons; }
/** adds all constraints in conjunction constraints to the problem; disables unmodifiable conjunction constraints */ static SCIP_RETCODE addAllConss( SCIP* scip, /**< SCIP data structure */ SCIP_CONS** conss, /**< active conjunction constraints */ int nconss, /**< number of active conjunction constraints */ SCIP_RESULT* result /**< pointer to store the result */ ) { SCIP_CONSDATA* consdata; int c; int i; assert(result != NULL); for( c = 0; c < nconss; ++c ) { consdata = SCIPconsGetData(conss[c]); assert(consdata != NULL); /* add all inactive constraints to local subproblem */ for( i = 0; i < consdata->nconss; ++i ) { /* update check flag for sub constraints when upgrade takes place */ if( SCIPconsIsChecked(conss[c]) ) { /* make sure, the constraint is checked for feasibility */ SCIP_CALL( SCIPsetConsChecked(scip, consdata->conss[i], TRUE) ); } if( !SCIPconsIsActive(consdata->conss[i]) ) { SCIPdebugMessage("adding constraint <%s> from add conjunction <%s>\n", SCIPconsGetName(consdata->conss[i]), SCIPconsGetName(conss[c])); SCIP_CALL( SCIPaddConsLocal(scip, consdata->conss[i], NULL) ); *result = SCIP_CONSADDED; } } /* disable conjunction constraint, if it is unmodifiable */ if( !SCIPconsIsModifiable(conss[c]) ) { SCIP_CALL( SCIPdelConsLocal(scip, conss[c]) ); } } return SCIP_OKAY; }
/** constraint copying method of constraint handler */ static SCIP_DECL_CONSCOPY(consCopyConjuction) { /*lint --e{715}*/ SCIP_CONSDATA* sourcedata; SCIP_CONS** sourceconss; SCIP_CONS** conss; int nconss; int c; sourcedata = SCIPconsGetData(sourcecons); assert(sourcedata != NULL); nconss = sourcedata->nconss; if( nconss == 0 && !SCIPconsIsModifiable(sourcecons) ) { *valid = TRUE; return SCIP_OKAY; } SCIP_CALL( SCIPallocBufferArray(scip, &conss, nconss) ); sourceconss = sourcedata->conss; /* copy each constraint one by one */ for( c = 0; c < nconss && (*valid); ++c ) { SCIP_CALL( SCIPgetConsCopy(sourcescip, scip, sourceconss[c], &conss[c], sourceconshdlr, varmap, consmap, SCIPconsGetName(sourceconss[c]), SCIPconsIsInitial(sourceconss[c]), SCIPconsIsSeparated(sourceconss[c]), SCIPconsIsEnforced(sourceconss[c]), SCIPconsIsChecked(sourceconss[c]), SCIPconsIsPropagated(sourceconss[c]), SCIPconsIsLocal(sourceconss[c]), SCIPconsIsModifiable(sourceconss[c]), SCIPconsIsDynamic(sourceconss[c]), SCIPconsIsRemovable(sourceconss[c]), SCIPconsIsStickingAtNode(sourceconss[c]), global, valid) ); assert(!(*valid) || conss[c] != NULL); } if( *valid ) { SCIP_CALL( SCIPcreateConsDisjunction(scip, cons, name, nconss, conss, initial, enforce, check, local, modifiable, dynamic) ); } SCIPfreeBufferArray(scip, &conss); return SCIP_OKAY; }
/** variable rounding lock method of constraint handler */ static SCIP_DECL_CONSLOCK(consLockConjunction) { /*lint --e{715}*/ SCIP_CONSDATA* consdata; int c; consdata = SCIPconsGetData(cons); assert(consdata != NULL); /* lock sub constraints */ for( c = 0; c < consdata->nconss; ++c ) { SCIP_CALL( SCIPaddConsLocks(scip, consdata->conss[c], nlockspos, nlocksneg) ); } return SCIP_OKAY; }
/** presolving method of constraint handler */ static SCIP_DECL_CONSPRESOL(consPresolDisjunction) { /*lint --e{715}*/ SCIP_CONSDATA* consdata; int oldndelconss; int c; assert(result != NULL); *result = SCIP_DIDNOTFIND; oldndelconss = *ndelconss; /* all disjunction constraints with one constraint can be replaced with that corresponding constraint */ for( c = 0; c < nconss; ++c ) { consdata = SCIPconsGetData(conss[c]); assert(consdata != NULL); if( !SCIPconsIsModifiable(conss[c]) && consdata->nconss == 1 ) { /* add constraint to the problem */ if( !SCIPconsIsActive(consdata->conss[0]) ) { SCIP_CALL( SCIPaddCons(scip, consdata->conss[0]) ); /* release constraint from the disjunction constraint */ SCIP_CALL( SCIPreleaseCons(scip, &consdata->conss[0]) ); } /* remove disjunction constraint */ SCIP_CALL( SCIPdelCons(scip, conss[0]) ); *result = SCIP_SUCCESS; } /* propagate constraint */ SCIP_CALL( propagateCons(scip, conss[c], ndelconss) ); } if( *ndelconss > oldndelconss ) *result = SCIP_SUCCESS; return SCIP_OKAY; }
/** checks the consistency of the origbranch constraints in the problem */ void GCGconsOrigbranchCheckConsistency( SCIP* scip /**< SCIP data structure */ ) { #ifdef CHECKCONSISTENCY SCIP_CONSHDLR* conshdlr; #ifndef NDEBUG SCIP_CONS** conss; int nconss; int i; SCIP_CONSDATA* consdata; #endif assert(scip != NULL); conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME); if( conshdlr == NULL ) { SCIPerrorMessage("origbranch constraint handler not found\n"); return; } #ifndef NDEBUG conss = SCIPconshdlrGetConss(conshdlr); nconss = SCIPconshdlrGetNConss(conshdlr); for( i = 0; i < nconss; i++ ) { consdata = SCIPconsGetData(conss[i]); assert(consdata != NULL); assert(consdata->node != NULL); assert((consdata->parentcons == NULL) == (SCIPnodeGetDepth(consdata->node) == 0)); assert(consdata->parentcons == NULL || SCIPconsGetData(consdata->parentcons)->child1cons == conss[i] || SCIPconsGetData(consdata->parentcons)->child2cons == conss[i] || ( SCIPinProbing(scip) && SCIPconsGetData(consdata->parentcons)->probingtmpcons == conss[i])); assert(consdata->child1cons == NULL || SCIPconsGetData(consdata->child1cons)->parentcons == conss[i]); assert(consdata->child2cons == NULL || SCIPconsGetData(consdata->child2cons)->parentcons == conss[i]); assert(consdata->probingtmpcons == NULL || SCIPinProbing(scip)); assert(consdata->probingtmpcons == NULL || SCIPconsGetData(consdata->probingtmpcons)->parentcons == conss[i]); assert(consdata->mastercons == NULL || GCGconsMasterbranchGetOrigcons(consdata->mastercons) == conss[i]); } #endif #endif }
/** adds a bound change on an original variable found by propagation in the original problem * to the given origbranch constraint so that it will be transferred to the master problem */ SCIP_RETCODE GCGconsOrigbranchAddPropBoundChg( SCIP* scip, /**< SCIP data structure */ SCIP_CONS* cons, /**< origbranch constraint to which the bound change is added */ SCIP_VAR* var, /**< variable on which the bound change was performed */ SCIP_BOUNDTYPE boundtype, /**< bound type of the bound change */ SCIP_Real newbound /**< new bound of the variable after the bound change */ ) { SCIP_CONSDATA* consdata; assert(scip != NULL); assert(cons != NULL); assert(var != NULL); consdata = SCIPconsGetData(cons); assert(consdata != NULL); /* realloc the arrays, if needed */ if( consdata->npropbounds >= consdata->maxpropbounds ) { consdata->maxpropbounds = consdata->npropbounds+5; SCIP_CALL( SCIPreallocMemoryArray(scip, &(consdata->propvars), consdata->maxpropbounds) ); SCIP_CALL( SCIPreallocMemoryArray(scip, &(consdata->propboundtypes), consdata->maxpropbounds) ); SCIP_CALL( SCIPreallocMemoryArray(scip, &(consdata->propbounds), consdata->maxpropbounds) ); } SCIPdebugMessage("Bound change stored at branch orig constraint: <%s>.\n", SCIPconsGetName(cons)); /* store the new bound change */ consdata->propvars[consdata->npropbounds] = var; consdata->propboundtypes[consdata->npropbounds] = boundtype; consdata->propbounds[consdata->npropbounds] = newbound; consdata->npropbounds++; /* mark the corresponding master node to be repropagated */ if( consdata->mastercons != NULL ) { SCIP_CALL( SCIPrepropagateNode(GCGrelaxGetMasterprob(scip), GCGconsMasterbranchGetNode(consdata->mastercons)) ); } return SCIP_OKAY; }
/** transforms constraint data into data belonging to the transformed problem */ static SCIP_DECL_CONSTRANS(consTransDisjunction) { /*lint --e{715}*/ SCIP_CONSDATA* sourcedata; SCIP_CONSDATA* targetdata; /* get constraint data of source constraint */ sourcedata = SCIPconsGetData(sourcecons); assert(sourcedata != NULL); SCIP_CALL( consdataCreate(scip, &targetdata, sourcedata->conss, sourcedata->nconss) ); /* create target constraint */ SCIP_CALL( SCIPcreateCons(scip, targetcons, SCIPconsGetName(sourcecons), conshdlr, targetdata, SCIPconsIsInitial(sourcecons), SCIPconsIsSeparated(sourcecons), SCIPconsIsEnforced(sourcecons), SCIPconsIsChecked(sourcecons), SCIPconsIsPropagated(sourcecons), SCIPconsIsLocal(sourcecons), SCIPconsIsModifiable(sourcecons), SCIPconsIsDynamic(sourcecons), SCIPconsIsRemovable(sourcecons), SCIPconsIsStickingAtNode(sourcecons)) ); return SCIP_OKAY; }
/** transforms constraint data into data belonging to the transformed problem */ static SCIP_DECL_CONSTRANS(consTransConjunction) { /*lint --e{715}*/ SCIP_CONSDATA* sourcedata; SCIP_CONSDATA* targetdata; int c; /* create constraint data for target constraint */ SCIP_CALL( SCIPallocBlockMemory(scip, &targetdata) ); /* get constraint data of source constraint */ sourcedata = SCIPconsGetData(sourcecons); if( sourcedata->nconss > 0 ) { targetdata->consssize = sourcedata->nconss; targetdata->nconss = sourcedata->nconss; SCIP_CALL( SCIPallocBlockMemoryArray(scip, &targetdata->conss, targetdata->consssize) ); for( c = 0; c < sourcedata->nconss; ++c ) { SCIP_CALL( SCIPtransformCons(scip, sourcedata->conss[c], &targetdata->conss[c]) ); } } else { targetdata->conss = NULL; targetdata->consssize = 0; targetdata->nconss = 0; } /* create target constraint */ SCIP_CALL( SCIPcreateCons(scip, targetcons, SCIPconsGetName(sourcecons), conshdlr, targetdata, SCIPconsIsInitial(sourcecons), SCIPconsIsSeparated(sourcecons), SCIPconsIsEnforced(sourcecons), SCIPconsIsChecked(sourcecons), SCIPconsIsPropagated(sourcecons), SCIPconsIsLocal(sourcecons), SCIPconsIsModifiable(sourcecons), SCIPconsIsDynamic(sourcecons), SCIPconsIsRemovable(sourcecons), SCIPconsIsStickingAtNode(sourcecons)) ); return SCIP_OKAY; }