pricer_binpacking.c
Go to the documentation of this file.
21 * This file implements the variable pricer which check if variables exist with negative reduced cost. See 26 * The task of the pricer is to search for new variables with negative reduced costs. For this, the following integer 39 * where \f$ (\lambda_S)_i \f$ for \f$i\in\{1,\dots,n\}\f$ are binary variables and \f$y^\star_i\f$ given by the dual 40 * solution of the restricted master problem. See the \ref PROBLEM "problem description" for more details. 42 * To solve the above integer program, we create a new SCIP instance within SCIP and use the usual functions to create 43 * variables and constraints. Besides, we need the current dual solutions to all set covering constraints (each stands 44 * for one item) which are the objective coefficients of the binary variables. Therefore, we use the function 47 * Since we also want to generate new variables during search, we have to care that we do not generate variables over 48 * and over again. For example, if we branched or fixed a certain packing to zero, we have to make sure that we do not 49 * generate the corresponding variables at that node again. For this, we have to add constraints forbidding to generate 50 * variables which are locally fixed to zero. See the function addFixedVarsConss() for more details. While using the 51 * \ref BRANCHING "Ryan/Foster branching", we also have to ensure that these branching decisions are respected. This is 54 * @note In case of this binpacking example, the master LP should not get infeasible after branching, because of the way 56 * 1. In case of Ryan/Foster branching, the two items are selected in a way such that the sum of the LP values of 57 * all columns/packings containing both items is fractional. Hence, it exists at least one column/packing which 58 * contains both items and also at least one column/packing for each item containing this but not the other 59 * item. That means, branching in the "same" direction stays LP feasible since there exists at least one 60 * column/packing with both items and branching in the "differ" direction stays LP feasible since there exists 62 * 2. In case of variable branching, we only branch on fractional variables. If a variable is fixed to one, there 63 * is no issue. If a variable is fixed to zero, then we know that for each item which is part of that 64 * column/packing, there exists at least one other column/packing containing this particular item due to the 68 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ 92 #define PRICER_DELAY TRUE /* only call pricer if all problem variables have non-negative reduced costs */ 149 /* loop over all branching decision constraints and apply the branching decision if the corresponding constraint is 156 /* ignore constraints which are not active since these are not laying on the current active path of the search 162 /* collect the two item ids and the branching type (SAME or DIFFER) on which the constraint branched */ 168 SCIPprobdataGetIds(SCIPgetProbData(scip))[id1], SCIPprobdataGetIds(SCIPgetProbData(scip))[id2]); 170 /* depending on the branching type select the correct left and right hand side for the linear constraint which 191 /* add linear (in that case a variable bound) constraint to pricing MIP depending on the branching type: 197 * note a setppc constraint would be sufficient and even better suitable for such kind of constraint 211 /** avoid to generate columns which are fixed to zero; therefore add for each variable which is fixed to zero a 214 * @note variable which are fixed locally to zero should not be generated again by the pricing MIP 253 /* if the upper bound is smaller than 0.5 if follows due to the integrality that the binary variable is fixed to zero */ 271 /* loop over these items and create a linear (logicor) constraint which forbids this item combination in the 313 SCIP_CALL( SCIPcreateConsBasicLogicor(subscip, &cons, SCIPvarGetName(origvars[v]), nlogicorvars, logicorvars) ); 383 SCIP_CALL( SCIPcreateVarBasic(subscip, &var, SCIPconsGetName(cons), 0.0, 1.0, dual, SCIP_VARTYPE_BINARY) ); 477 /** solving process deinitialization method of variable pricer (called before branch and bound process data is freed) */ 576 /* loop over all solutions and create the corresponding column to master if the reduced cost are negative for master, 585 assert(s == 0 || SCIPisFeasGE(subscip, SCIPgetSolOrigObj(subscip, sols[s-1]), SCIPgetSolOrigObj(subscip, sols[s]))); 595 SCIPwarningMessage(scip, "solution in pricing problem (capacity <%d>) is infeasible\n", capacity); 649 /* change the upper bound of the binary variable to lazy since the upper bound is already enforced due to 650 * the objective function the set covering constraint; The reason for doing is that, is to avoid the bound 651 * of x <= 1 in the LP relaxation since this bound constraint would produce a dual variable which might have 689 /** @note In case of this binpacking example, the master LP should not get infeasible after branching, because of the 691 * 1. In case of Ryan/Foster branching, the two items are selected in a way such that the sum of the LP values 693 * column/packing which contains both items and also at least one column/packing for each item containing 694 * this but not the other item. That means, branching in the "same" direction stays LP feasible since there 695 * exists at least one column/packing with both items and branching in the "differ" direction stays LP 696 * feasible since there exists at least one column/packing containing one item, but not the other. 697 * 2. In case of variable branching, we only branch on fractional variables. If a variable is fixed to one, 698 * there is no issue. If a variable is fixed to zero, then we know that for each item which is part of 699 * that column/packing, there exists at least one other column/packing containing this particular item due 702 SCIPwarningMessage(scip, "Current master LP is infeasible, but Farkas pricing was not implemented\n"); 737 SCIP_CALL( SCIPincludePricerBasic(scip, &pricer, PRICER_NAME, PRICER_DESC, PRICER_PRIORITY, PRICER_DELAY, SCIP_RETCODE SCIPpricerBinpackingActivate(SCIP *scip, SCIP_CONS **conss, SCIP_Longint *weights, int *ids, int nitems, SCIP_Longint capacity) Definition: pricer_binpacking.c:752 static SCIP_RETCODE addFixedVarsConss(SCIP *scip, SCIP *subscip, SCIP_VAR **vars, SCIP_CONS **conss, int nitems) Definition: pricer_binpacking.c:217 static SCIP_DECL_PRICEREXITSOL(pricerExitsolBinpacking) Definition: pricer_binpacking.c:479 SCIP_RETCODE SCIPincludePricerBinpacking(SCIP *scip) Definition: pricer_binpacking.c:717 Constraint handler stores the local branching decision data. Binpacking variable pricer. Variable data containing the ids of constraints in which the variable appears. int * SCIPvardataGetConsids(SCIP_VARDATA *vardata) Definition: vardata_binpacking.c:124 static SCIP_DECL_PRICERINIT(pricerInitBinpacking) Definition: pricer_binpacking.c:446 SCIP_RETCODE SCIPcreateVarBinpacking(SCIP *scip, SCIP_VAR **var, const char *name, SCIP_Real obj, SCIP_Bool initial, SCIP_Bool removable, SCIP_VARDATA *vardata) Definition: vardata_binpacking.c:142 static SCIP_DECL_PRICERFARKAS(pricerFarkasBinpacking) Definition: pricer_binpacking.c:686 int SCIPgetItemid2Samediff(SCIP *scip, SCIP_CONS *cons) Definition: cons_samediff.c:604 static SCIP_DECL_PRICERFREE(pricerFreeBinpacking) Definition: pricer_binpacking.c:421 SCIP_RETCODE SCIPvardataCreateBinpacking(SCIP *scip, SCIP_VARDATA **vardata, int *consids, int nconsids) Definition: vardata_binpacking.c:103 int * SCIPprobdataGetIds(SCIP_PROBDATA *probdata) Definition: probdata_binpacking.c:431 Definition: cons_samediff.h:37 Problem data for binpacking problem. CONSTYPE SCIPgetTypeSamediff(SCIP *scip, SCIP_CONS *cons) Definition: cons_samediff.c:620 int SCIPgetItemid1Samediff(SCIP *scip, SCIP_CONS *cons) Definition: cons_samediff.c:588 Definition: cons_samediff.h:38 static SCIP_RETCODE addBranchingDecisionConss(SCIP *scip, SCIP *subscip, SCIP_VAR **vars, SCIP_CONSHDLR *conshdlr) Definition: pricer_binpacking.c:121 static SCIP_DECL_PRICERREDCOST(pricerRedcostBinpacking) Definition: pricer_binpacking.c:503 int SCIPvardataGetNConsids(SCIP_VARDATA *vardata) Definition: vardata_binpacking.c:116 static SCIP_RETCODE initPricing(SCIP *scip, SCIP_PRICERDATA *pricerdata, SCIP *subscip, SCIP_VAR **vars) Definition: pricer_binpacking.c:329 |