35#define MAXITERATIONS 10000
101 SCIP_Real primalbound,
103 SCIP_Longint ntotalnodes,
107 SCIP_Real gap = 1e20;
110 gap = fabs(primalbound - dualbound)/(
MAX3(fabs(primalbound), fabs(dualbound), 1.0));
118 ntotalnodes, ntotalnodes, niter);
139 SCIP_Real primalbound,
141 SCIP_Longint ntotalnodes,
142 SCIP_Longint ntotalcuts,
146 SCIP_Real gap = 1e20;
149 gap = fabs(primalbound - dualbound)/(
MAX3(fabs(primalbound), fabs(dualbound), 1.0));
164 SCIPinfoMessage(masterscip,
NULL,
" Variables : %d (%d binary, %d integer, %d implicit integer, %d continuous)\n",
171 SCIPinfoMessage(masterscip,
NULL,
" Variables : %d (%d binary, %d integer, %d implicit integer, %d continuous)\n",
175 SCIPinfoMessage(masterscip,
NULL,
"Constraints : Number MaxNumber #Separate #Propagate #EnfoLP #EnfoPS #Check #ResProp Cutoffs DomReds Cuts Applied Conss Children\n");
177 "benders", 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ntotalcuts, 0);
179 SCIPinfoMessage(masterscip,
NULL,
"Constraint Timings : TotalTime SetupTime Separate Propagate EnfoLP EnfoPS Check ResProp SB-Prop\n");
180 SCIPinfoMessage(masterscip,
NULL,
" %-17.17s: %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f\n",
"benders",
181 SCIPgetClockTime(masterscip, oracletimeclock), 0.0,
SCIPgetClockTime(masterscip, oracletimeclock), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
215 SCIP_Bool solvemasterapprox,
216 SCIP_Longint masterstallnodes,
217 SCIP_Real mastergaplimit,
225 SCIP_Bool masteroptimal =
TRUE;
227 SCIP_Longint ntotalnodes = 0LL;
228 SCIP_Longint ntotalcuts = 0LL;
230 SCIP_Real* mastersolution;
231 SCIP_Real primalbound = 1e20;
232 SCIP_Real dualbound = -1e20;
233 SCIP_Real mastersolobj = 0.0;
280 if ( solvemasterapprox )
283 SCIPinfoMessage(masterscip,
NULL,
"\nApproximately solving master problem with time limit %.1f and gap limit %.2f%% ...\n", timelimit, 100.0 * mastergaplimit);
285 SCIPinfoMessage(masterscip,
NULL,
"\nApproximately solving master problem with gap limit %.2f%% ...\n", 100.0 * mastergaplimit);
290 SCIPinfoMessage(masterscip,
NULL,
"\nOptimally solving master problem with time limit: %.1f ...\n", timelimit);
299 if ( solvemasterapprox )
300 SCIPinfoMessage(masterscip,
NULL,
" time | niter |nconss | nvars |master|totalnodes|oracle| ncuts | dualbound | gap\n");
302 SCIPinfoMessage(masterscip,
NULL,
" time | niter |nconss | nvars |master|totalnodes|oracle| ncuts | dualbound\n");
310 SCIP_Bool success =
FALSE;
311 SCIP_Real currenttime;
312 SCIP_Real subtimelimit;
314 SCIP_Real mastergap = 1e20;
327 subtimelimit = timelimit - currenttime;
328 if ( subtimelimit <= 0.1 )
333 SCIPdebugMessage(
"Solving separation problem ... (time limit: %g)\n", subtimelimit);
353 SCIP_CALL( Oracle(masterscip, nmastervars, mastervars, mastersolution, data, timelimit, ntotalcuts, &ncuts, &substatus) );
364 primalbound = mastersolobj;
376 SCIPerrorMessage(
"Subproblem returned with status %d. Exiting ...\n", substatus);
387 solvemasterapprox =
FALSE;
399 subtimelimit = timelimit - currenttime;
400 if ( subtimelimit <= 0.1 )
414 if ( solvemasterapprox )
427 if ( solvemasterapprox )
437 masteroptimal =
FALSE;
438 switch ( masterstatus )
441 masteroptimal =
TRUE;
469 SCIPerrorMessage(
"Master problem returned with status %d. Exiting ...\n", masterstatus);
474 if ( mastersol ==
NULL )
476 SCIPerrorMessage(
"Benders master problem does not have a primal solution!\n");
485 for (v = 0; v < nmastervars; ++v)
491 mastersolution[v] = val;
513 if ( solvemasterapprox )
518 while ( niter < maxIters );
522 if ( niter >= maxIters )
540 SCIP_CALL(
printLongStatistics(masterscip, *status, totaltimeclock, oracletimeclock, mastertimeclock, primalbound, dualbound, ntotalnodes, ntotalcuts, niter) );
static SCIP_RETCODE printStatus(SCIP *masterscip, SCIP_STATUS status)
static SCIP_RETCODE printLongStatistics(SCIP *masterscip, SCIP_STATUS status, SCIP_CLOCK *totaltimeclock, SCIP_CLOCK *oracletimeclock, SCIP_CLOCK *mastertimeclock, SCIP_Real primalbound, SCIP_Real dualbound, SCIP_Longint ntotalnodes, SCIP_Longint ntotalcuts, int niter)
SCIP_RETCODE runBenders(SCIP *masterscip, BENDERS_CUTORACLE((*Oracle)), BENDERS_DATA *data, SCIP_Real timelimit, SCIP_Real memlimit, int dispfreq, SCIP_Bool usereopt, SCIP_Bool solvemasterapprox, SCIP_Longint masterstallnodes, SCIP_Real mastergaplimit, SCIP_VERBLEVEL verblevel, SCIP_STATUS *status)
static SCIP_RETCODE printShortStatistics(SCIP *masterscip, SCIP_STATUS status, SCIP_CLOCK *totaltimeclock, SCIP_Real primalbound, SCIP_Real dualbound, SCIP_Longint ntotalnodes, int niter)
@ BENDERS_STATUS_ADDEDCUT
@ BENDERS_STATUS_USERINTERRUPT
@ BENDERS_STATUS_TIMELIMIT
#define BENDERS_CUTORACLE(x)
enum BENDERS_Status BENDERS_STATUS
#define SCIP_LONGINT_FORMAT
SCIP_STATUS SCIPgetStatus(SCIP *scip)
int SCIPgetNIntVars(SCIP *scip)
SCIP_RETCODE SCIPgetOrigVarsData(SCIP *scip, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars)
int SCIPgetNImplVars(SCIP *scip)
const char * SCIPgetProbName(SCIP *scip)
int SCIPgetNContVars(SCIP *scip)
int SCIPgetNOrigConss(SCIP *scip)
int SCIPgetNVars(SCIP *scip)
int SCIPgetNConss(SCIP *scip)
int SCIPgetNOrigVars(SCIP *scip)
int SCIPgetNBinVars(SCIP *scip)
void SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...)
SCIP_MESSAGEHDLR * SCIPgetMessagehdlr(SCIP *scip)
SCIP_RETCODE SCIPsetLongintParam(SCIP *scip, const char *name, SCIP_Longint value)
SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value)
SCIP_RETCODE SCIPsetRealParam(SCIP *scip, const char *name, SCIP_Real value)
void SCIPdispLongint(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, SCIP_Longint val, int width)
void SCIPdispTime(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, SCIP_Real val, int width)
void SCIPdispInt(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, int val, int width)
#define SCIPfreeBlockMemoryArray(scip, ptr, num)
#define SCIPallocClearBlockMemoryArray(scip, ptr, num)
SCIP_RETCODE SCIPenableReoptimization(SCIP *scip, SCIP_Bool enable)
SCIP_RETCODE SCIPfreeReoptSolve(SCIP *scip)
SCIP_SOL * SCIPgetBestSol(SCIP *scip)
SCIP_Real SCIPgetSolOrigObj(SCIP *scip, SCIP_SOL *sol)
SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
SCIP_RETCODE SCIPfreeTransform(SCIP *scip)
SCIP_RETCODE SCIPsolve(SCIP *scip)
SCIP_Real SCIPgetGap(SCIP *scip)
SCIP_Real SCIPgetDualbound(SCIP *scip)
SCIP_Longint SCIPgetNTotalNodes(SCIP *scip)
SCIP_RETCODE SCIPcreateClock(SCIP *scip, SCIP_CLOCK **clck)
SCIP_RETCODE SCIPstopClock(SCIP *scip, SCIP_CLOCK *clck)
SCIP_RETCODE SCIPfreeClock(SCIP *scip, SCIP_CLOCK **clck)
SCIP_Real SCIPgetClockTime(SCIP *scip, SCIP_CLOCK *clck)
SCIP_RETCODE SCIPstartClock(SCIP *scip, SCIP_CLOCK *clck)
SCIP_Real SCIPinfinity(SCIP *scip)
SCIP_Bool SCIPisIntegral(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
assert(minobj< SCIPgetCutoffbound(scip))
void SCIPmessageFPrintInfo(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char *formatstr,...)
enum SCIP_VerbLevel SCIP_VERBLEVEL
enum SCIP_Retcode SCIP_RETCODE
@ SCIP_STATUS_TOTALNODELIMIT
@ SCIP_STATUS_BESTSOLLIMIT
@ SCIP_STATUS_USERINTERRUPT
@ SCIP_STATUS_STALLNODELIMIT
@ SCIP_STATUS_RESTARTLIMIT
enum SCIP_Status SCIP_STATUS