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) );
249 assert( 0 < i && i <= consdata->nconss );
250 SCIPinfoMessage(scip,
NULL,
"Conjunction constraint %s is violated, at least the sub-constraint %s is violated by this given solution.\n",
270 assert(scip !=
NULL);
271 assert(conshdlr !=
NULL);
306 if( sourcedata->nconss > 0 )
308 targetdata->consssize = sourcedata->nconss;
309 targetdata->nconss = sourcedata->nconss;
311 for( c = 0; c < sourcedata->nconss; ++c )
318 targetdata->conss =
NULL;
319 targetdata->consssize = 0;
320 targetdata->nconss = 0;
380 SCIP_CALL(
checkAllConss(scip, conss, nconss, sol, checkintegrality, checklprows, printreason, completely, result) );
394 assert(result !=
NULL);
402 for( c = 0; c < nconss; ++c )
405 assert(consdata !=
NULL);
408 for( i = 0; i < consdata->nconss; ++i )
420 SCIPdebugMsg(scip,
"adding constraint <%s> from add conjunction <%s>\n",
429 consdata->nconss = 0;
450 assert(consdata !=
NULL);
453 for( c = 0; c < consdata->nconss; ++c )
469 assert( scip !=
NULL );
470 assert( conshdlr !=
NULL );
471 assert( cons !=
NULL );
474 assert(consdata !=
NULL);
478 for( i = 0; i < consdata->nconss; ++i )
498 char* nexttokenstart;
501 assert(scip !=
NULL);
502 assert(conshdlr !=
NULL);
503 assert(cons !=
NULL);
504 assert(success !=
NULL);
506 assert(name !=
NULL);
519 saveptr = strpbrk(copystr,
"(");
521 if( saveptr ==
NULL )
523 SCIPdebugMsg(scip,
"error parsing conjunctive constraint: \"%s\"\n", str);
531 nexttokenstart = saveptr;
534 saveptr = strpbrk(saveptr,
"(,");
539 if( saveptr !=
NULL )
543 int bracketcounter = 0;
545 if( *saveptr ==
'(' )
553 while( bracketcounter > 0 )
555 saveptr = strpbrk(saveptr,
"()");
557 if( saveptr !=
NULL )
559 if( *saveptr ==
'(' )
568 SCIPdebugMsg(scip,
"error parsing conjunctive constraint: \"%s\"\n", str);
574 saveptr = strpbrk(saveptr,
"(,");
576 while( saveptr !=
NULL && *saveptr ==
'(' );
580 if( saveptr !=
NULL )
582 assert(*saveptr ==
',');
585 if( nconss == sconss )
588 assert(nconss < sconss);
593 assert(saveptr > nexttokenstart);
597 token[saveptr - nexttokenstart] =
'\0';
599 SCIPdebugMsg(scip,
"conjunctive parsing token(constraint): %s\n", token);
602 SCIP_CALL(
SCIPparseCons(scip, &(conss[nconss]), token, initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode, success) );
610 SCIPdebugMsg(scip,
"error parsing conjunctive constraint: \"%s\"\n", str);
616 nexttokenstart = saveptr;
618 saveptr = strpbrk(saveptr,
"(,");
621 while( saveptr !=
NULL );
625 saveptr = strrchr(nexttokenstart,
')');
627 if( saveptr ==
NULL )
629 SCIPdebugMsg(scip,
"error parsing conjunctive constraint: \"%s\"\n", str);
637 if( nconss == sconss )
643 assert(saveptr > nexttokenstart);
647 token[saveptr - nexttokenstart] =
'\0';
649 SCIPdebugMsg(scip,
"conjunctive parsing token(constraint): %s\n", token);
652 SCIP_CALL(
SCIPparseCons(scip, &(conss[nconss]), token, initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode, success) );
659 assert(nconss > 0 || !(*success));
666 enforce, check, local, modifiable, dynamic) );
670 for( --nconss; nconss >= 0; --nconss )
696 assert(sourcedata !=
NULL);
698 sourceconss = sourcedata->conss;
699 nconss = sourcedata->nconss;
703 assert(sourceconss !=
NULL);
708 for( c = 0; c < nconss && (*valid); ++c )
717 assert(!(*valid) || conss[c] !=
NULL);
725 enforce, check, local, modifiable, dynamic) );
730 enforce, check, local, modifiable, dynamic) );
735 for( c = (*valid ? c - 1 : c - 2); c >= 0; --c )
737 assert(conss[c] !=
NULL);
762 consEnfolpConjunction, consEnfopsConjunction, consCheckConjunction, consLockConjunction,
765 assert(conshdlr !=
NULL);
809 if( conshdlr ==
NULL )
819 SCIP_CALL(
SCIPcreateCons(scip, cons, name, conshdlr, consdata,
FALSE,
FALSE, enforce, check,
FALSE,
841 assert(scip !=
NULL);
858 assert(cons !=
NULL);
859 assert(addcons !=
NULL);
868 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)
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)