31 #define CONSHDLR_NAME "conjunction" 32 #define CONSHDLR_DESC "conjunction of constraints" 33 #define CONSHDLR_ENFOPRIORITY +900000 34 #define CONSHDLR_CHECKPRIORITY -900000 35 #define CONSHDLR_EAGERFREQ 100 37 #define CONSHDLR_MAXPREROUNDS -1 38 #define CONSHDLR_NEEDSCONS TRUE 40 #define CONSHDLR_PRESOLTIMING SCIP_PRESOLTIMING_FAST 68 assert(consdata != NULL);
74 (*consdata)->consssize = nconss;
75 (*consdata)->nconss = nconss;
85 for( c = 0; c < nconss; ++c )
93 (*consdata)->conss = NULL;
94 (*consdata)->consssize = 0;
95 (*consdata)->nconss = 0;
110 assert(consdata != NULL);
111 assert(*consdata != NULL);
114 for( c = 0; c < (*consdata)->nconss; ++c )
134 assert(consdata != NULL);
138 assert(consdata->conss != NULL);
139 assert(consdata->nconss < consdata->consssize);
142 consdata->conss[consdata->nconss] = cons;
171 assert(result != NULL);
173 for( c = 0; c < nconss; ++c )
176 assert(consdata != NULL);
179 for( i = 0; i < consdata->nconss; ++i )
190 SCIPdebugMsg(scip,
"adding constraint <%s> from add conjunction <%s>\n",
225 assert(result != NULL);
229 for( c = 0; c < nconss && (*result ==
SCIP_FEASIBLE || completely); ++c )
234 assert(consdata != NULL);
237 for( i = 0; i < consdata->nconss && subresult ==
SCIP_FEASIBLE; ++i )
239 SCIP_CALL(
SCIPcheckCons(scip, consdata->conss[i], sol, checkintegrality, checklprows, printreason, &subresult) );
252 assert( 0 < i && i <= consdata->nconss );
253 SCIPinfoMessage(scip, NULL,
"Conjunction constraint %s is violated, at least the sub-constraint %s is violated by this given solution.\n",
273 assert(scip != NULL);
274 assert(conshdlr != NULL);
309 if( sourcedata->nconss > 0 )
311 targetdata->consssize = sourcedata->nconss;
312 targetdata->nconss = sourcedata->nconss;
314 for( c = 0; c < sourcedata->nconss; ++c )
321 targetdata->conss = NULL;
322 targetdata->consssize = 0;
323 targetdata->nconss = 0;
383 SCIP_CALL(
checkAllConss(scip, conss, nconss, sol, checkintegrality, checklprows, printreason, completely, result) );
397 assert(result != NULL);
405 for( c = 0; c < nconss; ++c )
408 assert(consdata != NULL);
411 for( i = 0; i < consdata->nconss; ++i )
423 SCIPdebugMsg(scip,
"adding constraint <%s> from add conjunction <%s>\n",
432 consdata->nconss = 0;
453 assert(consdata != NULL);
456 for( c = 0; c < consdata->nconss; ++c )
472 assert( scip != NULL );
473 assert( conshdlr != NULL );
474 assert( cons != NULL );
477 assert(consdata != NULL);
481 for( i = 0; i < consdata->nconss; ++i )
501 char* nexttokenstart;
504 assert(scip != NULL);
505 assert(conshdlr != NULL);
506 assert(cons != NULL);
507 assert(success != NULL);
509 assert(name != NULL);
522 saveptr = strpbrk(copystr,
"(");
524 if( saveptr == NULL )
526 SCIPdebugMsg(scip,
"error parsing conjunctive constraint: \"%s\"\n", str);
534 nexttokenstart = saveptr;
537 saveptr = strpbrk(saveptr,
"(,");
542 if( saveptr != NULL )
546 int bracketcounter = 0;
548 if( *saveptr ==
'(' )
556 while( bracketcounter > 0 )
558 saveptr = strpbrk(saveptr,
"()");
560 if( saveptr != NULL )
562 if( *saveptr ==
'(' )
571 SCIPdebugMsg(scip,
"error parsing conjunctive constraint: \"%s\"\n", str);
577 saveptr = strpbrk(saveptr,
"(,");
579 while( saveptr != NULL && *saveptr ==
'(' );
583 if( saveptr != NULL )
585 assert(*saveptr ==
',');
588 if( nconss == sconss )
591 assert(nconss < sconss);
596 assert(saveptr > nexttokenstart);
600 token[saveptr - nexttokenstart] =
'\0';
602 SCIPdebugMsg(scip,
"conjunctive parsing token(constraint): %s\n", token);
605 SCIP_CALL(
SCIPparseCons(scip, &(conss[nconss]), token, initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode, success) );
613 SCIPdebugMsg(scip,
"error parsing conjunctive constraint: \"%s\"\n", str);
619 nexttokenstart = saveptr;
621 saveptr = strpbrk(saveptr,
"(,");
624 while( saveptr != NULL );
628 saveptr = strrchr(nexttokenstart,
')');
630 if( saveptr == NULL )
632 SCIPdebugMsg(scip,
"error parsing conjunctive constraint: \"%s\"\n", str);
640 if( nconss == sconss )
646 assert(saveptr > nexttokenstart);
650 token[saveptr - nexttokenstart] =
'\0';
652 SCIPdebugMsg(scip,
"conjunctive parsing token(constraint): %s\n", token);
655 SCIP_CALL(
SCIPparseCons(scip, &(conss[nconss]), token, initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode, success) );
662 assert(nconss > 0 || !(*success));
669 enforce, check, local, modifiable, dynamic) );
673 for( --nconss; nconss >= 0; --nconss )
699 assert(sourcedata != NULL);
701 sourceconss = sourcedata->conss;
702 nconss = sourcedata->nconss;
706 assert(sourceconss != NULL);
711 for( c = 0; c < nconss && (*valid); ++c )
720 assert(!(*valid) || conss[c] != NULL);
728 enforce, check, local, modifiable, dynamic) );
733 enforce, check, local, modifiable, dynamic) );
738 for( c = (*valid ? c - 1 : c - 2); c >= 0; --c )
740 assert(conss[c] != NULL);
765 consEnfolpConjunction, consEnfopsConjunction, consCheckConjunction, consLockConjunction,
768 assert(conshdlr != NULL);
812 if( conshdlr == NULL )
822 SCIP_CALL(
SCIPcreateCons(scip, cons, name, conshdlr, consdata,
FALSE,
FALSE, enforce, check,
FALSE,
844 assert(scip != NULL);
861 assert(cons != NULL);
862 assert(addcons != NULL);
871 assert(consdata != NULL);
enum SCIP_Result SCIP_RESULT
SCIP_RETCODE SCIPsetConshdlrDelete(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSDELETE((*consdelete)))
#define SCIPallocBlockMemoryArray(scip, ptr, num)
static SCIP_DECL_CONSPARSE(consParseConjunction)
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_RETCODE SCIPsetConshdlrEnforelax(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSENFORELAX((*consenforelax)))
SCIP_RETCODE SCIPdelCons(SCIP *scip, SCIP_CONS *cons)
int SCIPcalcMemGrowSize(SCIP *scip, int num)
SCIP_RETCODE SCIPtransformConss(SCIP *scip, int nconss, SCIP_CONS **conss, SCIP_CONS **transconss)
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_RETCODE SCIPparseCons(SCIP *scip, SCIP_CONS **cons, const char *str, 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_Bool *success)
enum SCIP_Retcode SCIP_RETCODE
SCIP_Bool SCIPconsIsStickingAtNode(SCIP_CONS *cons)
static SCIP_RETCODE checkAllConss(SCIP *scip, SCIP_CONS **conss, int nconss, SCIP_SOL *sol, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool printreason, SCIP_Bool completely, SCIP_RESULT *result)
#define SCIPfreeBlockMemory(scip, ptr)
static SCIP_RETCODE consdataCreate(SCIP *scip, SCIP_CONSDATA **consdata, SCIP_CONS **conss, int nconss)
static SCIP_DECL_CONSCOPY(consCopyConjunction)
#define SCIPduplicateBufferArray(scip, ptr, source, num)
#define SCIPfreeBufferArray(scip, ptr)
#define CONSHDLR_ENFOPRIORITY
#define SCIPallocBlockMemory(scip, ptr)
SCIP_Bool SCIPisTransformed(SCIP *scip)
static SCIP_DECL_CONSLOCK(consLockConjunction)
SCIP_Bool SCIPconsIsRemovable(SCIP_CONS *cons)
SCIP_RETCODE SCIPsetConshdlrParse(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSPARSE((*consparse)))
SCIP_Bool SCIPconsIsActive(SCIP_CONS *cons)
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 consdataFree(SCIP *scip, SCIP_CONSDATA **consdata)
#define CONSHDLR_EAGERFREQ
#define SCIPduplicateBlockMemoryArray(scip, ptr, source, num)
SCIP_RETCODE SCIPcreateConsBasicConjunction(SCIP *scip, SCIP_CONS **cons, const char *name, int nconss, SCIP_CONS **conss)
static SCIP_DECL_CONSCHECK(consCheckConjunction)
SCIP_RETCODE SCIPsetConshdlrCopy(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSHDLRCOPY((*conshdlrcopy)), SCIP_DECL_CONSCOPY((*conscopy)))
constraint handler for conjunction constraints
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
SCIP_RETCODE SCIPaddCons(SCIP *scip, SCIP_CONS *cons)
static SCIP_RETCODE consdataAddCons(SCIP *scip, SCIP_CONSDATA *consdata, SCIP_CONS *cons)
SCIP_RETCODE SCIPaddConsLocal(SCIP *scip, SCIP_CONS *cons, SCIP_NODE *validnode)
SCIP_RETCODE SCIPdelConsLocal(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPcheckCons(SCIP *scip, SCIP_CONS *cons, SCIP_SOL *sol, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool printreason, SCIP_RESULT *result)
SCIP_RETCODE SCIPsetConsChecked(SCIP *scip, SCIP_CONS *cons, SCIP_Bool check)
const char * SCIPconsGetName(SCIP_CONS *cons)
SCIP_Bool SCIPconsIsPropagated(SCIP_CONS *cons)
SCIP_RETCODE SCIPaddConsElemConjunction(SCIP *scip, SCIP_CONS *cons, SCIP_CONS *addcons)
SCIP_RETCODE SCIPtransformCons(SCIP *scip, SCIP_CONS *cons, SCIP_CONS **transcons)
SCIP_RETCODE SCIPincludeConshdlrConjunction(SCIP *scip)
#define SCIPensureBlockMemoryArray(scip, ptr, arraysizeptr, minsize)
static SCIP_DECL_CONSENFOLP(consEnfolpConjunction)
SCIP_Bool SCIPconsIsLocal(SCIP_CONS *cons)
#define CONSHDLR_PRESOLTIMING
SCIP_RETCODE SCIPcaptureCons(SCIP *scip, SCIP_CONS *cons)
struct SCIP_ConsData SCIP_CONSDATA
SCIP_RETCODE SCIPgetConsCopy(SCIP *sourcescip, SCIP *targetscip, SCIP_CONS *sourcecons, SCIP_CONS **targetcons, SCIP_CONSHDLR *sourceconshdlr, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, const char *name, 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_Bool global, SCIP_Bool *valid)
#define SCIPallocBufferArray(scip, ptr, num)
SCIP_RETCODE SCIPprintCons(SCIP *scip, SCIP_CONS *cons, FILE *file)
SCIP_CONSHDLR * SCIPconsGetHdlr(SCIP_CONS *cons)
static SCIP_DECL_CONSENFORELAX(consEnforelaxConjunction)
SCIP_Bool SCIPconsIsChecked(SCIP_CONS *cons)
SCIP_Bool SCIPconsIsInitial(SCIP_CONS *cons)
SCIP_RETCODE SCIPcreateConsConjunction(SCIP *scip, SCIP_CONS **cons, const char *name, int nconss, SCIP_CONS **conss, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic)
SCIP_RETCODE SCIPsetConshdlrPrint(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSPRINT((*consprint)))
static SCIP_DECL_CONSPRINT(consPrintConjunction)
#define CONSHDLR_CHECKPRIORITY
static SCIP_DECL_CONSDELETE(consDeleteConjunction)
SCIP_CONSDATA * SCIPconsGetData(SCIP_CONS *cons)
static SCIP_DECL_CONSENFOPS(consEnfopsConjunction)
static SCIP_DECL_CONSTRANS(consTransConjunction)
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
SCIP_RETCODE SCIPsetConshdlrPresol(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSPRESOL((*conspresol)), int maxprerounds, SCIP_PRESOLTIMING presoltiming)
void SCIPupdateSolConsViolation(SCIP *scip, SCIP_SOL *sol, SCIP_Real absviol, SCIP_Real relviol)
static SCIP_DECL_CONSHDLRCOPY(conshdlrCopyConjunction)
static SCIP_DECL_CONSPRESOL(consPresolConjunction)
#define CONSHDLR_MAXPREROUNDS
SCIP_Bool SCIPconsIsModifiable(SCIP_CONS *cons)
SCIP_Bool SCIPconsIsEnforced(SCIP_CONS *cons)
SCIP_Bool SCIPconsIsSeparated(SCIP_CONS *cons)
SCIP_RETCODE SCIPaddConsLocks(SCIP *scip, SCIP_CONS *cons, int nlockspos, int nlocksneg)
#define SCIPfreeBlockMemoryArrayNull(scip, ptr, num)
#define CONSHDLR_NEEDSCONS
#define SCIPreallocBufferArray(scip, ptr, num)
static SCIP_RETCODE addAllConss(SCIP *scip, SCIP_CONS **conss, int nconss, SCIP_RESULT *result)