/** adds all constraints in conjunction constraints to the problem; disables unmodifiable conjunction constraints */ static SCIP_RETCODE addAllConss( SCIP* scip, /**< SCIP data structure */ SCIP_CONS** conss, /**< active conjunction constraints */ int nconss, /**< number of active conjunction constraints */ SCIP_RESULT* result /**< pointer to store the result */ ) { SCIP_CONSDATA* consdata; int c; int i; assert(result != NULL); for( c = 0; c < nconss; ++c ) { consdata = SCIPconsGetData(conss[c]); assert(consdata != NULL); /* add all inactive constraints to local subproblem */ for( i = 0; i < consdata->nconss; ++i ) { /* update check flag for sub constraints when upgrade takes place */ if( SCIPconsIsChecked(conss[c]) ) { /* make sure, the constraint is checked for feasibility */ SCIP_CALL( SCIPsetConsChecked(scip, consdata->conss[i], TRUE) ); } if( !SCIPconsIsActive(consdata->conss[i]) ) { SCIPdebugMessage("adding constraint <%s> from add conjunction <%s>\n", SCIPconsGetName(consdata->conss[i]), SCIPconsGetName(conss[c])); SCIP_CALL( SCIPaddConsLocal(scip, consdata->conss[i], NULL) ); *result = SCIP_CONSADDED; } } /* disable conjunction constraint, if it is unmodifiable */ if( !SCIPconsIsModifiable(conss[c]) ) { SCIP_CALL( SCIPdelConsLocal(scip, conss[c]) ); } } return SCIP_OKAY; }
/** propagation method for disjunction constraint */ static SCIP_RETCODE propagateCons( SCIP* scip, /**< SCIP data structure */ SCIP_CONS* cons, /**< knapsack constraint */ int* ndelconss /**< pointer to count number of deleted constraints */ ) { SCIP_CONSDATA* consdata; SCIP_CONS** conss; int nconss; int c; assert(scip != NULL); assert(cons != NULL); assert(ndelconss != NULL); consdata = SCIPconsGetData(cons); assert(consdata != NULL); conss = consdata->conss; assert(conss != NULL); nconss = consdata->nconss; assert(nconss > 1); for( c = 0; c < nconss; ++c ) { if( SCIPconsIsActive(conss[c]) ) { (*ndelconss)++; SCIP_CALL( SCIPdelConsLocal(scip, cons) ); break; } } return SCIP_OKAY; }
/** initializes the pricing problem for the given capacity */ static SCIP_RETCODE initPricing( SCIP* scip, /**< SCIP data structure */ SCIP_PRICERDATA* pricerdata, /**< pricer data */ SCIP* subscip, /**< pricing SCIP data structure */ SCIP_VAR** vars /**< variable array for the items */ ) { SCIP_CONS** conss; SCIP_Longint* vals; SCIP_CONS* cons; SCIP_VAR* var; SCIP_Longint* weights; SCIP_Longint capacity; SCIP_Real dual; int nitems; int nvars; int c; assert( SCIPgetStage(subscip) == SCIP_STAGE_PROBLEM ); assert(pricerdata != NULL); nitems = pricerdata->nitems; conss = pricerdata->conss; weights = pricerdata->weights; capacity = pricerdata->capacity; nvars = 0; SCIP_CALL( SCIPallocBufferArray(subscip, &vals, nitems) ); /* create for each order, which is not assigned yet, a variable with objective coefficient */ for( c = 0; c < nitems; ++c ) { cons = conss[c]; /* check if each constraint is setppc constraint */ assert( !strncmp( SCIPconshdlrGetName( SCIPconsGetHdlr(cons) ), "setppc", 6) ); /* constraints which are (locally) disabled/redundant are not of * interest since the corresponding job is assigned to a packing */ if( !SCIPconsIsEnabled(cons) ) continue; if( SCIPgetNFixedonesSetppc(scip, cons) == 1 ) { /* disable constraint locally */ SCIP_CALL( SCIPdelConsLocal(scip, cons) ); continue; } /* dual value in original SCIP */ dual = SCIPgetDualsolSetppc(scip, cons); SCIP_CALL( SCIPcreateVarBasic(subscip, &var, SCIPconsGetName(cons), 0.0, 1.0, dual, SCIP_VARTYPE_BINARY) ); SCIP_CALL( SCIPaddVar(subscip, var) ); vals[nvars] = weights[c]; vars[nvars] = var; nvars++; /* release variable */ SCIP_CALL( SCIPreleaseVar(subscip, &var) ); } /* create capacity constraint */ SCIP_CALL( SCIPcreateConsBasicKnapsack(subscip, &cons, "capacity", nvars, vars, vals, capacity) ); SCIP_CALL( SCIPaddCons(subscip, cons) ); SCIP_CALL( SCIPreleaseCons(subscip, &cons) ); /* add constraint of the branching decisions */ SCIP_CALL( addBranchingDecisionConss(scip, subscip, vars, pricerdata->conshdlr) ); /* avoid to generate columns which are fixed to zero */ SCIP_CALL( addFixedVarsConss(scip, subscip, vars, conss, nitems) ); SCIPfreeBufferArray(subscip, &vals); return SCIP_OKAY; }