37 #define CONSHDLR_NAME "lop" 38 #define CONSHDLR_DESC "linear ordering constraint handler" 39 #define CONSHDLR_SEPAPRIORITY 100 40 #define CONSHDLR_ENFOPRIORITY -100 41 #define CONSHDLR_CHECKPRIORITY -100 42 #define CONSHDLR_SEPAFREQ 10 43 #define CONSHDLR_PROPFREQ 1 44 #define CONSHDLR_EAGERFREQ 100 46 #define CONSHDLR_DELAYSEPA FALSE 47 #define CONSHDLR_DELAYPROP FALSE 48 #define CONSHDLR_NEEDSCONS TRUE 50 #define CONSHDLR_PROP_TIMING SCIP_PROPTIMING_BEFORELP 78 assert( scip != NULL );
79 assert( vars != NULL );
80 assert( nGen != NULL );
81 assert( cutoff != NULL );
84 for (i = 0; i < n && ! (*cutoff); ++i)
86 for (j = 0; j < n && ! (*cutoff); ++j)
118 for (k = 0; k < n; ++k)
122 if (k == i || k == j)
162 assert( scip != NULL );
163 assert( conshdlr != NULL );
165 assert( valid != NULL );
182 assert( scip != NULL );
183 assert( conshdlr != NULL );
185 assert( cons != NULL );
186 assert( consdata != NULL);
187 assert( *consdata != NULL);
188 assert( (*consdata)->vars != NULL );
193 for (i = 0; i < n; ++i)
214 assert( scip != NULL );
215 assert( conshdlr != NULL );
230 for (c = 0; c < nconss; ++c)
237 assert( conss != NULL );
238 assert( conss[c] != NULL );
242 assert( consdata != NULL );
243 assert( consdata->vars != NULL );
245 vars = consdata->vars;
251 for (i = 0; i < n; ++i)
254 for (j = 0; j < n; ++j)
275 for (i = 0; i < n; ++i)
297 assert( scip != NULL );
298 assert( conshdlr != NULL );
300 assert( sourcecons != NULL );
301 assert( targetcons != NULL );
307 assert( sourcedata != NULL);
317 for (i = 0; i < n; ++i)
320 for (j = 0; j < n; ++j)
324 assert( sourcedata->vars[i][j] != NULL );
351 assert( scip != NULL );
352 assert( conshdlr != NULL );
354 assert( infeasible != NULL );
359 for (c = 0; c < nconss; ++c)
365 assert( conss != NULL );
366 assert( conss[c] != NULL );
370 assert( consdata != NULL );
371 assert( consdata->vars != NULL );
373 vars = consdata->vars;
376 for (i = 0; i < n; ++i)
378 for (j = i+1; j < n; ++j)
413 assert( scip != NULL );
414 assert( conshdlr != NULL );
416 assert( conss != NULL );
417 assert( result != NULL );
422 for (c = 0; c < nconss; ++c)
429 assert( cons != NULL );
433 assert( consdata != NULL );
457 assert( scip != NULL );
458 assert( conshdlr != NULL );
460 assert( conss != NULL );
461 assert( result != NULL );
466 for (c = 0; c < nconss; ++c)
473 assert( cons != NULL );
477 assert( consdata != NULL );
501 assert( scip != NULL );
502 assert( conshdlr != NULL );
504 assert( conss != NULL );
505 assert( result != NULL );
510 for (c = 0; c < nconss; ++c)
521 assert( cons != NULL );
525 assert( consdata != NULL );
528 vars = consdata->vars;
529 assert( vars != NULL );
531 for (i = 0; i < n; ++i)
533 for (j = 0; j < n; ++j)
569 for (k = 0; k < n; ++k)
573 if (k == i || k == j)
614 SCIPdebugMsg(scip,
"all linear ordering constraints are feasible.\n");
625 assert( scip != NULL );
626 assert( conshdlr != NULL );
628 assert( conss != NULL );
629 assert( result != NULL );
632 for (c = 0; c < nconss; ++c)
643 assert( cons != NULL );
647 assert( consdata != NULL );
648 assert( consdata->vars != NULL );
649 vars = consdata->vars;
653 for (i = 0; i < n; ++i)
655 for (j = 0; j < n; ++j)
673 for (k = 0; k < n; ++k)
676 if (k == i || k == j)
685 if ( oneIJ && oneJK && oneKI )
695 SCIPdebugMsg(scip,
"all linear ordering constraints are feasible.\n");
706 assert( scip != NULL );
707 assert( conshdlr != NULL );
709 assert( conss != NULL );
710 assert( result != NULL );
713 for (c = 0; c < nconss; ++c)
724 assert( cons != NULL );
728 assert( consdata != NULL );
729 assert( consdata->vars != NULL );
730 vars = consdata->vars;
734 for (i = 0; i < n; ++i)
736 for (j = 0; j < n; ++j)
755 SCIPinfoMessage(scip, NULL,
"violation: symmetry equation violated <%s> = %.15g and <%s> = %.15g\n",
762 for (k = 0; k < n; ++k)
765 if (k == i || k == j)
774 if ( oneIJ && oneJK && oneKI )
782 "violation: triangle inequality violated <%s> = %.15g, <%s> = %.15g, <%s> = %.15g\n",
793 SCIPdebugMsg(scip,
"all linear ordering constraints are feasible.\n");
805 assert( scip != NULL );
806 assert( conshdlr != NULL );
808 assert( conss != NULL );
809 assert( result != NULL );
814 for (c = 0; c < nconss; ++c)
825 assert( cons != NULL );
831 assert( consdata != NULL );
832 assert( consdata->vars != NULL );
834 vars = consdata->vars;
838 for (i = 0; i < n; ++i)
840 for (j = 0; j < n; ++j)
883 for (k = 0; k < n; ++k)
885 if (k == i || k == j)
928 assert( scip != NULL );
929 assert( conshdlr != NULL );
931 assert( cons != NULL );
932 assert( infervar != NULL );
933 assert( bdchgidx != NULL );
934 assert( result != NULL );
940 assert( consdata != NULL);
941 assert( consdata->vars != NULL );
944 vars = consdata->vars;
946 assert( 0 <= inferinfo && inferinfo < n*n + n*n*n );
949 if ( inferinfo < (n*n) )
954 index1 = inferinfo/n;
955 index2 = inferinfo % n;
956 assert( 0 <= index1 && index1 < n );
957 assert( 0 <= index2 && index2 < n );
958 assert( vars[index2][index1] == infervar );
963 SCIPdebugMsg(scip,
" -> reason for x[%d][%d] == 0 was x[%d][%d] = 1.\n", index2, index1, index1, index2);
973 SCIPdebugMsg(scip,
" -> reason for x[%d][%d] == 1 was x[%d][%d] = 0.\n", index2, index1, index1, index2);
987 index1 = (inferinfo - n*n)/(n*n);
988 index2 = (inferinfo - n*n - index1 * n*n)/n;
989 index3 = (inferinfo - n*n) % n;
991 assert( 0 <= index1 && index1 < n );
992 assert( 0 <= index2 && index2 < n );
993 assert( 0 <= index3 && index3 < n );
994 assert( index1 != index2 && index2 != index3 && index1 != index3 );
995 assert( vars[index3][index1] == infervar );
1001 SCIPdebugMsg(scip,
" -> reason for x[%d][%d] == 0 was x[%d][%d] = x[%d][%d] = 1.\n", index3, index1, index1, index2, index2, index3);
1020 assert( scip != NULL );
1021 assert( conshdlr != NULL );
1023 assert( cons != NULL );
1029 assert( consdata != NULL);
1030 assert( consdata->vars != NULL );
1032 vars = consdata->vars;
1034 for (i = 0; i < n; ++i)
1036 for (j = 0; j < n; ++j)
1059 assert( scip != NULL );
1060 assert( conshdlr != NULL );
1062 assert( cons != NULL );
1065 assert( consdata != NULL );
1066 assert( consdata->vars != NULL );
1068 vars = consdata->vars;
1071 for (i = 0; i < n; ++i)
1076 for (j = 0; j < n; ++j)
1080 if ( j > 0 && (i > 0 || j > 1) )
1103 assert( scip != 0 );
1104 assert( sourceconshdlr != 0 );
1106 assert( cons != 0 );
1107 assert( sourcescip != 0 );
1108 assert( sourcecons != 0 );
1109 assert( varmap != 0 );
1113 SCIPdebugMsg(scip,
"Copying method for linear ordering constraint handler.\n");
1116 assert( sourcedata != NULL );
1119 sourcevars = sourcedata->vars;
1120 assert( sourcevars != NULL );
1125 for (i = 0; i < n; ++i)
1129 for (j = 0; j < n && *valid; ++j)
1134 assert( !(*valid) || vars[i][j] != NULL );
1146 initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode) );
1150 for (i = n-1; i >= 0; --i)
1168 consEnfolpLOP, consEnfopsLOP, consCheckLOP, consLockLOP, NULL) );
1169 assert( conshdlr != NULL );
1213 if (conshdlr == NULL)
1224 for (i = 0; i < n; ++i)
1227 for (j = 0; j < n; ++j)
1231 assert( vars[i][j] != NULL );
1232 consdata->vars[i][j] = vars[i][j];
1238 SCIP_CALL(
SCIPcreateCons(scip, cons, name, conshdlr, consdata, initial, separate, enforce, check, propagate,
1239 local, modifiable, dynamic, removable, stickingatnode) );
static SCIP_DECL_CONSPRINT(consPrintLOP)
#define SCIPfreeBlockMemoryArray(scip, ptr, num)
#define CONSHDLR_DELAYSEPA
SCIP_RETCODE SCIPsetConshdlrDelete(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSDELETE((*consdelete)))
static SCIP_DECL_CONSHDLRCOPY(conshdlrCopyLOP)
#define SCIPallocBlockMemoryArray(scip, ptr, num)
SCIP_RETCODE SCIPcacheRowExtensions(SCIP *scip, SCIP_ROW *row)
SCIP_Bool SCIPisFeasEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_RETCODE SCIPcreateConsLOP(SCIP *scip, SCIP_CONS **cons, const char *name, int n, SCIP_VAR ***vars, 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 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 SCIPflushRowExtensions(SCIP *scip, SCIP_ROW *row)
SCIP_RETCODE SCIPaddVarToRow(SCIP *scip, SCIP_ROW *row, SCIP_VAR *var, SCIP_Real val)
static SCIP_DECL_CONSENFOPS(consEnfopsLOP)
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
SCIP_RETCODE SCIPaddConflictBinvar(SCIP *scip, SCIP_VAR *var)
SCIP_RETCODE SCIPgetTransformedVar(SCIP *scip, SCIP_VAR *var, SCIP_VAR **transvar)
#define CONSHDLR_SEPAFREQ
#define CONSHDLR_DELAYPROP
static SCIP_DECL_CONSRESPROP(consRespropLOP)
int SCIPgetSubscipDepth(SCIP *scip)
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_Real SCIPinfinity(SCIP *scip)
int SCIPsnprintf(char *t, int len, const char *s,...)
enum SCIP_Retcode SCIP_RETCODE
SCIP_RETCODE SCIPaddConflictUb(SCIP *scip, SCIP_VAR *var, SCIP_BDCHGIDX *bdchgidx)
SCIP_RETCODE SCIPaddVarLocks(SCIP *scip, SCIP_VAR *var, int nlocksdown, int nlocksup)
SCIP_Bool SCIPconsIsStickingAtNode(SCIP_CONS *cons)
SCIP_RETCODE SCIPinitConflictAnalysis(SCIP *scip, SCIP_CONFTYPE conftype, SCIP_Bool iscutoffinvolved)
#define SCIPfreeBlockMemory(scip, ptr)
#define CONSHDLR_PROPFREQ
SCIP_RETCODE SCIPsetConshdlrSepa(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSSEPALP((*conssepalp)), SCIP_DECL_CONSSEPASOL((*conssepasol)), int sepafreq, int sepapriority, SCIP_Bool delaysepa)
#define SCIPfreeBufferArray(scip, ptr)
#define SCIPallocBlockMemory(scip, ptr)
SCIP_Bool SCIPconsIsRemovable(SCIP_CONS *cons)
SCIP_RETCODE SCIPsetConshdlrInitlp(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSINITLP((*consinitlp)))
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 SCIPaddConflictLb(SCIP *scip, SCIP_VAR *var, SCIP_BDCHGIDX *bdchgidx)
static SCIP_DECL_CONSINITLP(consInitlpLOP)
SCIP_RETCODE SCIPsetConshdlrCopy(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSHDLRCOPY((*conshdlrcopy)), SCIP_DECL_CONSCOPY((*conscopy)))
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
void SCIPsortIntInt(int *intarray1, int *intarray2, int len)
#define CONSHDLR_EAGERFREQ
static SCIP_DECL_CONSSEPALP(consSepalpLOP)
#define SCIPfreeBufferArrayNull(scip, ptr)
SCIP_Bool SCIPisEfficacious(SCIP *scip, SCIP_Real efficacy)
constraint handler for linear ordering constraints
SCIP_Real SCIPvarGetUbAtIndex(SCIP_VAR *var, SCIP_BDCHGIDX *bdchgidx, SCIP_Bool after)
const char * SCIPconsGetName(SCIP_CONS *cons)
SCIP_Bool SCIPconsIsPropagated(SCIP_CONS *cons)
static SCIP_DECL_CONSTRANS(consTransLOP)
const char * SCIPvarGetName(SCIP_VAR *var)
SCIP_Bool SCIPisFeasGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_RETCODE SCIPanalyzeConflictCons(SCIP *scip, SCIP_CONS *cons, SCIP_Bool *success)
#define CONSHDLR_CHECKPRIORITY
SCIP_Bool SCIPconsIsLocal(SCIP_CONS *cons)
SCIP_RETCODE SCIPaddRow(SCIP *scip, SCIP_ROW *row, SCIP_Bool forcecut, SCIP_Bool *infeasible)
static SCIP_DECL_CONSEXIT(consExitLOP)
SCIP_RETCODE SCIPsetConshdlrResprop(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSRESPROP((*consresprop)))
struct SCIP_ConsData SCIP_CONSDATA
static SCIP_DECL_CONSCOPY(consCopyLOP)
#define SCIPallocBufferArray(scip, ptr, num)
static SCIP_DECL_CONSCHECK(consCheckLOP)
SCIP_RETCODE SCIPcreateEmptyRowCons(SCIP *scip, SCIP_ROW **row, SCIP_CONSHDLR *conshdlr, const char *name, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool removable)
SCIP_Real SCIPvarGetLbAtIndex(SCIP_VAR *var, SCIP_BDCHGIDX *bdchgidx, SCIP_Bool after)
SCIP_RETCODE SCIPprintCons(SCIP *scip, SCIP_CONS *cons, FILE *file)
SCIP_Bool SCIPconsIsChecked(SCIP_CONS *cons)
SCIP_Bool SCIPconsIsInitial(SCIP_CONS *cons)
static SCIP_DECL_CONSSEPASOL(consSepasolLOP)
SCIP_RETCODE SCIPsetConshdlrPrint(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSPRINT((*consprint)))
static SCIP_DECL_CONSPROP(consPropLOP)
SCIP_RETCODE SCIPincludeConshdlrLOP(SCIP *scip)
#define CONSHDLR_ENFOPRIORITY
SCIP_RETCODE SCIPreleaseRow(SCIP *scip, SCIP_ROW **row)
static SCIP_DECL_CONSDELETE(consDeleteLOP)
SCIP_SOL * SCIPgetBestSol(SCIP *scip)
SCIP_Bool SCIPisGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
#define CONSHDLR_PROP_TIMING
SCIP_RETCODE SCIPgetVarCopy(SCIP *sourcescip, SCIP *targetscip, SCIP_VAR *sourcevar, SCIP_VAR **targetvar, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, SCIP_Bool *success)
SCIP_CONSDATA * SCIPconsGetData(SCIP_CONS *cons)
SCIP_RETCODE SCIPsetConshdlrExit(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSEXIT((*consexit)))
#define CONSHDLR_SEPAPRIORITY
SCIP_Bool SCIPconsIsModifiable(SCIP_CONS *cons)
#define CONSHDLR_NEEDSCONS
SCIP_Bool SCIPconsIsEnforced(SCIP_CONS *cons)
SCIP_Bool SCIPconsIsSeparated(SCIP_CONS *cons)
SCIP_RETCODE SCIPprintRow(SCIP *scip, SCIP_ROW *row, FILE *file)
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
SCIP_Bool SCIPisFeasIntegral(SCIP *scip, SCIP_Real val)
static SCIP_DECL_CONSENFOLP(consEnfolpLOP)
#define BMSclearMemoryArray(ptr, num)
SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
static SCIP_RETCODE LOPseparate(SCIP *scip, SCIP_CONSHDLR *conshdlr, int n, SCIP_VAR ***vars, SCIP_SOL *sol, int *nGen, SCIP_Bool *cutoff)
SCIP_RETCODE SCIPinferBinvarCons(SCIP *scip, SCIP_VAR *var, SCIP_Bool fixedval, SCIP_CONS *infercons, int inferinfo, SCIP_Bool *infeasible, SCIP_Bool *tightened)
static SCIP_DECL_CONSLOCK(consLockLOP)
SCIP_RETCODE SCIPsetConshdlrProp(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSPROP((*consprop)), int propfreq, SCIP_Bool delayprop, SCIP_PROPTIMING proptiming)