40 #define CONSHDLR_NAME "samediff" 41 #define CONSHDLR_DESC "stores the local branching decisions" 42 #define CONSHDLR_ENFOPRIORITY 0 43 #define CONSHDLR_CHECKPRIORITY 9999999 44 #define CONSHDLR_PROPFREQ 1 45 #define CONSHDLR_EAGERFREQ 1 47 #define CONSHDLR_DELAYPROP FALSE 48 #define CONSHDLR_NEEDSCONS TRUE 50 #define CONSHDLR_PROP_TIMING SCIP_PROPTIMING_BEFORELP 68 unsigned int propagated:1;
88 assert( scip !=
NULL );
89 assert( consdata !=
NULL );
90 assert( itemid1 >= 0 );
91 assert( itemid2 >= 0 );
96 (*consdata)->itemid1 = itemid1;
97 (*consdata)->itemid2 = itemid2;
98 (*consdata)->type = type;
99 (*consdata)->npropagatedvars = 0;
100 (*consdata)->npropagations = 0;
101 (*consdata)->propagated =
FALSE;
102 (*consdata)->node = node;
119 assert(probdata !=
NULL);
125 consdata->type ==
SAME ?
"same" :
"diff",
126 ids[consdata->itemid1], ids[consdata->itemid2],
SCIPnodeGetNumber(consdata->node) );
152 assert(scip !=
NULL);
153 assert(consdata !=
NULL);
155 assert(nfixedvars !=
NULL);
156 assert(cutoff !=
NULL);
170 type = consdata->type;
172 if( (type ==
SAME && existid1 != existid2) || (type ==
DIFFER && existid1 && existid2) )
209 SCIPdebugMsg(scip,
"check variables %d to %d\n", consdata->npropagatedvars, nvars);
211 for( v = consdata->npropagatedvars; v < nvars && !cutoff; ++v )
216 SCIPdebugMsg(scip,
"fixed %d variables locally\n", nfixedvars);
220 else if( nfixedvars > 0 )
256 for( v = 0; v < nvars; ++v )
272 type = consdata->type;
274 if( (type ==
SAME && existid1 != existid2) || (type ==
DIFFER && existid1 && existid2) )
295 assert(consdata !=
NULL);
296 assert(*consdata !=
NULL);
315 assert(conshdlr !=
NULL);
317 assert(consdata !=
NULL);
318 assert(*consdata !=
NULL);
333 assert(conshdlr !=
NULL);
336 assert(sourcecons !=
NULL);
337 assert(targetcons !=
NULL);
340 assert(sourcedata !=
NULL);
344 sourcedata->itemid1, sourcedata->itemid2, sourcedata->type, sourcedata->node) );
357 #define consEnfolpSamediff NULL 360 #define consEnfopsSamediff NULL 363 #define consCheckSamediff NULL 376 assert(scip !=
NULL);
378 assert(result !=
NULL);
383 assert(probdata !=
NULL);
390 for( c = 0; c < nconss; ++c )
400 for( i = c+1; i < nconss; ++i )
403 assert( !(consdata->itemid1 == consdata2->itemid1
404 && consdata->itemid2 == consdata2->itemid2
405 && consdata->type == consdata2->type) );
406 assert( !(consdata->itemid1 == consdata2->itemid2
407 && consdata->itemid2 == consdata2->itemid1
408 && consdata->type == consdata2->type) );
413 if( !consdata->propagated )
419 consdata->npropagations++;
423 consdata->propagated =
TRUE;
424 consdata->npropagatedvars = nvars;
438 #define consLockSamediff NULL 447 assert(scip !=
NULL);
449 assert(cons !=
NULL);
452 assert(probdata !=
NULL);
455 assert(consdata !=
NULL);
458 SCIPdebugMsg(scip,
"activate constraint <%s> at node <%"SCIP_LONGINT_FORMAT
"> in depth <%d>: ",
464 SCIPdebugMsg(scip,
"-> mark constraint to be repropagated\n");
465 consdata->propagated =
FALSE;
482 assert(scip !=
NULL);
484 assert(cons !=
NULL);
487 assert(consdata !=
NULL);
491 assert(probdata !=
NULL);
493 SCIPdebugMsg(scip,
"deactivate constraint <%s> at node <%"SCIP_LONGINT_FORMAT
"> in depth <%d>: ",
510 assert(consdata !=
NULL);
537 assert(conshdlr !=
NULL);
567 if( conshdlr ==
NULL )
577 SCIP_CALL(
SCIPcreateCons(scip, cons, name, conshdlr, consdata,
FALSE,
FALSE,
FALSE,
FALSE,
TRUE,
594 assert(cons !=
NULL);
597 assert(consdata !=
NULL);
599 return consdata->itemid1;
610 assert(cons !=
NULL);
613 assert(consdata !=
NULL);
615 return consdata->itemid2;
626 assert(cons !=
NULL);
629 assert(consdata !=
NULL);
631 return consdata->type;
enum SCIP_Result SCIP_RESULT
SCIP_RETCODE SCIPsetConshdlrDelete(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSDELETE((*consdelete)))
static SCIP_DECL_CONSDELETE(consDeleteSamediff)
SCIP_STAGE SCIPgetStage(SCIP *scip)
void SCIPvardataPrint(SCIP *scip, SCIP_VARDATA *vardata, FILE *file)
SCIP_Bool SCIPconsIsDynamic(SCIP_CONS *cons)
SCIP_RETCODE SCIPsetConshdlrTrans(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSTRANS((*constrans)))
SCIP_CONSHDLR * SCIPfindConshdlr(SCIP *scip, const char *name)
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
static SCIP_DECL_CONSDEACTIVE(consDeactiveSamediff)
SCIP_RETCODE SCIPsetConshdlrDeactive(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSDEACTIVE((*consdeactive)))
static SCIP_RETCODE checkVariable(SCIP *scip, SCIP_CONSDATA *consdata, SCIP_VAR *var, int *nfixedvars, SCIP_Bool *cutoff)
Constraint handler stores the local branching decision data.
SCIP_RETCODE SCIPcreateConsSamediff(SCIP *scip, SCIP_CONS **cons, const char *name, int itemid1, int itemid2, CONSTYPE type, SCIP_NODE *node, SCIP_Bool local)
#define consEnfolpSamediff
struct SCIP_VarData SCIP_VARDATA
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)
enum SCIP_Retcode SCIP_RETCODE
static void consdataPrint(SCIP *scip, SCIP_CONSDATA *consdata, FILE *file)
SCIP_Bool SCIPconsIsStickingAtNode(SCIP_CONS *cons)
Variable data containing the ids of constraints in which the variable appears.
#define SCIPfreeBlockMemory(scip, ptr)
int SCIPnodeGetDepth(SCIP_NODE *node)
int * SCIPvardataGetConsids(SCIP_VARDATA *vardata)
#define SCIPallocBlockMemory(scip, ptr)
SCIP_Bool SCIPconsIsRemovable(SCIP_CONS *cons)
SCIP_VAR ** SCIPprobdataGetVars(SCIP_PROBDATA *probdata)
void SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...)
SCIP_RETCODE SCIPcreateCons(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_CONSHDLR *conshdlr, SCIP_CONSDATA *consdata, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
SCIP_RETCODE SCIPrepropagateNode(SCIP *scip, SCIP_NODE *node)
#define CONSHDLR_DELAYPROP
SCIP_Longint SCIPnodeGetNumber(SCIP_NODE *node)
#define CONSHDLR_PROP_TIMING
#define CONSHDLR_ENFOPRIORITY
#define CONSHDLR_NEEDSCONS
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
int SCIPgetItemid2Samediff(SCIP *scip, SCIP_CONS *cons)
const char * SCIPconsGetName(SCIP_CONS *cons)
int SCIPgetNChildren(SCIP *scip)
SCIP_Bool SCIPconsIsPropagated(SCIP_CONS *cons)
#define consEnfopsSamediff
SCIP_Bool SCIPconsIsLocal(SCIP_CONS *cons)
struct SCIP_ConsData SCIP_CONSDATA
SCIP_Bool SCIPsortedvecFindInt(int *intarray, int val, int len, int *pos)
int * SCIPprobdataGetIds(SCIP_PROBDATA *probdata)
#define CONSHDLR_EAGERFREQ
static SCIP_RETCODE consdataCreate(SCIP *scip, SCIP_CONSDATA **consdata, int itemid1, int itemid2, CONSTYPE type, SCIP_NODE *node)
SCIP_RETCODE SCIPincludeConshdlrSamediff(SCIP *scip)
Problem data for binpacking problem.
CONSTYPE SCIPgetTypeSamediff(SCIP *scip, SCIP_CONS *cons)
static SCIP_Bool consdataCheck(SCIP *scip, SCIP_PROBDATA *probdata, SCIP_CONSDATA *consdata, SCIP_Bool beforeprop)
SCIP_VARDATA * SCIPvarGetData(SCIP_VAR *var)
SCIP_Bool SCIPconsIsChecked(SCIP_CONS *cons)
SCIP_Bool SCIPconsIsInitial(SCIP_CONS *cons)
int SCIPprobdataGetNVars(SCIP_PROBDATA *probdata)
SCIP_RETCODE SCIPfixVar(SCIP *scip, SCIP_VAR *var, SCIP_Real fixedval, SCIP_Bool *infeasible, SCIP_Bool *fixed)
static SCIP_RETCODE consdataFixVariables(SCIP *scip, SCIP_CONSDATA *consdata, SCIP_VAR **vars, int nvars, SCIP_RESULT *result)
SCIP_RETCODE SCIPsetConshdlrPrint(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSPRINT((*consprint)))
int SCIPgetItemid1Samediff(SCIP *scip, SCIP_CONS *cons)
static SCIP_DECL_CONSPRINT(consPrintSamediff)
#define consCheckSamediff
#define CONSHDLR_PROPFREQ
static SCIP_DECL_CONSTRANS(consTransSamediff)
struct SCIP_ProbData SCIP_PROBDATA
SCIP_CONSDATA * SCIPconsGetData(SCIP_CONS *cons)
SCIP_PROBDATA * SCIPgetProbData(SCIP *scip)
static SCIP_RETCODE consdataFree(SCIP *scip, SCIP_CONSDATA **consdata)
int SCIPvardataGetNConsids(SCIP_VARDATA *vardata)
SCIP_Bool SCIPconsIsModifiable(SCIP_CONS *cons)
SCIP_Bool SCIPconsIsEnforced(SCIP_CONS *cons)
SCIP_Bool SCIPconsIsSeparated(SCIP_CONS *cons)
#define CONSHDLR_CHECKPRIORITY
struct SCIP_ConshdlrData SCIP_CONSHDLRDATA
static SCIP_DECL_CONSPROP(consPropSamediff)
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
SCIP_RETCODE SCIPsetConshdlrActive(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSACTIVE((*consactive)))
static SCIP_DECL_CONSACTIVE(consActiveSamediff)
SCIP_RETCODE SCIPprintVar(SCIP *scip, SCIP_VAR *var, FILE *file)
SCIP_RETCODE SCIPsetConshdlrProp(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSPROP((*consprop)), int propfreq, SCIP_Bool delayprop, SCIP_PROPTIMING proptiming)