/** adds initial constraint to root node */ SCIP_RETCODE SCIPconsOrigbranchAddRootCons( SCIP* scip /**< SCIP data structure */ ) { SCIP_CONSHDLR* conshdlr; SCIP_CONSHDLRDATA* conshdlrdata; SCIP_CONS* cons; assert(scip != NULL); conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME); if( conshdlr == NULL ) { SCIPerrorMessage("origbranch constraint handler not found\n"); return SCIP_ERROR; } conshdlrdata = SCIPconshdlrGetData(conshdlr); assert(conshdlrdata != NULL); if( conshdlrdata->rootcons == NULL ) { SCIP_CALL( GCGcreateConsOrigbranch(scip, &cons, "root-origbranch", NULL, NULL, NULL, NULL) ); SCIP_CALL( SCIPaddConsNode(scip, SCIPgetRootNode(scip), cons, SCIPgetRootNode(scip)) ); conshdlrdata->rootcons = cons; } /* check consistency */ GCGconsOrigbranchCheckConsistency(scip); return SCIP_OKAY; }
/** separation method of constraint handler for LP solutions */ static SCIP_DECL_CONSSEPALP(consSepalpStp) { /*lint --e{715}*/ SCIP_CONSHDLRDATA* conshdlrdata; int maxcuts; int ncuts = 0; int i; *result = SCIP_DIDNOTRUN; conshdlrdata = SCIPconshdlrGetData(conshdlr); assert(conshdlrdata != NULL); maxcuts = SCIPnodeGetDepth(SCIPgetCurrentNode(scip)) == 0 ? conshdlrdata->maxsepacutsroot : conshdlrdata->maxsepacuts; for( i = 0; i < nconss; ++i ) { SCIP_CONSDATA* consdata; consdata = SCIPconsGetData(conss[i]); SCIP_CALL( sep_flow(scip, conshdlr, conshdlrdata, consdata, maxcuts, &ncuts) ); SCIP_CALL( sep_2cut(scip, conshdlr, conshdlrdata, consdata, maxcuts, &ncuts) ); } if( ncuts > 0 ) *result = SCIP_SEPARATED; return SCIP_OKAY; }
/** constraint deactivation notification method of constraint handler */ static SCIP_DECL_CONSDEACTIVE(consDeactiveOrigbranch) { /*lint --e{715}*/ SCIP_CONSHDLRDATA* conshdlrData; assert(scip != NULL); assert(conshdlr != NULL); assert(strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0); assert(cons != NULL); conshdlrData = SCIPconshdlrGetData(conshdlr); assert(conshdlrData != NULL); assert(conshdlrData->stack != NULL || conshdlrData->nstack <= 1); assert(conshdlrData->nstack <= 1 || cons == conshdlrData->stack[conshdlrData->nstack-1]); assert(SCIPconsGetData(cons) != NULL); SCIPdebugMessage("Deactivating branch orig constraint: <%s> [stack size: %d].\n", SCIPconsGetName(cons), conshdlrData->nstack-1); /* remove constraint from the stack */ if( conshdlrData->nstack > 0 ) --(conshdlrData->nstack); return SCIP_OKAY; }
/** solving process initialization method of constraint handler (called when branch and bound process is about to begin) */ static SCIP_DECL_CONSINITSOL(consInitsolOrigbranch) { /*lint --e{715}*/ SCIP_CONSHDLRDATA* conshdlrData; assert(scip != NULL); assert(conshdlr != NULL); assert(strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0); conshdlrData = SCIPconshdlrGetData(conshdlr); assert(conshdlrData != NULL); /* prepare stack */ SCIP_CALL( SCIPallocMemoryArray(scip, &conshdlrData->stack, conshdlrData->maxstacksize) ); assert( conshdlrData->nstack >= 0 ); /* check consistency */ if( conshdlrData->rootcons != NULL ) { SCIP_CALL( SCIPreleaseCons(scip, &conshdlrData->rootcons) ); conshdlrData->rootcons = NULL; --(conshdlrData->nstack); } GCGconsOrigbranchCheckConsistency(scip); return SCIP_OKAY; }
/** destructor of constraint handler to free constraint handler data (called when SCIP is exiting) */ static SCIP_DECL_CONSFREE(consFreeOrigbranch) { /*lint --e{715}*/ SCIP_CONSHDLRDATA* conshdlrData; assert(scip != NULL); assert(conshdlr != NULL); assert(strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0); conshdlrData = SCIPconshdlrGetData(conshdlr); assert(conshdlrData != NULL); SCIPdebugMessage("freeing branch orig constraint handler\n"); /* free constraint handler storage */ assert(conshdlrData->stack == NULL); if( conshdlrData->rootcons != NULL ) { SCIP_CALL( SCIPreleaseCons(scip, &conshdlrData->rootcons) ); } SCIPfreeMemory(scip, &conshdlrData); return SCIP_OKAY; }
/** returns the conshdlr object for the given constraint handler */ scip::ObjConshdlr* SCIPgetObjConshdlr( SCIP* scip, /**< SCIP data structure */ SCIP_CONSHDLR* conshdlr /**< constraint handler */ ) { SCIP_CONSHDLRDATA* conshdlrdata; conshdlrdata = SCIPconshdlrGetData(conshdlr); assert(conshdlrdata != NULL); return conshdlrdata->objconshdlr; }
/** solving process deinitialization method of constraint handler (called before branch and bound process data is freed) */ static SCIP_DECL_CONSEXITSOL(consExitsolObj) { /*lint --e{715}*/ SCIP_CONSHDLRDATA* conshdlrdata; conshdlrdata = SCIPconshdlrGetData(conshdlr); assert(conshdlrdata != NULL); assert(conshdlrdata->objconshdlr != NULL); /* call virtual method of conshdlr object */ SCIP_CALL( conshdlrdata->objconshdlr->scip_exitsol(scip, conshdlr, conss, nconss, restart) ); return SCIP_OKAY; }
/** constraint display method of constraint handler */ static SCIP_DECL_CONSPRINT(consPrintObj) { /*lint --e{715}*/ SCIP_CONSHDLRDATA* conshdlrdata; conshdlrdata = SCIPconshdlrGetData(conshdlr); assert(conshdlrdata != NULL); assert(conshdlrdata->objconshdlr != NULL); /* call virtual method of conshdlr object */ SCIP_CALL( conshdlrdata->objconshdlr->scip_print(scip, conshdlr, cons, file) ); return SCIP_OKAY; }
/** variable deletion method of constraint handler */ static SCIP_DECL_CONSDELVARS(consDelVarsObj) { /*lint --e{715}*/ SCIP_CONSHDLRDATA* conshdlrdata; conshdlrdata = SCIPconshdlrGetData(conshdlr); assert(conshdlrdata != NULL); assert(conshdlrdata->objconshdlr != NULL); /* call virtual method of conshdlr object */ SCIP_CALL( conshdlrdata->objconshdlr->scip_delvars(scip, conshdlr, conss, nconss) ); return SCIP_OKAY; }
/** constraint disabling notification method of constraint handler */ static SCIP_DECL_CONSDISABLE(consDisableObj) { /*lint --e{715}*/ SCIP_CONSHDLRDATA* conshdlrdata; conshdlrdata = SCIPconshdlrGetData(conshdlr); assert(conshdlrdata != NULL); assert(conshdlrdata->objconshdlr != NULL); /* call virtual method of conshdlr object */ SCIP_CALL( conshdlrdata->objconshdlr->scip_disable(scip, conshdlr, cons) ); return SCIP_OKAY; }
/** variable rounding lock method of constraint handler */ static SCIP_DECL_CONSLOCK(consLockObj) { /*lint --e{715}*/ SCIP_CONSHDLRDATA* conshdlrdata; conshdlrdata = SCIPconshdlrGetData(conshdlr); assert(conshdlrdata != NULL); assert(conshdlrdata->objconshdlr != NULL); /* call virtual method of conshdlr object */ SCIP_CALL( conshdlrdata->objconshdlr->scip_lock(scip, conshdlr, cons, nlockspos, nlocksneg) ); return SCIP_OKAY; }
/** constraint method of constraint handler which returns the number of variables (if possible) */ static SCIP_DECL_CONSGETNVARS(consGetNVarsObj) { /*lint --e{715}*/ SCIP_CONSHDLRDATA* conshdlrdata; conshdlrdata = SCIPconshdlrGetData(conshdlr); assert(conshdlrdata != NULL); assert(conshdlrdata->objconshdlr != NULL); /* call virtual method of conshdlr object */ SCIP_CALL( conshdlrdata->objconshdlr->scip_getnvars(scip, conshdlr, cons, nvars, success) ); return SCIP_OKAY; }
/** domain propagation method of constraint handler */ static SCIP_DECL_CONSPROP(consPropObj) { /*lint --e{715}*/ SCIP_CONSHDLRDATA* conshdlrdata; conshdlrdata = SCIPconshdlrGetData(conshdlr); assert(conshdlrdata != NULL); assert(conshdlrdata->objconshdlr != NULL); /* call virtual method of conshdlr object */ SCIP_CALL( conshdlrdata->objconshdlr->scip_prop(scip, conshdlr, conss, nconss, nusefulconss, proptiming, result) ); return SCIP_OKAY; }
/** constraint enforcing method of constraint handler for LP solutions */ static SCIP_DECL_CONSENFOLP(consEnfolpObj) { /*lint --e{715}*/ SCIP_CONSHDLRDATA* conshdlrdata; conshdlrdata = SCIPconshdlrGetData(conshdlr); assert(conshdlrdata != NULL); assert(conshdlrdata->objconshdlr != NULL); /* call virtual method of conshdlr object */ SCIP_CALL( conshdlrdata->objconshdlr->scip_enfolp(scip, conshdlr, conss, nconss, nusefulconss, solinfeasible, result) ); return SCIP_OKAY; }
/** separation method of constraint handler for arbitrary primal solutions */ static SCIP_DECL_CONSSEPASOL(consSepasolObj) { /*lint --e{715}*/ SCIP_CONSHDLRDATA* conshdlrdata; conshdlrdata = SCIPconshdlrGetData(conshdlr); assert(conshdlrdata != NULL); assert(conshdlrdata->objconshdlr != NULL); /* call virtual method of conshdlr object */ SCIP_CALL( conshdlrdata->objconshdlr->scip_sepasol(scip, conshdlr, conss, nconss, nusefulconss, sol, result) ); return SCIP_OKAY; }
/** LP initialization method of constraint handler */ static SCIP_DECL_CONSINITLP(consInitlpObj) { /*lint --e{715}*/ SCIP_CONSHDLRDATA* conshdlrdata; conshdlrdata = SCIPconshdlrGetData(conshdlr); assert(conshdlrdata != NULL); assert(conshdlrdata->objconshdlr != NULL); /* call virtual method of conshdlr object */ SCIP_CALL( conshdlrdata->objconshdlr->scip_initlp(scip, conshdlr, conss, nconss) ); return SCIP_OKAY; }
/** transforms constraint data into data belonging to the transformed problem */ static SCIP_DECL_CONSTRANS(consTransObj) { /*lint --e{715}*/ SCIP_CONSHDLRDATA* conshdlrdata; conshdlrdata = SCIPconshdlrGetData(conshdlr); assert(conshdlrdata != NULL); assert(conshdlrdata->objconshdlr != NULL); /* call virtual method of conshdlr object */ SCIP_CALL( conshdlrdata->objconshdlr->scip_trans(scip, conshdlr, sourcecons, targetcons) ); return SCIP_OKAY; }
/** presolving deinitialization method of constraint handler (called after presolving has been finished) */ static SCIP_DECL_CONSEXITPRE(consExitpreObj) { /*lint --e{715}*/ SCIP_CONSHDLRDATA* conshdlrdata; conshdlrdata = SCIPconshdlrGetData(conshdlr); assert(conshdlrdata != NULL); assert(conshdlrdata->objconshdlr != NULL); /* call virtual method of conshdlr object */ SCIP_CALL( conshdlrdata->objconshdlr->scip_exitpre(scip, conshdlr, conss, nconss, isunbounded, isinfeasible, result) ); return SCIP_OKAY; }
/** constraint copying method of constraint handler */ static SCIP_DECL_CONSCOPY(consCopyObj) { /*lint --e{715}*/ SCIP_CONSHDLRDATA* sourceconshdlrdata; sourceconshdlrdata = SCIPconshdlrGetData(sourceconshdlr); assert(sourceconshdlrdata != NULL); assert(sourceconshdlrdata->objconshdlr != NULL); /* call virtual method of conshdlr object */ SCIP_CALL( sourceconshdlrdata->objconshdlr->scip_copy(scip, cons, name, sourcescip, sourceconshdlr, sourcecons, varmap, consmap, initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode, global, valid) ); return SCIP_OKAY; }
/** feasibility check method of constraint handler for primal solutions */ static SCIP_DECL_CONSCHECK(consCheckObj) { /*lint --e{715}*/ SCIP_CONSHDLRDATA* conshdlrdata; conshdlrdata = SCIPconshdlrGetData(conshdlr); assert(conshdlrdata != NULL); assert(conshdlrdata->objconshdlr != NULL); /* call virtual method of conshdlr object */ SCIP_CALL( conshdlrdata->objconshdlr->scip_check(scip, conshdlr, conss, nconss, sol, checkintegrality, checklprows, printreason, result) ); return SCIP_OKAY; }
/** constraint parsing method of constraint handler */ static SCIP_DECL_CONSPARSE(consParseObj) { /*lint --e{715}*/ SCIP_CONSHDLRDATA* conshdlrdata; conshdlrdata = SCIPconshdlrGetData(conshdlr); assert(conshdlrdata != NULL); assert(conshdlrdata->objconshdlr != NULL); /* call virtual method of conshdlr object */ SCIP_CALL( conshdlrdata->objconshdlr->scip_parse(scip, conshdlr, cons, name, str, initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode, success) ); return SCIP_OKAY; }
/** propagation conflict resolving method of constraint handler */ static SCIP_DECL_CONSRESPROP(consRespropObj) { /*lint --e{715}*/ SCIP_CONSHDLRDATA* conshdlrdata; conshdlrdata = SCIPconshdlrGetData(conshdlr); assert(conshdlrdata != NULL); assert(conshdlrdata->objconshdlr != NULL); /* call virtual method of conshdlr object */ SCIP_CALL( conshdlrdata->objconshdlr->scip_resprop(scip, conshdlr, cons, infervar, inferinfo, boundtype, bdchgidx, relaxedbd, result) ); return SCIP_OKAY; }
/** exit method of constraint handler (called before problem is free transformed) */ static SCIP_DECL_CONSEXIT(consExitOrigbranch) { /*lint --e{715}*/ SCIP_CONSHDLRDATA* conshdlrdata; assert(conshdlr != NULL); assert(scip != NULL); conshdlrdata = SCIPconshdlrGetData(conshdlr); assert(conshdlrdata != NULL); SCIPdebugMessage("exiting transformed branch orig constraint handler\n"); if( conshdlrdata->rootcons != NULL ) { SCIP_CALL( SCIPreleaseCons(scip, &conshdlrdata->rootcons) ); conshdlrdata->rootcons = NULL; } return SCIP_OKAY; }
/** returns the conshdlr object of the given name, or 0 if not existing */ scip::ObjConshdlr* SCIPfindObjConshdlr( SCIP* scip, /**< SCIP data structure */ const char* name /**< name of constraint handler */ ) { SCIP_CONSHDLR* conshdlr; SCIP_CONSHDLRDATA* conshdlrdata; conshdlr = SCIPfindConshdlr(scip, name); if( conshdlr == NULL ) return 0; conshdlrdata = SCIPconshdlrGetData(conshdlr); assert(conshdlrdata != NULL); return conshdlrdata->objconshdlr; }
/** presolving method of constraint handler */ static SCIP_DECL_CONSPRESOL(consPresolObj) { /*lint --e{715}*/ SCIP_CONSHDLRDATA* conshdlrdata; conshdlrdata = SCIPconshdlrGetData(conshdlr); assert(conshdlrdata != NULL); assert(conshdlrdata->objconshdlr != NULL); /* call virtual method of conshdlr object */ SCIP_CALL( conshdlrdata->objconshdlr->scip_presol(scip, conshdlr, conss, nconss, nrounds, nnewfixedvars, nnewaggrvars, nnewchgvartypes, nnewchgbds, nnewholes, nnewdelconss, nnewaddconss, nnewupgdconss, nnewchgcoefs, nnewchgsides, nfixedvars, naggrvars, nchgvartypes, nchgbds, naddholes, ndelconss, naddconss, nupgdconss, nchgcoefs, nchgsides, result) ); return SCIP_OKAY; }
/** destructor of constraint handler to free constraint handler data (called when SCIP is exiting) */ static SCIP_DECL_CONSFREE(consFreeStp) { /*lint --e{715}*/ SCIP_CONSHDLRDATA* conshdlrdata; assert(scip != NULL); assert(conshdlr != NULL); assert(strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0); /* free constraint handler data */ conshdlrdata = SCIPconshdlrGetData(conshdlr); assert(conshdlrdata != NULL); SCIPfreeMemory(scip, &conshdlrdata); SCIPconshdlrSetData(conshdlr, NULL); return SCIP_OKAY; }
/** solving process deinitialization method of constraint handler (called before branch and bound process data is freed) */ static SCIP_DECL_CONSEXITSOL(consExitsolOrigbranch) { /*lint --e{715}*/ SCIP_CONSHDLRDATA* conshdlrData; assert(scip != NULL); assert(conshdlr != NULL); assert(strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0); conshdlrData = SCIPconshdlrGetData(conshdlr); assert(conshdlrData != NULL); assert(conshdlrData->nstack <= 1); SCIPdebugMessage("exiting solution process branch orig constraint handler\n"); /* free stack */ SCIPfreeMemoryArray(scip, &conshdlrData->stack); conshdlrData->stack = NULL; return SCIP_OKAY; }
/** returns the branch orig constraint of the current node, only needs the pointer to scip */ SCIP_CONS* GCGconsOrigbranchGetActiveCons( SCIP* scip /**< SCIP data structure */ ) { SCIP_CONSHDLR* conshdlr; SCIP_CONSHDLRDATA* conshdlrData; assert(scip != NULL); conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME); if( conshdlr == NULL ) { SCIPerrorMessage("origbranch constraint handler not found\n"); return NULL; } conshdlrData = SCIPconshdlrGetData(conshdlr); assert(conshdlrData != NULL); assert(conshdlrData->stack != NULL); assert(conshdlrData->nstack > 0); return conshdlrData->stack[conshdlrData->nstack-1]; }
/** copy method for constraint handler plugins (called when SCIP copies plugins) */ static SCIP_DECL_CONSHDLRCOPY(conshdlrCopyObj) { /*lint --e{715}*/ SCIP_CONSHDLRDATA* conshdlrdata; assert(scip != NULL); conshdlrdata = SCIPconshdlrGetData(conshdlr); assert(conshdlrdata != NULL); assert(conshdlrdata->objconshdlr != NULL); assert(conshdlrdata->objconshdlr->scip_ != scip); if( conshdlrdata->objconshdlr->iscloneable() ) { scip::ObjConshdlr* newobjconshdlr; newobjconshdlr = dynamic_cast<scip::ObjConshdlr*> (conshdlrdata->objconshdlr->clone(scip, valid)); /* call include method of constraint handler object */ SCIP_CALL( SCIPincludeObjConshdlr(scip, newobjconshdlr, TRUE) ); } return SCIP_OKAY; }
/** destructor of constraint handler to free user data (called when SCIP is exiting) */ static SCIP_DECL_CONSFREE(consFreeObj) { /*lint --e{715}*/ SCIP_CONSHDLRDATA* conshdlrdata; conshdlrdata = SCIPconshdlrGetData(conshdlr); assert(conshdlrdata != NULL); assert(conshdlrdata->objconshdlr != NULL); assert(conshdlrdata->objconshdlr->scip_ == scip); /* call virtual method of conshdlr object */ SCIP_CALL( conshdlrdata->objconshdlr->scip_free(scip, conshdlr) ); /* free conshdlr object */ if( conshdlrdata->deleteobject ) delete conshdlrdata->objconshdlr; /* free conshdlr data */ delete conshdlrdata; SCIPconshdlrSetData(conshdlr, NULL); /*lint !e64*/ return SCIP_OKAY; }