Scippy

SCIP

Solving Constraint Integer Programs

cons_knapsack.c File Reference

Detailed Description

Constraint handler for knapsack constraints of the form $a^T x \le b$, x binary and $a \ge 0$.

Author
Tobias Achterberg
Xin Liu
Kati Wolter
Michael Winkler

Definition in file cons_knapsack.c.

#include <assert.h>
#include <string.h>
#include <limits.h>
#include <stdio.h>
#include <ctype.h>
#include "scip/cons_knapsack.h"
#include "scip/cons_linear.h"
#include "scip/cons_logicor.h"
#include "scip/cons_setppc.h"
#include "scip/pub_misc.h"

Go to the source code of this file.

Macros

#define CONSHDLR_NAME   "knapsack"
 
#define CONSHDLR_DESC   "knapsack constraint of the form a^T x <= b, x binary and a >= 0"
 
#define CONSHDLR_SEPAPRIORITY   +600000
 
#define CONSHDLR_ENFOPRIORITY   -600000
 
#define CONSHDLR_CHECKPRIORITY   -600000
 
#define CONSHDLR_SEPAFREQ   0
 
#define CONSHDLR_PROPFREQ   1
 
#define CONSHDLR_EAGERFREQ   100
 
#define CONSHDLR_MAXPREROUNDS   -1
 
#define CONSHDLR_DELAYSEPA   FALSE
 
#define CONSHDLR_DELAYPROP   FALSE
 
#define CONSHDLR_DELAYPRESOL   FALSE
 
#define CONSHDLR_NEEDSCONS   TRUE
 
#define CONSHDLR_PROP_TIMING   SCIP_PROPTIMING_BEFORELP
 
#define EVENTHDLR_NAME   "knapsack"
 
#define EVENTHDLR_DESC   "bound change event handler for knapsack constraints"
 
#define LINCONSUPGD_PRIORITY   +100000
 
#define MAX_USECLIQUES_SIZE   1000
 
#define MAX_ZEROITEMS_SIZE   10000
 
#define KNAPSACKRELAX_MAXDELTA   0.1
 
#define KNAPSACKRELAX_MAXDNOM   1000LL
 
#define KNAPSACKRELAX_MAXSCALE   1000.0
 
#define DEFAULT_SEPACARDFREQ   1
 
#define DEFAULT_MAXROUNDS   5
 
#define DEFAULT_MAXROUNDSROOT   -1
 
#define DEFAULT_MAXSEPACUTS   50
 
#define DEFAULT_MAXSEPACUTSROOT   200
 
#define DEFAULT_MAXCARDBOUNDDIST   0.0
 
#define DEFAULT_DISAGGREGATION   TRUE
 
#define DEFAULT_SIMPLIFYINEQUALITIES   TRUE
 
#define DEFAULT_NEGATEDCLIQUE   TRUE
 
#define MAXABSVBCOEF   1e+5
 
#define USESUPADDLIFT   FALSE
 
#define DEFAULT_PRESOLUSEHASHING   TRUE
 
#define HASHSIZE_KNAPSACKCONS   131101
 
#define DEFAULT_PRESOLPAIRWISE   TRUE
 
#define NMINCOMPARISONS   200000
 
#define MINGAINPERNMINCOMPARISONS   1e-06
 
#define DEFAULT_DUALPRESOLVING   TRUE
 
#define DEFAULT_DETECTCUTOFFBOUND   TRUE
 
#define DEFAULT_DETECTLOWERBOUND   TRUE
 
#define MAXCOVERSIZEITERLEWI   1000
 
#define DEFAULT_USEGUBS   FALSE
 
#define GUBCONSGROWVALUE   6
 
#define GUBSPLITGNC1GUBS   FALSE
 
#define IDX(j, d)   ((j)*(intcap)+(d))
 
#define MAXNCLIQUEVARSCOMP   1000000
 
#define MAX_CLIQUELENGTH   50
 

Typedefs

typedef struct sortkeypair SORTKEYPAIR
 
typedef enum GUBVarstatus GUBVARSTATUS
 
typedef enum GUBConsstatus GUBCONSSTATUS
 
typedef struct SCIP_GUBCons SCIP_GUBCONS
 
typedef struct SCIP_GUBSet SCIP_GUBSET
 

Enumerations

enum  GUBVarstatus {
  GUBVARSTATUS_UNINITIAL = -1,
  GUBVARSTATUS_CAPACITYEXCEEDED = 0,
  GUBVARSTATUS_BELONGSTOSET_R = 1,
  GUBVARSTATUS_BELONGSTOSET_F = 2,
  GUBVARSTATUS_BELONGSTOSET_C2 = 3,
  GUBVARSTATUS_BELONGSTOSET_C1 = 4
}
 
enum  GUBConsstatus {
  GUBCONSSTATUS_UNINITIAL = -1,
  GUBCONSSTATUS_BELONGSTOSET_GR = 0,
  GUBCONSSTATUS_BELONGSTOSET_GF = 1,
  GUBCONSSTATUS_BELONGSTOSET_GC2 = 2,
  GUBCONSSTATUS_BELONGSTOSET_GNC1 = 3,
  GUBCONSSTATUS_BELONGSTOSET_GOC1 = 4
}
 

Functions

static SCIP_DECL_SORTPTRCOMP (compSortkeypairs)
 
static SCIP_RETCODE eventdataCreate (SCIP *scip, SCIP_EVENTDATA **eventdata, SCIP_CONSDATA *consdata, SCIP_Longint weight)
 
static SCIP_RETCODE eventdataFree (SCIP *scip, SCIP_EVENTDATA **eventdata)
 
static void sortItems (SCIP_CONSDATA *consdata)
 
static SCIP_RETCODE calcCliquepartition (SCIP *scip, SCIP_CONSDATA *consdata, SCIP_Bool normalclique, SCIP_Bool negatedclique)
 
static SCIP_RETCODE lockRounding (SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var)
 
static SCIP_RETCODE unlockRounding (SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var)
 
static SCIP_RETCODE catchEvents (SCIP *scip, SCIP_CONSDATA *consdata, SCIP_EVENTHDLR *eventhdlr)
 
static SCIP_RETCODE dropEvents (SCIP *scip, SCIP_CONSDATA *consdata, SCIP_EVENTHDLR *eventhdlr)
 
static SCIP_RETCODE consdataEnsureVarsSize (SCIP *scip, SCIP_CONSDATA *consdata, int num, SCIP_Bool transformed)
 
static SCIP_RETCODE consdataCreate (SCIP *scip, SCIP_CONSDATA **consdata, SCIP_EVENTHDLR *eventhdlr, int nvars, SCIP_VAR **vars, SCIP_Longint *weights, SCIP_Longint capacity)
 
static SCIP_RETCODE consdataFree (SCIP *scip, SCIP_CONSDATA **consdata, SCIP_EVENTHDLR *eventhdlr)
 
static void consdataChgWeight (SCIP_CONSDATA *consdata, int item, SCIP_Longint newweight)
 
static SCIP_RETCODE createRelaxation (SCIP *scip, SCIP_CONS *cons)
 
static SCIP_RETCODE addRelaxation (SCIP *scip, SCIP_CONS *cons, SCIP_SOL *sol, SCIP_Bool *cutoff)
 
static SCIP_RETCODE checkCons (SCIP *scip, SCIP_CONS *cons, SCIP_SOL *sol, SCIP_Bool checklprows, SCIP_Bool printreason, SCIP_Bool *violated)
 
SCIP_RETCODE SCIPsolveKnapsackExactly (SCIP *scip, int nitems, SCIP_Longint *weights, SCIP_Real *profits, SCIP_Longint capacity, int *items, int *solitems, int *nonsolitems, int *nsolitems, int *nnonsolitems, SCIP_Real *solval, SCIP_Bool *success)
 
SCIP_RETCODE SCIPsolveKnapsackApproximately (SCIP *scip, int nitems, SCIP_Longint *weights, SCIP_Real *profits, SCIP_Longint capacity, int *items, int *solitems, int *nonsolitems, int *nsolitems, int *nnonsolitems, SCIP_Real *solval)
 
static SCIP_Bool checkSolveKnapsack (SCIP *scip, int nitems, SCIP_Longint *transweights, SCIP_Real *transprofits, int *items, SCIP_Longint *weights, SCIP_Real *solvals, SCIP_Bool modtransused)
 
static SCIP_RETCODE GUBconsCreate (SCIP *scip, SCIP_GUBCONS **gubcons)
 
static SCIP_RETCODE GUBconsFree (SCIP *scip, SCIP_GUBCONS **gubcons)
 
static SCIP_RETCODE GUBconsAddVar (SCIP *scip, SCIP_GUBCONS *gubcons, int var)
 
static SCIP_RETCODE GUBconsDelVar (SCIP *scip, SCIP_GUBCONS *gubcons, int var, int gubvarsidx)
 
static SCIP_RETCODE GUBsetMoveVar (SCIP *scip, SCIP_GUBSET *gubset, SCIP_VAR **vars, int var, int oldgubcons, int newgubcons)
 
static void GUBsetSwapVars (SCIP *scip, SCIP_GUBSET *gubset, int var1, int var2)
 
static SCIP_RETCODE GUBsetCreate (SCIP *scip, SCIP_GUBSET **gubset, int nvars, SCIP_Longint *weights, SCIP_Longint capacity)
 
static SCIP_RETCODE GUBsetFree (SCIP *scip, SCIP_GUBSET **gubset)
 
static SCIP_RETCODE GUBsetCheck (SCIP *scip, SCIP_GUBSET *gubset, SCIP_VAR **vars)
 
static SCIP_RETCODE GUBsetCalcCliquePartition (SCIP *const scip, SCIP_VAR **const vars, int const nvars, int *const cliquepartition, int *const ncliques, SCIP_Real *solvals)
 
static SCIP_RETCODE GUBsetGetCliquePartition (SCIP *scip, SCIP_GUBSET *gubset, SCIP_VAR **vars, SCIP_Real *solvals)
 
static SCIP_RETCODE getCover (SCIP *scip, SCIP_VAR **vars, int nvars, SCIP_Longint *weights, SCIP_Longint capacity, SCIP_Real *solvals, int *covervars, int *noncovervars, int *ncovervars, int *nnoncovervars, SCIP_Longint *coverweight, SCIP_Bool *found, SCIP_Bool modtransused, int *ntightened, SCIP_Bool *fractional)
 
static SCIP_Bool checkMinweightidx (SCIP_Longint *weights, SCIP_Longint capacity, int *covervars, int ncovervars, SCIP_Longint coverweight, int minweightidx, int j)
 
static void getPartitionCovervars (SCIP *scip, SCIP_Real *solvals, int *covervars, int ncovervars, int *varsC1, int *varsC2, int *nvarsC1, int *nvarsC2)
 
static SCIP_RETCODE changePartitionCovervars (SCIP *scip, SCIP_Longint *weights, int *varsC1, int *varsC2, int *nvarsC1, int *nvarsC2)
 
static SCIP_RETCODE changePartitionFeasiblesetvars (SCIP *scip, SCIP_Longint *weights, int *varsC1, int *varsC2, int *nvarsC1, int *nvarsC2)
 
static void getPartitionNoncovervars (SCIP *scip, SCIP_Real *solvals, int *noncovervars, int nnoncovervars, int *varsF, int *varsR, int *nvarsF, int *nvarsR)
 
static SCIP_RETCODE getLiftingSequence (SCIP *scip, SCIP_Real *solvals, SCIP_Longint *weights, int *varsF, int *varsC2, int *varsR, int nvarsF, int nvarsC2, int nvarsR)
 
static SCIP_RETCODE getLiftingSequenceGUB (SCIP *scip, SCIP_GUBSET *gubset, SCIP_Real *solvals, SCIP_Longint *weights, int *varsC1, int *varsC2, int *varsF, int *varsR, int nvarsC1, int nvarsC2, int nvarsF, int nvarsR, int *gubconsGC1, int *gubconsGC2, int *gubconsGFC1, int *gubconsGR, int *ngubconsGC1, int *ngubconsGC2, int *ngubconsGFC1, int *ngubconsGR, int *ngubconscapexceed, int *maxgubvarssize)
 
static SCIP_RETCODE enlargeMinweights (SCIP *scip, SCIP_Longint **minweightsptr, int *minweightslen, int *minweightssize, int newlen)
 
static SCIP_RETCODE sequentialUpAndDownLifting (SCIP *scip, SCIP_VAR **vars, int nvars, int ntightened, SCIP_Longint *weights, SCIP_Longint capacity, SCIP_Real *solvals, int *varsM1, int *varsM2, int *varsF, int *varsR, int nvarsM1, int nvarsM2, int nvarsF, int nvarsR, int alpha0, int *liftcoefs, SCIP_Real *cutact, int *liftrhs)
 
static SCIP_Longint safeAddMinweightsGUB (SCIP_Longint val1, SCIP_Longint val2)
 
static void computeMinweightsGUB (SCIP_Longint *minweights, SCIP_Longint *finished, SCIP_Longint *unfinished, int minweightslen)
 
static SCIP_RETCODE sequentialUpAndDownLiftingGUB (SCIP *scip, SCIP_GUBSET *gubset, SCIP_VAR **vars, int ngubconscapexceed, SCIP_Longint *weights, SCIP_Longint capacity, SCIP_Real *solvals, int *gubconsGC1, int *gubconsGC2, int *gubconsGFC1, int *gubconsGR, int ngubconsGC1, int ngubconsGC2, int ngubconsGFC1, int ngubconsGR, int alpha0, int *liftcoefs, SCIP_Real *cutact, int *liftrhs, int maxgubvarssize)
 
static SCIP_RETCODE superadditiveUpLifting (SCIP *scip, SCIP_VAR **vars, int nvars, int ntightened, SCIP_Longint *weights, SCIP_Longint capacity, SCIP_Real *solvals, int *covervars, int *noncovervars, int ncovervars, int nnoncovervars, SCIP_Longint coverweight, SCIP_Real *liftcoefs, SCIP_Real *cutact)
 
static SCIP_RETCODE separateSequLiftedMinimalCoverInequality (SCIP *scip, SCIP_CONS *cons, SCIP_SEPA *sepa, SCIP_VAR **vars, int nvars, int ntightened, SCIP_Longint *weights, SCIP_Longint capacity, SCIP_Real *solvals, int *mincovervars, int *nonmincovervars, int nmincovervars, int nnonmincovervars, SCIP_SOL *sol, SCIP_GUBSET *gubset, SCIP_Bool *cutoff, int *ncuts)
 
static SCIP_RETCODE separateSequLiftedExtendedWeightInequality (SCIP *scip, SCIP_CONS *cons, SCIP_SEPA *sepa, SCIP_VAR **vars, int nvars, int ntightened, SCIP_Longint *weights, SCIP_Longint capacity, SCIP_Real *solvals, int *feassetvars, int *nonfeassetvars, int nfeassetvars, int nnonfeassetvars, SCIP_SOL *sol, SCIP_Bool *cutoff, int *ncuts)
 
static SCIP_RETCODE separateSupLiftedMinimalCoverInequality (SCIP *scip, SCIP_CONS *cons, SCIP_SEPA *sepa, SCIP_VAR **vars, int nvars, int ntightened, SCIP_Longint *weights, SCIP_Longint capacity, SCIP_Real *solvals, int *mincovervars, int *nonmincovervars, int nmincovervars, int nnonmincovervars, SCIP_Longint mincoverweight, SCIP_SOL *sol, SCIP_Bool *cutoff, int *ncuts)
 
static SCIP_RETCODE makeCoverMinimal (SCIP *scip, SCIP_Longint *weights, SCIP_Longint capacity, SCIP_Real *solvals, int *covervars, int *noncovervars, int *ncovervars, int *nnoncovervars, SCIP_Longint *coverweight, SCIP_Bool modtransused)
 
static SCIP_RETCODE getFeasibleSet (SCIP *scip, SCIP_CONS *cons, SCIP_SEPA *sepa, SCIP_VAR **vars, int nvars, int ntightened, SCIP_Longint *weights, SCIP_Longint capacity, SCIP_Real *solvals, int *covervars, int *noncovervars, int *ncovervars, int *nnoncovervars, SCIP_Longint *coverweight, SCIP_Bool modtransused, SCIP_SOL *sol, SCIP_Bool *cutoff, int *ncuts)
 
SCIP_RETCODE SCIPseparateKnapsackCuts (SCIP *scip, SCIP_CONS *cons, SCIP_SEPA *sepa, SCIP_VAR **vars, int nvars, SCIP_Longint *weights, SCIP_Longint capacity, SCIP_SOL *sol, SCIP_Bool usegubs, SCIP_Bool *cutoff, int *ncuts)
 
SCIP_RETCODE SCIPseparateRelaxedKnapsack (SCIP *scip, SCIP_CONS *cons, SCIP_SEPA *sepa, int nknapvars, SCIP_VAR **knapvars, SCIP_Real *knapvals, SCIP_Real valscale, SCIP_Real rhs, SCIP_SOL *sol, SCIP_Bool *cutoff, int *ncuts)
 
static SCIP_RETCODE separateCons (SCIP *scip, SCIP_CONS *cons, SCIP_SOL *sol, SCIP_Bool sepacuts, SCIP_Bool usegubs, SCIP_Bool *cutoff, int *ncuts)
 
static SCIP_RETCODE addCoef (SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Longint weight)
 
static SCIP_RETCODE delCoefPos (SCIP *scip, SCIP_CONS *cons, int pos)
 
static SCIP_RETCODE removeZeroWeights (SCIP *scip, SCIP_CONS *cons)
 
static SCIP_RETCODE performVarDeletions (SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_CONS **conss, int nconss)
 
static SCIP_RETCODE mergeMultiples (SCIP *scip, SCIP_CONS *cons, SCIP_Bool *cutoff)
 
static SCIP_RETCODE dualPresolving (SCIP *scip, SCIP_CONS *cons, int *nfixedvars, int *ndelconss, SCIP_Bool *deleted)
 
static SCIP_RETCODE checkParallelObjective (SCIP *scip, SCIP_CONS *cons, SCIP_CONSHDLRDATA *conshdlrdata)
 
static SCIP_RETCODE stableSort (SCIP *scip, SCIP_CONSDATA *consdata, SCIP_VAR **vars, SCIP_Longint *weights, int *cliquestartposs, SCIP_Bool usenegatedclique)
 
static SCIP_RETCODE propagateCons (SCIP *scip, SCIP_CONS *cons, SCIP_Bool *cutoff, SCIP_Bool *redundant, int *nfixedvars, SCIP_Bool usenegatedclique)
 
static SCIP_RETCODE upgradeCons (SCIP *scip, SCIP_CONS *cons, int *ndelconss, int *naddconss)
 
static SCIP_RETCODE deleteRedundantVars (SCIP *scip, SCIP_CONS *cons, SCIP_Longint frontsum, int splitpos, int *nchgcoefs, int *nchgsides, int *naddconss)
 
static SCIP_RETCODE detectRedundantVars (SCIP *scip, SCIP_CONS *cons, int *ndelconss, int *nchgcoefs, int *nchgsides, int *naddconss)
 
static void normalizeWeights (SCIP_CONS *cons, int *nchgcoefs, int *nchgsides)
 
static SCIP_RETCODE dualWeightsTightening (SCIP *scip, SCIP_CONS *cons, int *ndelconss, int *nchgcoefs, int *nchgsides, int *naddconss)
 
static SCIP_RETCODE prepareCons (SCIP *scip, SCIP_CONS *cons, int *nfixedvars, int *ndelconss, int *nchgcoefs)
 
static SCIP_RETCODE simplifyInequalities (SCIP *scip, SCIP_CONS *cons, int *nfixedvars, int *ndelconss, int *nchgcoefs, int *nchgsides, int *naddconss, SCIP_Bool *cutoff)
 
static SCIP_RETCODE applyFixings (SCIP *scip, SCIP_CONS *cons, SCIP_Bool *cutoff)
 
static SCIP_RETCODE insertZerolist (SCIP *scip, int **liftcands, int *nliftcands, int **firstidxs, SCIP_Longint **zeroweightsums, int **zeroitems, int **nextidxs, int *zeroitemssize, int *nzeroitems, int probindex, SCIP_Bool value, int knapsackidx, SCIP_Longint knapsackweight, SCIP_Bool *memlimitreached)
 
static SCIP_RETCODE tightenWeightsLift (SCIP *scip, SCIP_CONS *cons, int *nchgcoefs, SCIP_Bool *cutoff)
 
static SCIP_RETCODE tightenWeights (SCIP *scip, SCIP_CONS *cons, int *nchgcoefs, int *nchgsides, int *naddconss, int *ndelconss, SCIP_Bool *cutoff)
 
static SCIP_RETCODE addNegatedCliques (SCIP *const scip, SCIP_CONS *const cons, SCIP_Bool *const cutoff, int *const nbdchgs)
 
static SCIP_RETCODE addCliques (SCIP *const scip, SCIP_CONS *const cons, SCIP_Bool *const cutoff, int *const nbdchgs)
 
static SCIP_DECL_HASHGETKEY (hashGetKeyKnapsackcons)
 
static SCIP_DECL_HASHKEYEQ (hashKeyEqKnapsackcons)
 
static SCIP_DECL_HASHKEYVAL (hashKeyValKnapsackcons)
 
static SCIP_RETCODE detectRedundantConstraints (SCIP *scip, BMS_BLKMEM *blkmem, SCIP_CONS **conss, int nconss, SCIP_Bool *cutoff, int *ndelconss)
 
static SCIP_RETCODE preprocessConstraintPairs (SCIP *scip, SCIP_CONS **conss, int firstchange, int chkind, int *ndelconss)
 
static SCIP_RETCODE createNormalizedKnapsack (SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *vals, SCIP_Real lhs, SCIP_Real rhs, 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)
 
static SCIP_DECL_LINCONSUPGD (linconsUpgdKnapsack)
 
static SCIP_DECL_CONSHDLRCOPY (conshdlrCopyKnapsack)
 
static SCIP_DECL_CONSFREE (consFreeKnapsack)
 
static SCIP_DECL_CONSINIT (consInitKnapsack)
 
static SCIP_DECL_CONSEXIT (consExitKnapsack)
 
static SCIP_DECL_CONSINITPRE (consInitpreKnapsack)
 
static SCIP_DECL_CONSEXITPRE (consExitpreKnapsack)
 
static SCIP_DECL_CONSEXITSOL (consExitsolKnapsack)
 
static SCIP_DECL_CONSDELETE (consDeleteKnapsack)
 
static SCIP_DECL_CONSTRANS (consTransKnapsack)
 
static SCIP_DECL_CONSINITLP (consInitlpKnapsack)
 
static SCIP_DECL_CONSSEPALP (consSepalpKnapsack)
 
static SCIP_DECL_CONSSEPASOL (consSepasolKnapsack)
 
static SCIP_DECL_CONSENFOLP (consEnfolpKnapsack)
 
static SCIP_DECL_CONSENFOPS (consEnfopsKnapsack)
 
static SCIP_DECL_CONSCHECK (consCheckKnapsack)
 
static SCIP_DECL_CONSPROP (consPropKnapsack)
 
static SCIP_DECL_CONSPRESOL (consPresolKnapsack)
 
static SCIP_DECL_CONSRESPROP (consRespropKnapsack)
 
static SCIP_DECL_CONSLOCK (consLockKnapsack)
 
static SCIP_DECL_CONSDELVARS (consDelvarsKnapsack)
 
static SCIP_DECL_CONSPRINT (consPrintKnapsack)
 
static SCIP_DECL_CONSCOPY (consCopyKnapsack)
 
static SCIP_DECL_CONSPARSE (consParseKnapsack)
 
static SCIP_DECL_CONSGETVARS (consGetVarsKnapsack)
 
static SCIP_DECL_CONSGETNVARS (consGetNVarsKnapsack)
 
static SCIP_DECL_EVENTEXEC (eventExecKnapsack)
 
SCIP_RETCODE SCIPincludeConshdlrKnapsack (SCIP *scip)
 
SCIP_RETCODE SCIPcreateConsKnapsack (SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Longint *weights, SCIP_Longint capacity, 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 SCIPcreateConsBasicKnapsack (SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Longint *weights, SCIP_Longint capacity)
 
SCIP_RETCODE SCIPaddCoefKnapsack (SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Longint weight)
 
SCIP_Longint SCIPgetCapacityKnapsack (SCIP *scip, SCIP_CONS *cons)
 
SCIP_RETCODE SCIPchgCapacityKnapsack (SCIP *scip, SCIP_CONS *cons, SCIP_Longint capacity)
 
int SCIPgetNVarsKnapsack (SCIP *scip, SCIP_CONS *cons)
 
SCIP_VAR ** SCIPgetVarsKnapsack (SCIP *scip, SCIP_CONS *cons)
 
SCIP_LongintSCIPgetWeightsKnapsack (SCIP *scip, SCIP_CONS *cons)
 
SCIP_Real SCIPgetDualsolKnapsack (SCIP *scip, SCIP_CONS *cons)
 
SCIP_Real SCIPgetDualfarkasKnapsack (SCIP *scip, SCIP_CONS *cons)
 
SCIP_ROWSCIPgetRowKnapsack (SCIP *scip, SCIP_CONS *cons)
 

Macro Definition Documentation

#define CONSHDLR_DESC   "knapsack constraint of the form a^T x <= b, x binary and a >= 0"

Definition at line 40 of file cons_knapsack.c.

Referenced by SCIPincludeConshdlrKnapsack().

#define CONSHDLR_SEPAPRIORITY   +600000

priority of the constraint handler for separation

Definition at line 41 of file cons_knapsack.c.

Referenced by SCIPincludeConshdlrKnapsack().

#define CONSHDLR_ENFOPRIORITY   -600000

priority of the constraint handler for constraint enforcing

Definition at line 42 of file cons_knapsack.c.

Referenced by SCIPincludeConshdlrKnapsack().

#define CONSHDLR_CHECKPRIORITY   -600000

priority of the constraint handler for checking feasibility

Definition at line 43 of file cons_knapsack.c.

Referenced by SCIPincludeConshdlrKnapsack().

#define CONSHDLR_SEPAFREQ   0

frequency for separating cuts; zero means to separate only in the root node

Definition at line 44 of file cons_knapsack.c.

Referenced by SCIPincludeConshdlrKnapsack().

#define CONSHDLR_PROPFREQ   1

frequency for propagating domains; zero means only preprocessing propagation

Definition at line 45 of file cons_knapsack.c.

Referenced by SCIPincludeConshdlrKnapsack().

#define CONSHDLR_EAGERFREQ   100

frequency for using all instead of only the useful constraints in separation, propagation and enforcement, -1 for no eager evaluations, 0 for first only

Definition at line 46 of file cons_knapsack.c.

Referenced by SCIPincludeConshdlrKnapsack().

#define CONSHDLR_MAXPREROUNDS   -1

maximal number of presolving rounds the constraint handler participates in (-1: no limit)

Definition at line 48 of file cons_knapsack.c.

Referenced by SCIPincludeConshdlrKnapsack().

#define CONSHDLR_DELAYSEPA   FALSE

should separation method be delayed, if other separators found cuts?

Definition at line 49 of file cons_knapsack.c.

Referenced by SCIPincludeConshdlrKnapsack().

#define CONSHDLR_DELAYPROP   FALSE

should propagation method be delayed, if other propagators found reductions?

Definition at line 50 of file cons_knapsack.c.

Referenced by SCIPincludeConshdlrKnapsack().

#define CONSHDLR_DELAYPRESOL   FALSE

should presolving method be delayed, if other presolvers found reductions?

Definition at line 51 of file cons_knapsack.c.

Referenced by SCIPincludeConshdlrKnapsack().

#define CONSHDLR_NEEDSCONS   TRUE

should the constraint handler be skipped, if no constraints are available?

Definition at line 52 of file cons_knapsack.c.

Referenced by SCIPincludeConshdlrKnapsack().

#define CONSHDLR_PROP_TIMING   SCIP_PROPTIMING_BEFORELP

Definition at line 54 of file cons_knapsack.c.

Referenced by SCIPincludeConshdlrKnapsack().

#define EVENTHDLR_NAME   "knapsack"

Definition at line 56 of file cons_knapsack.c.

Referenced by SCIPincludeConshdlrKnapsack().

#define EVENTHDLR_DESC   "bound change event handler for knapsack constraints"

Definition at line 57 of file cons_knapsack.c.

Referenced by SCIPincludeConshdlrKnapsack().

#define LINCONSUPGD_PRIORITY   +100000

priority of the constraint handler for upgrading of linear constraints

Definition at line 59 of file cons_knapsack.c.

Referenced by SCIPincludeConshdlrKnapsack().

#define MAX_USECLIQUES_SIZE   1000

maximal number of items in knapsack where clique information is used

Definition at line 65 of file cons_knapsack.c.

Referenced by tightenWeights(), and tightenWeightsLift().

#define MAX_ZEROITEMS_SIZE   10000

maximal number of items to store in the zero list in preprocessing

Definition at line 66 of file cons_knapsack.c.

Referenced by insertZerolist(), and tightenWeightsLift().

#define KNAPSACKRELAX_MAXDELTA   0.1

maximal allowed rounding distance for scaling in knapsack relaxation

Definition at line 68 of file cons_knapsack.c.

Referenced by SCIPseparateRelaxedKnapsack().

#define KNAPSACKRELAX_MAXDNOM   1000LL

maximal allowed denominator in knapsack rational relaxation

Definition at line 69 of file cons_knapsack.c.

Referenced by SCIPseparateRelaxedKnapsack().

#define KNAPSACKRELAX_MAXSCALE   1000.0

maximal allowed scaling factor in knapsack rational relaxation

Definition at line 70 of file cons_knapsack.c.

Referenced by SCIPseparateRelaxedKnapsack().

#define DEFAULT_SEPACARDFREQ   1

multiplier on separation frequency, how often knapsack cuts are separated

Definition at line 72 of file cons_knapsack.c.

Referenced by SCIPincludeConshdlrKnapsack().

#define DEFAULT_MAXROUNDS   5

maximal number of separation rounds per node (-1: unlimited)

Definition at line 73 of file cons_knapsack.c.

Referenced by SCIPincludeConshdlrKnapsack().

#define DEFAULT_MAXROUNDSROOT   -1

maximal number of separation rounds in the root node (-1: unlimited)

Definition at line 74 of file cons_knapsack.c.

Referenced by SCIPincludeConshdlrKnapsack().

#define DEFAULT_MAXSEPACUTS   50

maximal number of cuts separated per separation round

Definition at line 75 of file cons_knapsack.c.

Referenced by SCIPincludeConshdlrKnapsack().

#define DEFAULT_MAXSEPACUTSROOT   200

maximal number of cuts separated per separation round in the root node

Definition at line 76 of file cons_knapsack.c.

Referenced by SCIPincludeConshdlrKnapsack().

#define DEFAULT_MAXCARDBOUNDDIST   0.0

maximal relative distance from current node's dual bound to primal bound compared to best node's dual bound for separating knapsack cuts

Definition at line 77 of file cons_knapsack.c.

Referenced by SCIPincludeConshdlrKnapsack().

#define DEFAULT_DISAGGREGATION   TRUE

should disaggregation of knapsack constraints be allowed in preprocessing?

Definition at line 79 of file cons_knapsack.c.

Referenced by SCIPincludeConshdlrKnapsack().

#define DEFAULT_SIMPLIFYINEQUALITIES   TRUE

should presolving try to simplify knapsacks

Definition at line 80 of file cons_knapsack.c.

Referenced by SCIPincludeConshdlrKnapsack().

#define DEFAULT_NEGATEDCLIQUE   TRUE

should negated clique information be used in solving process

Definition at line 81 of file cons_knapsack.c.

Referenced by SCIPincludeConshdlrKnapsack().

#define MAXABSVBCOEF   1e+5

maximal absolute coefficient in variable bounds used for knapsack relaxation

Definition at line 83 of file cons_knapsack.c.

Referenced by SCIPseparateRelaxedKnapsack().

#define USESUPADDLIFT   FALSE

should lifted minimal cover inequalities using superadditive up-lifting be separated in addition

Definition at line 84 of file cons_knapsack.c.

Referenced by SCIPseparateKnapsackCuts().

#define DEFAULT_PRESOLUSEHASHING   TRUE

should hash table be used for detecting redundant constraints in advance

Definition at line 86 of file cons_knapsack.c.

Referenced by SCIPincludeConshdlrKnapsack().

#define HASHSIZE_KNAPSACKCONS   131101

minimal size of hash table in linear constraint tables

Definition at line 87 of file cons_knapsack.c.

Referenced by detectRedundantConstraints().

#define DEFAULT_PRESOLPAIRWISE   TRUE

should pairwise constraint comparison be performed in presolving?

Definition at line 89 of file cons_knapsack.c.

Referenced by SCIPincludeConshdlrKnapsack().

#define NMINCOMPARISONS   200000

number for minimal pairwise presolving comparisons

Definition at line 90 of file cons_knapsack.c.

Referenced by SCIP_DECL_CONSPRESOL().

#define MINGAINPERNMINCOMPARISONS   1e-06

minimal gain per minimal pairwise presolving comparisons to repeat pairwise comparison round

Definition at line 91 of file cons_knapsack.c.

Referenced by SCIP_DECL_CONSPRESOL().

#define DEFAULT_DUALPRESOLVING   TRUE

should dual presolving steps be performed?

Definition at line 93 of file cons_knapsack.c.

Referenced by SCIPincludeConshdlrKnapsack().

#define DEFAULT_DETECTCUTOFFBOUND   TRUE

should presolving try to detect constraints parallel to the objective function defining an upper bound and prevent these constraints from entering the LP

Definition at line 94 of file cons_knapsack.c.

Referenced by SCIPincludeConshdlrKnapsack().

#define DEFAULT_DETECTLOWERBOUND   TRUE

should presolving try to detect constraints parallel to the objective function defining a lower bound and prevent these constraints from entering the LP

Definition at line 97 of file cons_knapsack.c.

Referenced by SCIPincludeConshdlrKnapsack().

#define MAXCOVERSIZEITERLEWI   1000

maximal size for which LEWI are iteratively separated by reducing the feasible set

Definition at line 101 of file cons_knapsack.c.

Referenced by getFeasibleSet().

#define DEFAULT_USEGUBS   FALSE

should GUB information be used for separation?

Definition at line 103 of file cons_knapsack.c.

Referenced by SCIPincludeConshdlrKnapsack(), and SCIPseparateRelaxedKnapsack().

#define GUBCONSGROWVALUE   6

memory growing value for GUB constraint array

Definition at line 104 of file cons_knapsack.c.

Referenced by GUBconsAddVar(), GUBconsCreate(), and GUBconsDelVar().

#define GUBSPLITGNC1GUBS   FALSE

should GNC1 GUB conss without F vars be split into GOC1 and GR GUB conss?

Definition at line 105 of file cons_knapsack.c.

#define IDX (   j,
 
)    ((j)*(intcap)+(d))

Definition at line 935 of file cons_knapsack.c.

Referenced by SCIPsolveKnapsackExactly().

#define MAXNCLIQUEVARSCOMP   1000000

calculates a partition of the given set of binary variables into cliques; afterwards the output array contains one value for each variable, such that two variables got the same value iff they were assigned to the same clique; the first variable is always assigned to clique 0, and a variable can only be assigned to clique i if at least one of the preceding variables was assigned to clique i-1; note: in contrast to SCIPcalcCliquePartition(), variables with LP value 1 are put into trivial cliques (with one variable) and for the remaining variables, a partition with a small number of cliques is constructed

Definition at line 2082 of file cons_knapsack.c.

Referenced by GUBsetCalcCliquePartition().

#define MAX_CLIQUELENGTH   50

Definition at line 9612 of file cons_knapsack.c.

Referenced by tightenWeightsLift().

Typedef Documentation

typedef struct sortkeypair SORTKEYPAIR

Definition at line 211 of file cons_knapsack.c.

typedef enum GUBVarstatus GUBVARSTATUS

Definition at line 223 of file cons_knapsack.c.

Definition at line 235 of file cons_knapsack.c.

typedef struct SCIP_GUBCons SCIP_GUBCONS

Definition at line 245 of file cons_knapsack.c.

typedef struct SCIP_GUBSet SCIP_GUBSET

Definition at line 257 of file cons_knapsack.c.

Enumeration Type Documentation

status of GUB constraint

Enumerator:
GUBVARSTATUS_UNINITIAL 
GUBVARSTATUS_CAPACITYEXCEEDED 

unintitialized variable status

GUBVARSTATUS_BELONGSTOSET_R 

variable with weight exceeding the knapsack capacity

GUBVARSTATUS_BELONGSTOSET_F 

variable in noncovervars R

GUBVARSTATUS_BELONGSTOSET_C2 

variable in noncovervars F

GUBVARSTATUS_BELONGSTOSET_C1 

variable in covervars C2

Definition at line 214 of file cons_knapsack.c.

status of variable in GUB constraint

Enumerator:
GUBCONSSTATUS_UNINITIAL 
GUBCONSSTATUS_BELONGSTOSET_GR 

unintitialized GUB constraint status

GUBCONSSTATUS_BELONGSTOSET_GF 

all GUB variables are in noncovervars R

GUBCONSSTATUS_BELONGSTOSET_GC2 

all GUB variables are in noncovervars F (and noncovervars R)

GUBCONSSTATUS_BELONGSTOSET_GNC1 

all GUB variables are in covervars C2

GUBCONSSTATUS_BELONGSTOSET_GOC1 

some GUB variables are in covervars C1, others in noncovervars R or F

Definition at line 226 of file cons_knapsack.c.

Function Documentation

static SCIP_DECL_SORTPTRCOMP ( compSortkeypairs  )
static

comparison method for two sorting key pairs

Definition at line 265 of file cons_knapsack.c.

static SCIP_RETCODE eventdataCreate ( SCIP scip,
SCIP_EVENTDATA **  eventdata,
SCIP_CONSDATA consdata,
SCIP_Longint  weight 
)
static

creates event data

Parameters
scipSCIP data structure
eventdatapointer to store event data
consdataconstraint data
weightweight of variable

Definition at line 284 of file cons_knapsack.c.

References NULL, SCIP_CALL, SCIP_OKAY, and SCIPallocBlockMemory.

Referenced by addCoef(), and catchEvents().

static SCIP_RETCODE eventdataFree ( SCIP scip,
SCIP_EVENTDATA **  eventdata 
)
static

frees event data

Parameters
scipSCIP data structure
eventdatapointer to event data

Definition at line 302 of file cons_knapsack.c.

References NULL, SCIP_OKAY, and SCIPfreeBlockMemory.

Referenced by delCoefPos(), and dropEvents().

static void sortItems ( SCIP_CONSDATA consdata)
static

sorts items in knapsack with nonincreasing weights

Parameters
consdataconstraint data

Definition at line 316 of file cons_knapsack.c.

References FALSE, NULL, SCIPsortDownLongPtrPtrIntInt(), SCIPsortPtrPtrIntInt(), and TRUE.

Referenced by addCliques(), addNegatedCliques(), normalizeWeights(), prepareCons(), preprocessConstraintPairs(), propagateCons(), SCIP_DECL_HASHKEYVAL(), tightenWeights(), and tightenWeightsLift().

static SCIP_RETCODE calcCliquepartition ( SCIP scip,
SCIP_CONSDATA consdata,
SCIP_Bool  normalclique,
SCIP_Bool  negatedclique 
)
static

calculates a partition of the variables into cliques

Parameters
scipSCIP data structure
consdataconstraint data
normalcliqueShould normal cliquepartition be created?
negatedcliqueShould negated cliquepartition be created?

Definition at line 416 of file cons_knapsack.c.

References NULL, SCIP_CALL, SCIP_OKAY, SCIPcalcCliquePartition(), SCIPcalcNegatedCliquePartition(), and TRUE.

Referenced by addCliques(), addNegatedCliques(), detectRedundantVars(), propagateCons(), tightenWeights(), and tightenWeightsLift().

static SCIP_RETCODE lockRounding ( SCIP scip,
SCIP_CONS cons,
SCIP_VAR var 
)
static

installs rounding locks for the given variable in the given knapsack constraint

Parameters
scipSCIP data structure
consknapsack constraint
varvariable of constraint entry

Definition at line 446 of file cons_knapsack.c.

References FALSE, SCIP_CALL, SCIP_OKAY, SCIPlockVarCons(), and TRUE.

Referenced by addCoef().

static SCIP_RETCODE unlockRounding ( SCIP scip,
SCIP_CONS cons,
SCIP_VAR var 
)
static

removes rounding locks for the given variable in the given knapsack constraint

Parameters
scipSCIP data structure
consknapsack constraint
varvariable of constraint entry

Definition at line 460 of file cons_knapsack.c.

References FALSE, SCIP_CALL, SCIP_OKAY, SCIPunlockVarCons(), and TRUE.

Referenced by delCoefPos().

static SCIP_RETCODE catchEvents ( SCIP scip,
SCIP_CONSDATA consdata,
SCIP_EVENTHDLR eventhdlr 
)
static

catches bound change events for variables in knapsack

Parameters
scipSCIP data structure
consdataconstraint data
eventhdlrevent handler to call for the event processing

Definition at line 474 of file cons_knapsack.c.

References eventdataCreate(), NULL, SCIP_CALL, SCIP_EVENTTYPE_IMPLADDED, SCIP_EVENTTYPE_LBCHANGED, SCIP_EVENTTYPE_UBRELAXED, SCIP_EVENTTYPE_VARDELETED, SCIP_EVENTTYPE_VARFIXED, SCIP_OKAY, and SCIPcatchVarEvent().

Referenced by consdataCreate().

static SCIP_RETCODE dropEvents ( SCIP scip,
SCIP_CONSDATA consdata,
SCIP_EVENTHDLR eventhdlr 
)
static

drops bound change events for variables in knapsack

Parameters
scipSCIP data structure
consdataconstraint data
eventhdlrevent handler to call for the event processing

Definition at line 501 of file cons_knapsack.c.

References eventdataFree(), NULL, SCIP_CALL, SCIP_EVENTTYPE_IMPLADDED, SCIP_EVENTTYPE_LBCHANGED, SCIP_EVENTTYPE_UBRELAXED, SCIP_EVENTTYPE_VARDELETED, SCIP_EVENTTYPE_VARFIXED, SCIP_OKAY, and SCIPdropVarEvent().

Referenced by consdataFree().

static SCIP_RETCODE consdataEnsureVarsSize ( SCIP scip,
SCIP_CONSDATA consdata,
int  num,
SCIP_Bool  transformed 
)
static

ensures, that vars and vals arrays can store at least num entries

Parameters
scipSCIP data structure
consdataknapsack constraint data
numminimum number of entries to store
transformedis constraint from transformed problem?

Definition at line 528 of file cons_knapsack.c.

References NULL, SCIP_CALL, SCIP_OKAY, SCIPcalcMemGrowSize(), and SCIPreallocBlockMemoryArray.

Referenced by addCoef().

static SCIP_RETCODE consdataCreate ( SCIP scip,
SCIP_CONSDATA **  consdata,
SCIP_EVENTHDLR eventhdlr,
int  nvars,
SCIP_VAR **  vars,
SCIP_Longint weights,
SCIP_Longint  capacity 
)
static

creates knapsack constraint data

Parameters
scipSCIP data structure
consdatapointer to store constraint data
eventhdlrevent handler to call for the event processing
nvarsnumber of variables in knapsack
varsvariables of knapsack
weightsweights of knapsack items
capacitycapacity of knapsack

Definition at line 566 of file cons_knapsack.c.

References catchEvents(), FALSE, NULL, SCIP_GUBSet::nvars, SCIP_CALL, SCIP_OKAY, SCIP_VARSTATUS_MULTAGGR, SCIPallocBlockMemory, SCIPallocBlockMemoryArray, SCIPcaptureVar(), SCIPduplicateBlockMemoryArray, SCIPfreeBlockMemoryArray, SCIPgetTransformedVars(), SCIPisTransformed(), SCIPreallocBlockMemoryArray, SCIPvarGetLbLocal(), SCIPvarGetProbvar(), and SCIPvarGetStatus().

Referenced by SCIP_DECL_CONSTRANS(), and SCIPcreateConsKnapsack().

static SCIP_RETCODE consdataFree ( SCIP scip,
SCIP_CONSDATA **  consdata,
SCIP_EVENTHDLR eventhdlr 
)
static

frees knapsack constraint data

Parameters
scipSCIP data structure
consdatapointer to the constraint data
eventhdlrevent handler to call for the event processing

Definition at line 691 of file cons_knapsack.c.

References dropEvents(), NULL, SCIP_CALL, SCIP_OKAY, SCIPfreeBlockMemory, SCIPfreeBlockMemoryArray, SCIPreleaseRow(), and SCIPreleaseVar().

Referenced by SCIP_DECL_CONSDELETE().

static void consdataChgWeight ( SCIP_CONSDATA consdata,
int  item,
SCIP_Longint  newweight 
)
static

changes a single weight in knapsack constraint data

Parameters
consdataknapsack constraint data
itemitem number
newweightnew weight of item

Definition at line 741 of file cons_knapsack.c.

References FALSE, NULL, SCIP_GUBSet::nvars, SCIP_Longint, and SCIPvarGetLbLocal().

Referenced by deleteRedundantVars(), dualWeightsTightening(), mergeMultiples(), normalizeWeights(), simplifyInequalities(), and tightenWeights().

static SCIP_RETCODE createRelaxation ( SCIP scip,
SCIP_CONS cons 
)
static

creates LP row corresponding to knapsack constraint

Parameters
scipSCIP data structure
consknapsack constraint

Definition at line 779 of file cons_knapsack.c.

References NULL, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPaddVarToRow(), SCIPcacheRowExtensions(), SCIPconsGetData(), SCIPconsGetHdlr(), SCIPconsGetName(), SCIPconsIsLocal(), SCIPconsIsModifiable(), SCIPconsIsRemovable(), SCIPcreateEmptyRowCons(), SCIPflushRowExtensions(), and SCIPinfinity().

Referenced by addRelaxation().

static SCIP_RETCODE addRelaxation ( SCIP scip,
SCIP_CONS cons,
SCIP_SOL sol,
SCIP_Bool cutoff 
)
static

adds linear relaxation of knapsack constraint to the LP

Parameters
scipSCIP data structure
consknapsack constraint
solprimal CIP solution, NULL for current LP solution
cutoffwhether a cutoff has been detected

Definition at line 807 of file cons_knapsack.c.

References createRelaxation(), FALSE, NULL, SCIP_CALL, SCIP_OKAY, SCIPaddCut(), SCIPconsGetData(), SCIPconsGetName(), SCIPdebug, SCIPdebugMessage, SCIPprintRow(), and SCIProwIsInLP().

Referenced by SCIP_DECL_CONSENFOLP(), SCIP_DECL_CONSINITLP(), and separateCons().

static SCIP_RETCODE checkCons ( SCIP scip,
SCIP_CONS cons,
SCIP_SOL sol,
SCIP_Bool  checklprows,
SCIP_Bool  printreason,
SCIP_Bool violated 
)
static

checks knapsack constraint for feasibility of given solution: returns TRUE iff constraint is feasible

Parameters
scipSCIP data structure
consconstraint to check
solsolution to check, NULL for current solution
checklprowsshould LP rows be checked?
printreasonshould the reason for the violation be printed?
violatedpointer to store whether the constraint is violated

Definition at line 842 of file cons_knapsack.c.

References FALSE, NULL, SCIP_Bool, SCIP_CALL, SCIP_Longint, SCIP_OKAY, SCIP_Real, SCIPconsGetData(), SCIPconsGetName(), SCIPdebugMessage, SCIPgetSolVal(), SCIPincConsAge(), SCIPinfoMessage(), SCIPisFeasGT(), SCIPisHugeValue(), SCIPprintCons(), SCIPresetConsAge(), SCIProwIsInLP(), SCIPvarIsBinary(), and TRUE.

Referenced by SCIP_DECL_CONSCHECK(), SCIP_DECL_CONSENFOLP(), SCIP_DECL_CONSENFOPS(), and separateCons().

SCIP_RETCODE SCIPsolveKnapsackExactly ( SCIP scip,
int  nitems,
SCIP_Longint weights,
SCIP_Real profits,
SCIP_Longint  capacity,
int *  items,
int *  solitems,
int *  nonsolitems,
int *  nsolitems,
int *  nnonsolitems,
SCIP_Real solval,
SCIP_Bool success 
)

solves knapsack problem in maximization form exactly using dynamic programming; if needed, one can provide arrays to store all selected items and all not selected items

Note
in case you provide the solitems or nonsolitems array you also have to provide the counter part as well
Parameters
scipSCIP data structure
nitemsnumber of available items
weightsitem weights
profitsitem profits
capacitycapacity of knapsack
itemsitem numbers
solitemsarray to store items in solution, or NULL
nonsolitemsarray to store items not in solution, or NULL
nsolitemspointer to store number of items in solution, or NULL
nnonsolitemspointer to store number of items not in solution, or NULL
solvalpointer to store optimal solution value, or NULL
successpointer to store if an error occured during solving(normally a memory problem)

Definition at line 942 of file cons_knapsack.c.

References FALSE, IDX, MAX, NULL, SCIP_Bool, SCIP_CALL, SCIP_Longint, SCIP_LONGINT_MAX, SCIP_NOMEMORY, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPallocMemoryArray, SCIPcalcGreComDiv(), SCIPdebugMessage, SCIPfreeBufferArray, SCIPfreeMemoryArray, SCIPsortDownRealIntLong(), SCIPsortDownRealLongRealInt(), and TRUE.

Referenced by dualPresolving(), getFlowCover(), and getHighestCapacityUsage().

SCIP_RETCODE SCIPsolveKnapsackApproximately ( SCIP scip,
int  nitems,
SCIP_Longint weights,
SCIP_Real profits,
SCIP_Longint  capacity,
int *  items,
int *  solitems,
int *  nonsolitems,
int *  nsolitems,
int *  nnonsolitems,
SCIP_Real solval 
)

solves knapsack problem in maximization form approximately by solving the LP-relaxation of the problem using Dantzig's method and rounding down the solution; if needed, one can provide arrays to store all selected items and all not selected items

Parameters
scipSCIP data structure
nitemsnumber of available items
weightsitem weights
profitsitem profits
capacitycapacity of knapsack
itemsitem numbers
solitemsarray to store items in solution, or NULL
nonsolitemsarray to store items not in solution, or NULL
nsolitemspointer to store number of items in solution, or NULL
nnonsolitemspointer to store number of items not in solution, or NULL
solvalpointer to store optimal solution value, or NULL

Definition at line 1485 of file cons_knapsack.c.

References NULL, SCIP_CALL, SCIP_Longint, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPfreeBufferArray, and SCIPsortDownRealLongRealInt().

Referenced by getCover().

static SCIP_Bool checkSolveKnapsack ( SCIP scip,
int  nitems,
SCIP_Longint transweights,
SCIP_Real transprofits,
int *  items,
SCIP_Longint weights,
SCIP_Real solvals,
SCIP_Bool  modtransused 
)
static

returns, whether the the arrays transweights, transprofits and items are sorted such that p_1 / w_1 >= p_2 / w_2 >= ... >= p_n / w_n and these arrays are not changed

Parameters
scipSCIP data structure
nitemsnumber of available items
transweightsitem weights
transprofitsitem profits
itemsitem numbers
weightsweights of variables in knapsack constraint
solvalssolution values of all problem variables
modtransusedTRUE for mod trans sepa prob was used to find cover

Definition at line 1556 of file cons_knapsack.c.

References FALSE, NULL, SCIPisFeasEQ(), SCIPisFeasGE(), SCIPisFeasLT(), and TRUE.

Referenced by getCover().

static SCIP_RETCODE GUBconsCreate ( SCIP scip,
SCIP_GUBCONS **  gubcons 
)
static

creates an empty GUB constraint

Parameters
scipSCIP data structure
gubconspointer to store GUB constraint data

Definition at line 1671 of file cons_knapsack.c.

References GUBCONSGROWVALUE, NULL, SCIP_CALL, SCIP_OKAY, SCIPallocBufferArray, and SCIPallocMemory.

Referenced by getLiftingSequenceGUB(), and GUBsetCreate().

static SCIP_RETCODE GUBconsFree ( SCIP scip,
SCIP_GUBCONS **  gubcons 
)
static

frees GUB constraint

Parameters
scipSCIP data structure
gubconspointer to GUB constraint data structure

Definition at line 1692 of file cons_knapsack.c.

References NULL, SCIP_OKAY, SCIPfreeBufferArray, and SCIPfreeMemory.

Referenced by GUBsetFree(), and GUBsetMoveVar().

static SCIP_RETCODE GUBconsAddVar ( SCIP scip,
SCIP_GUBCONS gubcons,
int  var 
)
static

adds variable to given GUB constraint

Parameters
scipSCIP data structure
gubconsGUB constraint data
varindex of given variable in knapsack constraint

Definition at line 1712 of file cons_knapsack.c.

References GUBCONSGROWVALUE, SCIP_GUBCons::gubvars, SCIP_GUBCons::gubvarssize, SCIP_GUBCons::gubvarsstatus, GUBVARSTATUS_UNINITIAL, SCIP_GUBCons::ngubvars, NULL, SCIP_CALL, SCIP_OKAY, and SCIPreallocBufferArray.

Referenced by GUBsetCreate(), and GUBsetMoveVar().

static SCIP_RETCODE GUBconsDelVar ( SCIP scip,
SCIP_GUBCONS gubcons,
int  var,
int  gubvarsidx 
)
static

deletes variable from its current GUB constraint

Parameters
scipSCIP data structure
gubconsGUB constraint data
varindex of given variable in knapsack constraint
gubvarsidxindex of the variable in its current GUB constraint

Definition at line 1747 of file cons_knapsack.c.

References GUBCONSGROWVALUE, SCIP_GUBCons::gubvars, SCIP_GUBSet::gubvarsidx, SCIP_GUBCons::gubvarssize, SCIP_GUBCons::gubvarsstatus, SCIP_GUBCons::ngubvars, NULL, SCIP_CALL, SCIP_OKAY, and SCIPreallocBufferArray.

Referenced by GUBsetMoveVar().

static SCIP_RETCODE GUBsetMoveVar ( SCIP scip,
SCIP_GUBSET gubset,
SCIP_VAR **  vars,
int  var,
int  oldgubcons,
int  newgubcons 
)
static

moves variable from current GUB constraint to a different existing (nonempty) GUB constraint

Parameters
scipSCIP data structure
gubsetGUB set data structure
varsvariables in knapsack constraint
varindex of given variable in knapsack constraint
oldgubconsindex of old GUB constraint of given variable
newgubconsindex of new GUB constraint of given variable

Definition at line 1784 of file cons_knapsack.c.

References GUBconsAddVar(), GUBconsDelVar(), GUBconsFree(), SCIP_GUBSet::gubconss, SCIP_GUBSet::gubconssidx, SCIP_GUBSet::gubconsstatus, SCIP_GUBCons::gubvars, SCIP_GUBSet::gubvarsidx, SCIP_GUBSet::ngubconss, SCIP_GUBCons::ngubvars, NULL, SCIP_CALL, SCIP_OKAY, SCIPdebugMessage, and SCIPvarGetName().

Referenced by getLiftingSequenceGUB(), and GUBsetGetCliquePartition().

static void GUBsetSwapVars ( SCIP scip,
SCIP_GUBSET gubset,
int  var1,
int  var2 
)
static

swaps two variables in the same GUB constraint

Parameters
scipSCIP data structure
gubsetGUB set data structure
var1first variable to be swapped
var2second variable to be swapped

Definition at line 1875 of file cons_knapsack.c.

References SCIP_GUBSet::gubconss, SCIP_GUBSet::gubconssidx, SCIP_GUBCons::gubvars, SCIP_GUBSet::gubvarsidx, SCIP_GUBCons::gubvarsstatus, and NULL.

Referenced by getLiftingSequenceGUB().

static SCIP_RETCODE GUBsetCreate ( SCIP scip,
SCIP_GUBSET **  gubset,
int  nvars,
SCIP_Longint weights,
SCIP_Longint  capacity 
)
static

initializes partition of knapsack variables into nonoverlapping trivial GUB constraints (GUB with one variable)

Parameters
scipSCIP data structure
gubsetpointer to store GUB set data structure
nvarsnumber of variables in the knapsack constraint
weightsweights of variables in knapsack constraint
capacitycapacity of knapsack

Definition at line 1915 of file cons_knapsack.c.

References GUBconsAddVar(), GUBconsCreate(), GUBCONSSTATUS_UNINITIAL, GUBVARSTATUS_CAPACITYEXCEEDED, NULL, SCIP_GUBSet::nvars, SCIP_CALL, SCIP_OKAY, SCIPallocBufferArray, and SCIPallocMemory.

Referenced by SCIPseparateKnapsackCuts().

static SCIP_RETCODE GUBsetFree ( SCIP scip,
SCIP_GUBSET **  gubset 
)
static

frees GUB set data structure

Parameters
scipSCIP data structure
gubsetpointer to GUB set data structure

Definition at line 1965 of file cons_knapsack.c.

References GUBconsFree(), NULL, SCIP_CALL, SCIP_OKAY, SCIPfreeBufferArray, and SCIPfreeMemory.

Referenced by SCIPseparateKnapsackCuts().

static SCIP_RETCODE GUBsetCheck ( SCIP scip,
SCIP_GUBSET gubset,
SCIP_VAR **  vars 
)
static

checks whether GUB set data structure is consistent

Parameters
scipSCIP data structure
gubsetGUB set data structure
varsvariables in the knapsack constraint

Definition at line 1999 of file cons_knapsack.c.

References FALSE, SCIP_GUBSet::gubconss, SCIP_GUBSet::gubconssidx, SCIP_GUBCons::gubvars, SCIP_GUBSet::gubvarsidx, SCIP_GUBSet::ngubconss, SCIP_GUBCons::ngubvars, NULL, SCIP_GUBSet::nvars, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIPdebugMessage, SCIPvarGetName(), SCIPvarGetProbvarBinary(), SCIPvarsHaveCommonClique(), and TRUE.

Referenced by GUBsetGetCliquePartition().

static SCIP_RETCODE GUBsetCalcCliquePartition ( SCIP *const  scip,
SCIP_VAR **const  vars,
int const  nvars,
int *const  cliquepartition,
int *const  ncliques,
SCIP_Real solvals 
)
static
Parameters
scipSCIP data structure
varsbinary variables in the clique from which at most one can be set to 1
nvarsnumber of variables in the clique
cliquepartitionarray of length nvars to store the clique partition
ncliquespointer to store number of cliques actually contained in the partition
solvalssolution values of all given binary variables

Definition at line 2084 of file cons_knapsack.c.

References MAXNCLIQUEVARSCOMP, MIN, NULL, SCIP_GUBSet::nvars, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIPallocBufferArray, SCIPduplicateBufferArray, SCIPfreeBufferArray, SCIPisFeasEQ(), SCIPsortIntInt(), SCIPvarGetNCliques(), SCIPvarIsActive(), SCIPvarsGetProbvarBinary(), SCIPvarsHaveCommonClique(), and TRUE.

Referenced by GUBsetGetCliquePartition().

static SCIP_RETCODE GUBsetGetCliquePartition ( SCIP scip,
SCIP_GUBSET gubset,
SCIP_VAR **  vars,
SCIP_Real solvals 
)
static

constructs sophisticated partion of knapsack variables into nonoverlapping GUBs; current partion uses trivial GUBs

Parameters
scipSCIP data structure
gubsetGUB set data structure
varsvariables in the knapsack constraint
solvalssolution values of all knapsack variables

Definition at line 2243 of file cons_knapsack.c.

References SCIP_GUBSet::gubconss, SCIP_GUBSet::gubconssidx, GUBsetCalcCliquePartition(), GUBsetCheck(), GUBsetMoveVar(), SCIP_GUBCons::gubvars, SCIP_GUBSet::gubvarsidx, SCIP_GUBCons::ngubvars, NULL, SCIP_GUBSet::nvars, SCIP_CALL, SCIP_OKAY, SCIPallocBufferArray, and SCIPfreeBufferArray.

Referenced by SCIPseparateKnapsackCuts().

static SCIP_RETCODE getCover ( SCIP scip,
SCIP_VAR **  vars,
int  nvars,
SCIP_Longint weights,
SCIP_Longint  capacity,
SCIP_Real solvals,
int *  covervars,
int *  noncovervars,
int *  ncovervars,
int *  nnoncovervars,
SCIP_Longint coverweight,
SCIP_Bool found,
SCIP_Bool  modtransused,
int *  ntightened,
SCIP_Bool fractional 
)
static

gets a most violated cover C ( $\sum_{j \in C} a_j > a_0$) for a given knapsack constraint $\sum_{j \in N} a_j x_j \leq a_0$ taking into consideration the following fixing: $j \in C$, if $j \in N_1 = \{j \in N : x^*_j = 1\}$ and $j \in N \setminus C$, if $j \in N_0 = \{j \in N : x^*_j = 0\}$, if one exists.

Parameters
scipSCIP data structure
varsvariables in knapsack constraint
nvarsnumber of variables in knapsack constraint
weightsweights of variables in knapsack constraint
capacitycapacity of knapsack
solvalssolution values of all problem variables
covervarspointer to store cover variables
noncovervarspointer to store noncover variables
ncovervarspointer to store number of cover variables
nnoncovervarspointer to store number of noncover variables
coverweightpointer to store weight of cover
foundpointer to store whether a cover was found
modtransusedshould modified transformed separation problem be used to find cover
ntightenedpointer to store number of variables with tightened upper bound
fractionalpointer to store whether the LP sol for knapsack vars is fractional

Definition at line 2340 of file cons_knapsack.c.

References checkSolveKnapsack(), FALSE, NULL, SCIP_GUBSet::nvars, SCIP_Bool, SCIP_CALL, SCIP_Longint, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPdebugMessage, SCIPfreeBufferArray, SCIPisFeasEQ(), SCIPisFeasGT(), SCIPisFeasLT(), SCIPisFeasPositive(), SCIPsolveKnapsackApproximately(), SCIPtightenVarUb(), SCIPvarIsBinary(), and TRUE.

Referenced by SCIPseparateKnapsackCuts().

static SCIP_Bool checkMinweightidx ( SCIP_Longint weights,
SCIP_Longint  capacity,
int *  covervars,
int  ncovervars,
SCIP_Longint  coverweight,
int  minweightidx,
int  j 
)
static

checks if minweightidx is set correctly

Parameters
weightsweights of variables in knapsack constraint
capacitycapacity of knapsack
covervarspointer to store cover variables
ncovervarspointer to store number of cover variables
coverweightpointer to store weight of cover
minweightidxindex of variable in cover variables with minimum weight
jcurrent index in cover variables

Definition at line 2571 of file cons_knapsack.c.

References FALSE, NULL, SCIP_Longint, and TRUE.

Referenced by makeCoverMinimal().

static void getPartitionCovervars ( SCIP scip,
SCIP_Real solvals,
int *  covervars,
int  ncovervars,
int *  varsC1,
int *  varsC2,
int *  nvarsC1,
int *  nvarsC2 
)
static

gets partition $(C_1,C_2)$ of minimal cover $C$, i.e. $C_1 \cup C_2 = C$ and $C_1 \cap C_2 = \emptyset$, with $C_1$ not empty; chooses partition as follows $C_2 = \{ j \in C : x^*_j = 1 \}$ and $C_1 = C \setminus C_2$

Parameters
scipSCIP data structure
solvalssolution values of all problem variables
covervarscover variables
ncovervarsnumber of cover variables
varsC1pointer to store variables in C1
varsC2pointer to store variables in C2
nvarsC1pointer to store number of variables in C1
nvarsC2pointer to store number of variables in C2

Definition at line 2614 of file cons_knapsack.c.

References NULL, SCIPisFeasGT(), SCIPisGE(), and SCIPisLT().

Referenced by separateSequLiftedExtendedWeightInequality(), and separateSequLiftedMinimalCoverInequality().

static SCIP_RETCODE changePartitionCovervars ( SCIP scip,
SCIP_Longint weights,
int *  varsC1,
int *  varsC2,
int *  nvarsC1,
int *  nvarsC2 
)
static

changes given partition (C_1,C_2) of minimal cover C, if |C1| = 1, by moving one and two (if possible) variables from C2 to C1 if |C1| = 1 and |C1| = 0, respectively.

Parameters
scipSCIP data structure
weightsweights of variables in knapsack constraint
varsC1pointer to store variables in C1
varsC2pointer to store variables in C2
nvarsC1pointer to store number of variables in C1
nvarsC2pointer to store number of variables in C2

Definition at line 2663 of file cons_knapsack.c.

References SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPfreeBufferArray, and SCIPsortDownRealInt().

Referenced by separateSequLiftedMinimalCoverInequality().

static SCIP_RETCODE changePartitionFeasiblesetvars ( SCIP scip,
SCIP_Longint weights,
int *  varsC1,
int *  varsC2,
int *  nvarsC1,
int *  nvarsC2 
)
static

changes given partition (C_1,C_2) of feasible set C, if |C1| = 1, by moving one variable from C2 to C1

Parameters
scipSCIP data structure
weightsweights of variables in knapsack constraint
varsC1pointer to store variables in C1
varsC2pointer to store variables in C2
nvarsC1pointer to store number of variables in C1
nvarsC2pointer to store number of variables in C2

Definition at line 2703 of file cons_knapsack.c.

References SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPfreeBufferArray, and SCIPsortDownRealInt().

Referenced by separateSequLiftedExtendedWeightInequality().

static void getPartitionNoncovervars ( SCIP scip,
SCIP_Real solvals,
int *  noncovervars,
int  nnoncovervars,
int *  varsF,
int *  varsR,
int *  nvarsF,
int *  nvarsR 
)
static

gets partition $(F,R)$ of $N \setminus C$ where $C$ is a minimal cover, i.e. $F \cup R = N \setminus C$ and $F \cap R = \emptyset$; chooses partition as follows $R = \{ j \in N \setminus C : x^*_j = 0 \}$ and $F = (N \setminus C) \setminus F$

Parameters
scipSCIP data structure
solvalssolution values of all problem variables
noncovervarsnoncover variables
nnoncovervarsnumber of noncover variables
varsFpointer to store variables in F
varsRpointer to store variables in R
nvarsFpointer to store number of variables in F
nvarsRpointer to store number of variables in R

Definition at line 2744 of file cons_knapsack.c.

References NULL, SCIPisFeasEQ(), and SCIPisFeasGT().

Referenced by separateSequLiftedExtendedWeightInequality(), and separateSequLiftedMinimalCoverInequality().

static SCIP_RETCODE getLiftingSequence ( SCIP scip,
SCIP_Real solvals,
SCIP_Longint weights,
int *  varsF,
int *  varsC2,
int *  varsR,
int  nvarsF,
int  nvarsC2,
int  nvarsR 
)
static

sorts variables in F, C_2, and R according to the second level lifting sequence that will be used in the sequential lifting procedure

Parameters
scipSCIP data structure
solvalssolution values of all problem variables
weightsweights of variables in knapsack constraint
varsFpointer to store variables in F
varsC2pointer to store variables in C2
varsRpointer to store variables in R
nvarsFnumber of variables in F
nvarsC2number of variables in C2
nvarsRnumber of variables in R

Definition at line 2792 of file cons_knapsack.c.

References NULL, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPallocMemoryArray, SCIPfreeBufferArray, SCIPfreeMemoryArray, SCIPsortDownPtrInt(), and SCIPsortDownRealInt().

Referenced by separateSequLiftedExtendedWeightInequality(), and separateSequLiftedMinimalCoverInequality().

static SCIP_RETCODE getLiftingSequenceGUB ( SCIP scip,
SCIP_GUBSET gubset,
SCIP_Real solvals,
SCIP_Longint weights,
int *  varsC1,
int *  varsC2,
int *  varsF,
int *  varsR,
int  nvarsC1,
int  nvarsC2,
int  nvarsF,
int  nvarsR,
int *  gubconsGC1,
int *  gubconsGC2,
int *  gubconsGFC1,
int *  gubconsGR,
int *  ngubconsGC1,
int *  ngubconsGC2,
int *  ngubconsGFC1,
int *  ngubconsGR,
int *  ngubconscapexceed,
int *  maxgubvarssize 
)
static

categorizies GUBs of knapsack GUB partion into GOC1, GNC1, GF, GC2, and GR and computes a lifting sequence of the GUBs for the sequential GUB wise lifting procedure

Parameters
scipSCIP data structure
gubsetGUB set data structure
solvalssolution values of variables in knapsack constraint
weightsweights of variables in knapsack constraint
varsC1variables in C1
varsC2variables in C2
varsFvariables in F
varsRvariables in R
nvarsC1number of variables in C1
nvarsC2number of variables in C2
nvarsFnumber of variables in F
nvarsRnumber of variables in R
gubconsGC1pointer to store GUBs in GC1(GNC1+GOC1)
gubconsGC2pointer to store GUBs in GC2
gubconsGFC1pointer to store GUBs in GFC1(GNC1+GF)
gubconsGRpointer to store GUBs in GR
ngubconsGC1pointer to store number of GUBs in GC1(GNC1+GOC1)
ngubconsGC2pointer to store number of GUBs in GC2
ngubconsGFC1pointer to store number of GUBs in GFC1(GNC1+GF)
ngubconsGRpointer to store number of GUBs in GR
ngubconscapexceedpointer to store number of GUBs with only capacity exceeding variables
maxgubvarssizepointer to store the maximal size of GUB constraints

Definition at line 2878 of file cons_knapsack.c.

References BMSclearMemoryArray, FALSE, GUBconsCreate(), SCIP_GUBSet::gubconss, SCIP_GUBSet::gubconssidx, SCIP_GUBSet::gubconsstatus, GUBCONSSTATUS_BELONGSTOSET_GC2, GUBCONSSTATUS_BELONGSTOSET_GF, GUBCONSSTATUS_BELONGSTOSET_GNC1, GUBCONSSTATUS_BELONGSTOSET_GOC1, GUBCONSSTATUS_BELONGSTOSET_GR, GUBCONSSTATUS_UNINITIAL, GUBsetMoveVar(), GUBsetSwapVars(), SCIP_GUBCons::gubvars, SCIP_GUBSet::gubvarsidx, SCIP_GUBCons::gubvarssize, SCIP_GUBCons::gubvarsstatus, GUBVARSTATUS_BELONGSTOSET_C1, GUBVARSTATUS_BELONGSTOSET_C2, GUBVARSTATUS_BELONGSTOSET_F, GUBVARSTATUS_BELONGSTOSET_R, GUBVARSTATUS_CAPACITYEXCEEDED, SCIP_GUBSet::ngubconss, SCIP_GUBCons::ngubvars, NULL, SCIP_GUBSet::nvars, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBuffer, SCIPallocBufferArray, SCIPallocMemoryArray, SCIPfreeBuffer, SCIPfreeBufferArray, SCIPfreeMemoryArray, SCIPsortDownPtrInt(), SCIPsortDownRealInt(), SCIPsortRealInt(), and TRUE.

Referenced by separateSequLiftedMinimalCoverInequality().

static SCIP_RETCODE enlargeMinweights ( SCIP scip,
SCIP_Longint **  minweightsptr,
int *  minweightslen,
int *  minweightssize,
int  newlen 
)
static

enlarges minweight table to at least the given length

Parameters
scipSCIP data structure
minweightsptrpointer to minweights table
minweightslenpointer to store number of entries in minweights table (incl. z=0)
minweightssizepointer to current size of minweights table
newlennew length of minweights table

Definition at line 3398 of file cons_knapsack.c.

References NULL, SCIP_CALL, SCIP_LONGINT_MAX, SCIP_OKAY, SCIPcalcMemGrowSize(), and SCIPreallocBufferArray.

Referenced by sequentialUpAndDownLifting(), and sequentialUpAndDownLiftingGUB().

static SCIP_RETCODE sequentialUpAndDownLifting ( SCIP scip,
SCIP_VAR **  vars,
int  nvars,
int  ntightened,
SCIP_Longint weights,
SCIP_Longint  capacity,
SCIP_Real solvals,
int *  varsM1,
int *  varsM2,
int *  varsF,
int *  varsR,
int  nvarsM1,
int  nvarsM2,
int  nvarsF,
int  nvarsR,
int  alpha0,
int *  liftcoefs,
SCIP_Real cutact,
int *  liftrhs 
)
static

lifts given inequality sum_{j in M_1} x_j <= alpha_0 valid for S^0 = { x in {0,1}^|M_1| : sum_{j in M_1} a_j x_j <= a_0 - sum_{j in M_2} a_j } to a valid inequality sum_{j in M_1} x_j + sum_{j in F} alpha_j x_j + sum_{j in M_2} alpha_j x_j + sum_{j in R} alpha_j x_j <= alpha_0 + sum_{j in M_2} alpha_j for S = { x in {0,1}^|N| : sum_{j in N} a_j x_j <= a_0 }; uses sequential up-lifting for the variables in F, sequential down-lifting for the variable in M_2, and sequential up-lifting for the variables in R; procedure can be used to strengthen minimal cover inequalities and extended weight inequalities.

Parameters
scipSCIP data structure
varsvariables in knapsack constraint
nvarsnumber of variables in knapsack constraint
ntightenednumber of variables with tightened upper bound
weightsweights of variables in knapsack constraint
capacitycapacity of knapsack
solvalssolution values of all problem variables
varsM1variables in M_1
varsM2variables in M_2
varsFvariables in F
varsRvariables in R
nvarsM1number of variables in M_1
nvarsM2number of variables in M_2
nvarsFnumber of variables in F
nvarsRnumber of variables in R
alpha0rights hand side of given valid inequality
liftcoefspointer to store lifting coefficient of vars in knapsack constraint
cutactpointer to store activity of lifted valid inequality
liftrhspointer to store right hand side of the lifted valid inequality

Definition at line 3448 of file cons_knapsack.c.

References BMSclearMemoryArray, enlargeMinweights(), MIN, NULL, SCIP_CALL, SCIP_Longint, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPfreeBufferArray, SCIPisFeasEQ(), SCIPisFeasGT(), and SCIPsortRealInt().

Referenced by separateSequLiftedExtendedWeightInequality(), and separateSequLiftedMinimalCoverInequality().

static SCIP_Longint safeAddMinweightsGUB ( SCIP_Longint  val1,
SCIP_Longint  val2 
)
static

adds two minweight values in a safe way, i.e,, ensures no overflow

Parameters
val1first value to add
val2second value to add

Definition at line 3826 of file cons_knapsack.c.

References SCIP_LONGINT_MAX.

Referenced by computeMinweightsGUB(), and sequentialUpAndDownLiftingGUB().

static void computeMinweightsGUB ( SCIP_Longint minweights,
SCIP_Longint finished,
SCIP_Longint unfinished,
int  minweightslen 
)
static

computes minweights table for lifting with GUBs by combining unfished and fished tables

Parameters
minweightsminweight table to compute
finishedgiven finished table
unfinishedgiven unfinished table
minweightslenlength of minweight, finished, and unfinished tables

Definition at line 3845 of file cons_knapsack.c.

References safeAddMinweightsGUB(), SCIP_Longint, and SCIP_LONGINT_MAX.

Referenced by sequentialUpAndDownLiftingGUB().

static SCIP_RETCODE sequentialUpAndDownLiftingGUB ( SCIP scip,
SCIP_GUBSET gubset,
SCIP_VAR **  vars,
int  ngubconscapexceed,
SCIP_Longint weights,
SCIP_Longint  capacity,
SCIP_Real solvals,
int *  gubconsGC1,
int *  gubconsGC2,
int *  gubconsGFC1,
int *  gubconsGR,
int  ngubconsGC1,
int  ngubconsGC2,
int  ngubconsGFC1,
int  ngubconsGR,
int  alpha0,
int *  liftcoefs,
SCIP_Real cutact,
int *  liftrhs,
int  maxgubvarssize 
)
static

lifts given inequality sum_{j in C_1} x_j <= alpha_0 valid for S^0 = { x in {0,1}^|C_1| : sum_{j in C_1} a_j x_j <= a_0 - sum_{j in C_2} a_j; sum_{j in Q_i} x_j <= 1, forall i in I } to a valid inequality sum_{j in C_1} x_j + sum_{j in F} alpha_j x_j + sum_{j in C_2} alpha_j x_j + sum_{j in R} alpha_j x_j <= alpha_0 + sum_{j in C_2} alpha_j for S = { x in {0,1}^|N| : sum_{j in N} a_j x_j <= a_0; sum_{j in Q_i} x_j <= 1, forall i in I }; uses sequential up-lifting for the variables in GUB constraints in gubconsGFC1, sequential down-lifting for the variables in GUB constraints in gubconsGC2, and sequential up-lifting for the variabels in GUB constraints in gubconsGR.

Parameters
scipSCIP data structure
gubsetGUB set data structure
varsvariables in knapsack constraint
ngubconscapexceednumber of GUBs with only capacity exceeding variables
weightsweights of variables in knapsack constraint
capacitycapacity of knapsack
solvalssolution values of all knapsack variables
gubconsGC1GUBs in GC1(GNC1+GOC1)
gubconsGC2GUBs in GC2
gubconsGFC1GUBs in GFC1(GNC1+GF)
gubconsGRGUBs in GR
ngubconsGC1number of GUBs in GC1(GNC1+GOC1)
ngubconsGC2number of GUBs in GC2
ngubconsGFC1number of GUBs in GFC1(GNC1+GF)
ngubconsGRnumber of GUBs in GR
alpha0rights hand side of given valid inequality
liftcoefspointer to store lifting coefficient of vars in knapsack constraint
cutactpointer to store activity of lifted valid inequality
liftrhspointer to store right hand side of the lifted valid inequality
maxgubvarssizemaximal size of GUB constraints

Definition at line 3897 of file cons_knapsack.c.

References BMSclearMemoryArray, computeMinweightsGUB(), enlargeMinweights(), SCIP_GUBSet::gubconss, SCIP_GUBSet::gubconsstatus, GUBCONSSTATUS_BELONGSTOSET_GC2, GUBCONSSTATUS_BELONGSTOSET_GF, GUBCONSSTATUS_BELONGSTOSET_GNC1, GUBCONSSTATUS_BELONGSTOSET_GOC1, GUBCONSSTATUS_BELONGSTOSET_GR, SCIP_GUBCons::gubvars, SCIP_GUBCons::gubvarsstatus, GUBVARSTATUS_BELONGSTOSET_C1, GUBVARSTATUS_BELONGSTOSET_C2, GUBVARSTATUS_BELONGSTOSET_F, GUBVARSTATUS_BELONGSTOSET_R, GUBVARSTATUS_CAPACITYEXCEEDED, MIN, SCIP_GUBSet::ngubconss, SCIP_GUBCons::ngubvars, NULL, SCIP_GUBSet::nvars, safeAddMinweightsGUB(), SCIP_CALL, SCIP_Longint, SCIP_LONGINT_MAX, SCIP_OKAY, SCIPallocBufferArray, SCIPfreeBufferArray, and SCIPisFeasEQ().

Referenced by separateSequLiftedMinimalCoverInequality().

static SCIP_RETCODE superadditiveUpLifting ( SCIP scip,
SCIP_VAR **  vars,
int  nvars,
int  ntightened,
SCIP_Longint weights,
SCIP_Longint  capacity,
SCIP_Real solvals,
int *  covervars,
int *  noncovervars,
int  ncovervars,
int  nnoncovervars,
SCIP_Longint  coverweight,
SCIP_Real liftcoefs,
SCIP_Real cutact 
)
static

lifts given minimal cover inequality

\[ \sum_{j \in C} x_j \leq |C| - 1 \]

valid for

\[ S^0 = \{ x \in {0,1}^{|C|} : \sum_{j \in C} a_j x_j \leq a_0 \} \]

to a valid inequality

\[ \sum_{j \in C} x_j + \sum_{j \in N \setminus C} \alpha_j x_j \leq |C| - 1 \]

for

\[ S = \{ x \in {0,1}^{|N|} : \sum_{j \in N} a_j x_j \leq a_0 \}; \]

uses superadditive up-lifting for the variables in $N \setminus C$.

Parameters
scipSCIP data structure
varsvariables in knapsack constraint
nvarsnumber of variables in knapsack constraint
ntightenednumber of variables with tightened upper bound
weightsweights of variables in knapsack constraint
capacitycapacity of knapsack
solvalssolution values of all problem variables
covervarscover variables
noncovervarsnoncover variables
ncovervarsnumber of cover variables
nnoncovervarsnumber of noncover variables
coverweightweight of cover
liftcoefspointer to store lifting coefficient of vars in knapsack constraint
cutactpointer to store activity of lifted valid inequality

Definition at line 4629 of file cons_knapsack.c.

References BMSclearMemoryArray, MAX, NULL, SCIP_CALL, SCIP_Longint, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPfreeBufferArray, SCIPsortDownRealInt(), and SCIPsortRealInt().

Referenced by separateSupLiftedMinimalCoverInequality().

static SCIP_RETCODE separateSequLiftedMinimalCoverInequality ( SCIP scip,
SCIP_CONS cons,
SCIP_SEPA sepa,
SCIP_VAR **  vars,
int  nvars,
int  ntightened,
SCIP_Longint weights,
SCIP_Longint  capacity,
SCIP_Real solvals,
int *  mincovervars,
int *  nonmincovervars,
int  nmincovervars,
int  nnonmincovervars,
SCIP_SOL sol,
SCIP_GUBSET gubset,
SCIP_Bool cutoff,
int *  ncuts 
)
static

separates lifted minimal cover inequalities using sequential up- and down-lifting and GUB information, if wanted, for given knapsack problem

Parameters
scipSCIP data structure
consoriginating constraint of the knapsack problem, or NULL
sepaoriginating separator of the knapsack problem, or NULL
varsvariables in knapsack constraint
nvarsnumber of variables in knapsack constraint
ntightenednumber of variables with tightened upper bound
weightsweights of variables in knapsack constraint
capacitycapacity of knapsack
solvalssolution values of all problem variables
mincovervarsmincover variables
nonmincovervarsnonmincover variables
nmincovervarsnumber of mincover variables
nnonmincovervarsnumber of nonmincover variables
solprimal SCIP solution to separate, NULL for current LP solution
gubsetGUB set data structure, NULL if no GUB information should be used
cutoffpointer to store whether a cutoff has been detected
ncutspointer to add up the number of found cuts

Definition at line 4760 of file cons_knapsack.c.

References changePartitionCovervars(), FALSE, getLiftingSequence(), getLiftingSequenceGUB(), getPartitionCovervars(), getPartitionNoncovervars(), MAX, MIN, SCIP_GUBSet::ngubconss, NULL, SCIP_GUBSet::nvars, SCIP_CALL, SCIP_MAXSTRLEN, SCIP_OKAY, SCIP_Real, SCIPaddCut(), SCIPaddVarToRow(), SCIPallocBufferArray, SCIPcacheRowExtensions(), SCIPconsGetHdlr(), SCIPconsGetName(), SCIPconshdlrGetNCutsFound(), SCIPconsIsLocal(), SCIPconsIsRemovable(), SCIPcreateEmptyRowCons(), SCIPcreateEmptyRowSepa(), SCIPcreateEmptyRowUnspec(), SCIPflushRowExtensions(), SCIPfreeBufferArray, SCIPinfinity(), SCIPisCutEfficacious(), SCIPisEfficacious(), SCIPreleaseRow(), SCIPresetConsAge(), SCIPsepaGetName(), SCIPsepaGetNCutsFound(), SCIPsnprintf(), sequentialUpAndDownLifting(), sequentialUpAndDownLiftingGUB(), sqrt(), and TRUE.

Referenced by SCIPseparateKnapsackCuts().

static SCIP_RETCODE separateSequLiftedExtendedWeightInequality ( SCIP scip,
SCIP_CONS cons,
SCIP_SEPA sepa,
SCIP_VAR **  vars,
int  nvars,
int  ntightened,
SCIP_Longint weights,
SCIP_Longint  capacity,
SCIP_Real solvals,
int *  feassetvars,
int *  nonfeassetvars,
int  nfeassetvars,
int  nnonfeassetvars,
SCIP_SOL sol,
SCIP_Bool cutoff,
int *  ncuts 
)
static

separates lifted extended weight inequalities using sequential up- and down-lifting for given knapsack problem

Parameters
scipSCIP data structure
consconstraint that originates the knapsack problem, or NULL
sepaoriginating separator of the knapsack problem, or NULL
varsvariables in knapsack constraint
nvarsnumber of variables in knapsack constraint
ntightenednumber of variables with tightened upper bound
weightsweights of variables in knapsack constraint
capacitycapacity of knapsack
solvalssolution values of all problem variables
feassetvarsvariables in feasible set
nonfeassetvarsvariables not in feasible set
nfeassetvarsnumber of variables in feasible set
nnonfeassetvarsnumber of variables not in feasible set
solprimal SCIP solution to separate, NULL for current LP solution
cutoffwhether a cutoff has been detected
ncutspointer to add up the number of found cuts

Definition at line 4994 of file cons_knapsack.c.

References changePartitionFeasiblesetvars(), FALSE, getLiftingSequence(), getPartitionCovervars(), getPartitionNoncovervars(), MAX, NULL, SCIP_CALL, SCIP_MAXSTRLEN, SCIP_OKAY, SCIP_Real, SCIPaddCut(), SCIPaddVarToRow(), SCIPallocBufferArray, SCIPcacheRowExtensions(), SCIPconsGetHdlr(), SCIPconsGetName(), SCIPconshdlrGetNCutsFound(), SCIPconsIsLocal(), SCIPconsIsRemovable(), SCIPcreateEmptyRowCons(), SCIPcreateEmptyRowSepa(), SCIPcreateEmptyRowUnspec(), SCIPflushRowExtensions(), SCIPfreeBufferArray, SCIPinfinity(), SCIPisCutEfficacious(), SCIPisEfficacious(), SCIPreleaseRow(), SCIPresetConsAge(), SCIPsepaGetName(), SCIPsepaGetNCutsFound(), SCIPsnprintf(), sequentialUpAndDownLifting(), sqrt(), and TRUE.

Referenced by getFeasibleSet().

static SCIP_RETCODE separateSupLiftedMinimalCoverInequality ( SCIP scip,
SCIP_CONS cons,
SCIP_SEPA sepa,
SCIP_VAR **  vars,
int  nvars,
int  ntightened,
SCIP_Longint weights,
SCIP_Longint  capacity,
SCIP_Real solvals,
int *  mincovervars,
int *  nonmincovervars,
int  nmincovervars,
int  nnonmincovervars,
SCIP_Longint  mincoverweight,
SCIP_SOL sol,
SCIP_Bool cutoff,
int *  ncuts 
)
static

separates lifted minimal cover inequalities using superadditive up-lifting for given knapsack problem

Parameters
scipSCIP data structure
consconstraint that originates the knapsack problem, or NULL
sepaoriginating separator of the knapsack problem, or NULL
varsvariables in knapsack constraint
nvarsnumber of variables in knapsack constraint
ntightenednumber of variables with tightened upper bound
weightsweights of variables in knapsack constraint
capacitycapacity of knapsack
solvalssolution values of all problem variables
mincovervarsmincover variables
nonmincovervarsnonmincover variables
nmincovervarsnumber of mincover variables
nnonmincovervarsnumber of nonmincover variables
mincoverweightweight of minimal cover
solprimal SCIP solution to separate, NULL for current LP solution
cutoffwhether a cutoff has been detected
ncutspointer to add up the number of found cuts

Definition at line 5161 of file cons_knapsack.c.

References FALSE, MAX, NULL, SCIP_CALL, SCIP_MAXSTRLEN, SCIP_OKAY, SCIP_Real, SCIPaddCut(), SCIPaddVarToRow(), SCIPallocBufferArray, SCIPcacheRowExtensions(), SCIPconsGetHdlr(), SCIPconsGetName(), SCIPconshdlrGetNCutsFound(), SCIPconsIsLocal(), SCIPconsIsRemovable(), SCIPcreateEmptyRowCons(), SCIPcreateEmptyRowSepa(), SCIPcreateEmptyRowUnspec(), SCIPflushRowExtensions(), SCIPfreeBufferArray, SCIPinfinity(), SCIPisCutEfficacious(), SCIPisEfficacious(), SCIPisFeasGE(), SCIPisFeasGT(), SCIPreleaseRow(), SCIPresetConsAge(), SCIPsepaGetName(), SCIPsepaGetNCutsFound(), SCIPsnprintf(), sqrt(), superadditiveUpLifting(), and TRUE.

Referenced by SCIPseparateKnapsackCuts().

static SCIP_RETCODE makeCoverMinimal ( SCIP scip,
SCIP_Longint weights,
SCIP_Longint  capacity,
SCIP_Real solvals,
int *  covervars,
int *  noncovervars,
int *  ncovervars,
int *  nnoncovervars,
SCIP_Longint coverweight,
SCIP_Bool  modtransused 
)
static

converts given cover C to a minimal cover by removing variables in the reverse order in which the variables were chosen to be in C, i.e. in the order of non-increasing (1 - x*_j)/a_j, if the transformed separation problem was used to find C and in the order of non-increasing (1 - x*_j), if the modified transformed separation problem was used to find C; note that all variables with x*_j = 1 will be removed last

Parameters
scipSCIP data structure
weightsweights of variables in knapsack constraint
capacitycapacity of knapsack
solvalssolution values of all problem variables
covervarspointer to store cover variables
noncovervarspointer to store noncover variables
ncovervarspointer to store number of cover variables
nnoncovervarspointer to store number of noncover variables
coverweightpointer to store weight of cover
modtransusedTRUE if mod trans sepa prob was used to find cover

Definition at line 5275 of file cons_knapsack.c.

References checkMinweightidx(), NULL, SCIP_CALL, SCIP_Longint, SCIP_OKAY, SCIP_Real, SCIPallocBlockMemory, SCIPallocBlockMemoryArray, SCIPfreeBlockMemory, SCIPfreeBlockMemoryArray, and SCIPsortPtrInt().

Referenced by SCIPseparateKnapsackCuts().

static SCIP_RETCODE getFeasibleSet ( SCIP scip,
SCIP_CONS cons,
SCIP_SEPA sepa,
SCIP_VAR **  vars,
int  nvars,
int  ntightened,
SCIP_Longint weights,
SCIP_Longint  capacity,
SCIP_Real solvals,
int *  covervars,
int *  noncovervars,
int *  ncovervars,
int *  nnoncovervars,
SCIP_Longint coverweight,
SCIP_Bool  modtransused,
SCIP_SOL sol,
SCIP_Bool cutoff,
int *  ncuts 
)
static

converts given initial cover C_init to a feasible set by removing variables in the reverse order in which they were chosen to be in C_init: non-increasing (1 - x*_j)/a_j, if transformed separation problem was used to find C_init non-increasing (1 - x*_j), if modified transformed separation problem was used to find C_init. separates lifted extended weight inequalities using sequential up- and down-lifting for this feasible set and all subsequent feasible sets.

Parameters
scipSCIP data structure
consconstraint that originates the knapsack problem
sepaoriginating separator of the knapsack problem, or NULL
varsvariables in knapsack constraint
nvarsnumber of variables in knapsack constraint
ntightenednumber of variables with tightened upper bound
weightsweights of variables in knapsack constraint
capacitycapacity of knapsack
solvalssolution values of all problem variables
covervarspointer to store cover variables
noncovervarspointer to store noncover variables
ncovervarspointer to store number of cover variables
nnoncovervarspointer to store number of noncover variables
coverweightpointer to store weight of cover
modtransusedTRUE if mod trans sepa prob was used to find cover
solprimal SCIP solution to separate, NULL for current LP solution
cutoffwhether a cutoff has been detected
ncutspointer to add up the number of found cuts

Definition at line 5418 of file cons_knapsack.c.

References FALSE, MAXCOVERSIZEITERLEWI, NULL, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPfreeBufferArray, SCIPisFeasGE(), SCIPisFeasLE(), SCIPsortRealInt(), and separateSequLiftedExtendedWeightInequality().

Referenced by SCIPseparateKnapsackCuts().

SCIP_RETCODE SCIPseparateKnapsackCuts ( SCIP scip,
SCIP_CONS cons,
SCIP_SEPA sepa,
SCIP_VAR **  vars,
int  nvars,
SCIP_Longint weights,
SCIP_Longint  capacity,
SCIP_SOL sol,
SCIP_Bool  usegubs,
SCIP_Bool cutoff,
int *  ncuts 
)

separates different classes of valid inequalities for the 0-1 knapsack problem

Parameters
scipSCIP data structure
consoriginating constraint of the knapsack problem, or NULL
sepaoriginating separator of the knapsack problem, or NULL
varsvariables in knapsack constraint
nvarsnumber of variables in knapsack constraint
weightsweights of variables in knapsack constraint
capacitycapacity of knapsack
solprimal SCIP solution to separate, NULL for current LP solution
usegubsshould GUB information be used for separation?
cutoffwhether a cutoff has been detected
ncutspointer to add up the number of found cuts

Definition at line 5517 of file cons_knapsack.c.

References FALSE, getCover(), getFeasibleSet(), GUBsetCreate(), GUBsetFree(), GUBsetGetCliquePartition(), makeCoverMinimal(), SCIP_GUBSet::ngubconss, NULL, SCIP_GUBSet::nvars, SCIP_Bool, SCIP_CALL, SCIP_Longint, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPconsGetName(), SCIPdebugMessage, SCIPdebugPrintf, SCIPfreeBufferArray, SCIPgetSolVals(), SCIPincConsAge(), SCIPvarGetName(), separateSequLiftedMinimalCoverInequality(), separateSupLiftedMinimalCoverInequality(), TRUE, and USESUPADDLIFT.

Referenced by SCIPseparateRelaxedKnapsack(), and separateCons().

SCIP_RETCODE SCIPseparateRelaxedKnapsack ( SCIP scip,
SCIP_CONS cons,
SCIP_SEPA sepa,
int  nknapvars,
SCIP_VAR **  knapvars,
SCIP_Real knapvals,
SCIP_Real  valscale,
SCIP_Real  rhs,
SCIP_SOL sol,
SCIP_Bool cutoff,
int *  ncuts 
)
Parameters
scipSCIP data structure
consoriginating constraint of the knapsack problem, or NULL
sepaoriginating separator of the knapsack problem, or NULL
nknapvarsnumber of variables in the continuous knapsack constraint
knapvarsvariables in the continuous knapsack constraint
knapvalscoefficient of the variables in the continuous knapsack constraint
valscale-1.0 if lhs of row is used as rhs of c. k. constraint, +1.0 otherwise
rhsright hand side of the continuous knapsack constraint
solprimal CIP solution, NULL for current LP solution
cutoffpointer to store whether a cutoff was found
ncutspointer to add up the number of found cuts

Definition at line 5730 of file cons_knapsack.c.

References BMSclearMemoryArray, CONSHDLR_NAME, DEFAULT_USEGUBS, FALSE, KNAPSACKRELAX_MAXDELTA, KNAPSACKRELAX_MAXDNOM, KNAPSACKRELAX_MAXSCALE, MAXABSVBCOEF, NULL, REALABS, SCIP_Bool, SCIP_CALL, SCIP_Longint, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPcalcIntegralScalar(), SCIPconsGetName(), SCIPconshdlrGetData(), SCIPdebug, SCIPdebugMessage, SCIPdebugPrintCons, SCIPdebugPrintf, SCIPepsilon(), SCIPfeasFloor(), SCIPfindConshdlr(), SCIPfloor(), SCIPfreeBufferArray, SCIPgetNContVars(), SCIPgetNegatedVar(), SCIPgetNVars(), SCIPgetSolVal(), SCIPgetVars(), SCIPisGE(), SCIPisGT(), SCIPisInfinity(), SCIPisLE(), SCIPisLT(), SCIPreallocMemoryArray, SCIPseparateKnapsackCuts(), SCIPvarGetLbGlobal(), SCIPvarGetLbLocal(), SCIPvarGetName(), SCIPvarGetNVlbs(), SCIPvarGetNVubs(), SCIPvarGetProbindex(), SCIPvarGetUbGlobal(), SCIPvarGetUbLocal(), SCIPvarGetVlbCoefs(), SCIPvarGetVlbConstants(), SCIPvarGetVlbVars(), SCIPvarGetVubCoefs(), SCIPvarGetVubConstants(), SCIPvarGetVubVars(), SCIPvarIsActive(), SCIPvarIsBinary(), and TRUE.

Referenced by addCut(), and separateCons().

static SCIP_RETCODE separateCons ( SCIP scip,
SCIP_CONS cons,
SCIP_SOL sol,
SCIP_Bool  sepacuts,
SCIP_Bool  usegubs,
SCIP_Bool cutoff,
int *  ncuts 
)
static

separates given knapsack constraint

Parameters
scipSCIP data structure
consknapsack constraint
solprimal SCIP solution, NULL for current LP solution
sepacutsshould knapsack cuts be separated?
usegubsshould GUB information be used for separation?
cutoffwhether a cutoff has been detected
ncutspointer to add up the number of found cuts

Definition at line 6148 of file cons_knapsack.c.

References addRelaxation(), checkCons(), FALSE, NULL, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIPconsGetData(), SCIPconsGetName(), SCIPdebugMessage, and SCIPseparateKnapsackCuts().

Referenced by SCIP_DECL_CONSSEPALP(), and SCIP_DECL_CONSSEPASOL().

static SCIP_RETCODE removeZeroWeights ( SCIP scip,
SCIP_CONS cons 
)
static

removes all items with weight zero from knapsack constraint

Parameters
scipSCIP data structure
consknapsack constraint

Definition at line 6468 of file cons_knapsack.c.

References delCoefPos(), NULL, SCIP_CALL, SCIP_OKAY, and SCIPconsGetData().

Referenced by tightenWeights().

static SCIP_RETCODE performVarDeletions ( SCIP scip,
SCIP_CONSHDLR conshdlr,
SCIP_CONS **  conss,
int  nconss 
)
static
Parameters
scipSCIP data structure
conshdlrconstraint handler
conssarray of constraints
nconssnumber of constraints

Definition at line 6492 of file cons_knapsack.c.

References CONSHDLR_NAME, delCoefPos(), FALSE, NULL, SCIP_CALL, SCIP_OKAY, SCIPconsGetData(), SCIPconshdlrGetName(), and SCIPvarIsDeleted().

Referenced by SCIP_DECL_CONSDELVARS().

static SCIP_RETCODE mergeMultiples ( SCIP scip,
SCIP_CONS cons,
SCIP_Bool cutoff 
)
static

replaces multiple occurrences of a variable or its negation by a single coefficient

Parameters
scipSCIP data structure
consknapsack constraint
cutoffpointer to store whether the node can be cut off

Definition at line 6534 of file cons_knapsack.c.

References consdataChgWeight(), delCoefPos(), FALSE, NULL, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_VARSTATUS_NEGATED, SCIPconsGetData(), SCIPdebugMessage, SCIPsortPtrPtrLongIntInt(), SCIPvarGetNegatedVar(), SCIPvarGetStatus(), SCIPvarIsActive(), SCIPvarIsBinary(), and TRUE.

Referenced by addCliques(), addNegatedCliques(), applyFixings(), SCIP_DECL_CONSPRESOL(), simplifyInequalities(), tightenWeights(), and tightenWeightsLift().

static SCIP_RETCODE dualPresolving ( SCIP scip,
SCIP_CONS cons,
int *  nfixedvars,
int *  ndelconss,
SCIP_Bool deleted 
)
static

in case the knapsack constraint is independent of every else, solve the knapsack problem (exactly) and apply the fixings (dual reductions)

Parameters
scipSCIP data structure
consknapsack constraint
nfixedvarspointer to count number of fixings
ndelconsspointer to count number of deleted constraints
deletedpointer to store if the constraint is deleted

Definition at line 6677 of file cons_knapsack.c.

References FALSE, NULL, SCIP_GUBSet::nvars, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPconsGetData(), SCIPconsGetName(), SCIPconsIsChecked(), SCIPconsIsModifiable(), SCIPdebugMessage, SCIPdebugPrintCons, SCIPdelCons(), SCIPfreeBufferArray, SCIPsolveKnapsackExactly(), SCIPtightenVarLb(), SCIPtightenVarUb(), SCIPvarGetLbGlobal(), SCIPvarGetName(), SCIPvarGetNLocksDown(), SCIPvarGetNLocksUp(), SCIPvarGetObj(), SCIPvarGetProbvarBinary(), SCIPvarGetUbGlobal(), SCIPvarIsActive(), and TRUE.

Referenced by SCIP_DECL_CONSPRESOL().

static SCIP_RETCODE checkParallelObjective ( SCIP scip,
SCIP_CONS cons,
SCIP_CONSHDLRDATA conshdlrdata 
)
static

check if the knapsack constraint is parallel to objective function; if so update the cutoff bound and avoid that the constraint enters the LP by setting the initial and separated flag to FALSE

Parameters
scipSCIP data structure
consknapsack constraint
conshdlrdataknapsack constraint handler data

Definition at line 6818 of file cons_knapsack.c.

References FALSE, NULL, SCIP_GUBSet::nvars, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPconsGetData(), SCIPconsGetName(), SCIPconsIsInitial(), SCIPconsIsSeparated(), SCIPcutoffbounddelta(), SCIPdebugMessage, SCIPgetCutoffbound(), SCIPgetNObjVars(), SCIPisEQ(), SCIPisNegative(), SCIPisPositive(), SCIPisZero(), SCIPsetConsEnforced(), SCIPsetConsInitial(), SCIPsetConsPropagated(), SCIPsetConsSeparated(), SCIPupdateCutoffbound(), SCIPupdateLocalLowerbound(), SCIPvarGetNegatedVar(), SCIPvarGetObj(), SCIPvarIsNegated(), and TRUE.

Referenced by SCIP_DECL_CONSPRESOL().

static SCIP_RETCODE stableSort ( SCIP scip,
SCIP_CONSDATA consdata,
SCIP_VAR **  vars,
SCIP_Longint weights,
int *  cliquestartposs,
SCIP_Bool  usenegatedclique 
)
static

sort the variables and weights w.r.t. the clique partition; thereby ensure the current order of the variables when a weight of one variable is greater or equal another weight and both variables are in the same cliques

Parameters
scipSCIP data structure
consdataknapsack constraint data
varsarray for sorted variables
weightsarray for sorted weights
cliquestartpossstarting position array for each clique
usenegatedcliqueshould negated or normal clique partition be used

Definition at line 6963 of file cons_knapsack.c.

References BMSclearMemoryArray, NULL, SCIP_CALL, SCIP_Longint, SCIP_OKAY, SCIPallocBufferArray, and SCIPfreeBufferArray.

Referenced by propagateCons().

static SCIP_RETCODE propagateCons ( SCIP scip,
SCIP_CONS cons,
SCIP_Bool cutoff,
SCIP_Bool redundant,
int *  nfixedvars,
SCIP_Bool  usenegatedclique 
)
static

propagation method for knapsack constraints

Parameters
scipSCIP data structure
consknapsack constraint
cutoffpointer to store whether the node can be cut off
redundantpointer to store whether constraint is redundant
nfixedvarspointer to count number of fixings
usenegatedcliqueshould negated clique information be used

Definition at line 7087 of file cons_knapsack.c.

References BMSclearMemoryArray, calcCliquepartition(), FALSE, NULL, SCIP_GUBSet::nvars, SCIP_Bool, SCIP_CALL, SCIP_Longint, SCIP_OKAY, SCIP_STAGE_SOLVING, SCIPaddConflictBinvar(), SCIPallocBufferArray, SCIPanalyzeConflictCons(), SCIPconsGetData(), SCIPconsGetName(), SCIPconsIsModifiable(), SCIPdebugMessage, SCIPdelConsLocal(), SCIPduplicateBufferArray, SCIPfreeBufferArray, SCIPgetStage(), SCIPincConsAge(), SCIPinferBinvarCons(), SCIPinitConflictAnalysis(), SCIPinProbing(), SCIPinRepropagation(), SCIPisConflictAnalysisApplicable(), SCIPresetConsAge(), SCIPvarGetIndex(), SCIPvarGetLbLocal(), SCIPvarGetName(), SCIPvarGetUbLocal(), sortItems(), stableSort(), and TRUE.

Referenced by SCIP_DECL_CONSPRESOL(), and SCIP_DECL_CONSPROP().

static SCIP_RETCODE upgradeCons ( SCIP scip,
SCIP_CONS cons,
int *  ndelconss,
int *  naddconss 
)
static

all but one variable fit into the knapsack constraint, so we can upgrade this constraint to an logicor constraint containing all negated variables of this knapsack constraint

Parameters
scipSCIP data structure
consknapsack constraint
ndelconsspointer to store the amount of deleted constraints
naddconsspointer to count number of added constraints

Definition at line 7531 of file cons_knapsack.c.

References NULL, SCIP_CALL, SCIP_OKAY, SCIPaddCons(), SCIPallocBufferArray, SCIPconsGetData(), SCIPconsGetName(), SCIPconsIsChecked(), SCIPconsIsDynamic(), SCIPconsIsEnforced(), SCIPconsIsInitial(), SCIPconsIsLocal(), SCIPconsIsModifiable(), SCIPconsIsPropagated(), SCIPconsIsRemovable(), SCIPconsIsSeparated(), SCIPconsIsStickingAtNode(), SCIPcreateConsLogicor(), SCIPcreateConsSetpack(), SCIPdebugMessage, SCIPdelCons(), SCIPfreeBufferArray, SCIPgetNegatedVars(), and SCIPreleaseCons().

Referenced by detectRedundantVars(), and dualWeightsTightening().

static SCIP_RETCODE deleteRedundantVars ( SCIP scip,
SCIP_CONS cons,
SCIP_Longint  frontsum,
int  splitpos,
int *  nchgcoefs,
int *  nchgsides,
int *  naddconss 
)
static

delete redundant variables

i.e. 5x1 + 5x2 + 5x3 + 2x4 + 1x5 <= 13 => x4, x5 always fits into the knapsack, so we can delete them

i.e. 5x1 + 5x2 + 5x3 + 2x4 + 1x5 <= 8 and we have the cliqueinformation (x1,x2,x3) is a clique => x4, x5 always fits into the knapsack, so we can delete them

i.e. 5x1 + 5x2 + 5x3 + 1x4 + 1x5 <= 6 and we have the cliqueinformation (x1,x2,x3) is a clique and (x4,x5) too => we create the set partitioning constraint x4 + x5 <= 1 and delete them in this knapsack

Parameters
scipSCIP data structure
consknapsack constraint
frontsumsum of front items which fit if we try to take from the first till the last
splitpossplit position till when all front items are fitting, splitpos is the first which did not fit
nchgcoefspointer to store the amount of changed coefficients
nchgsidespointer to store the amount of changed sides
naddconsspointer to count number of added constraints

Definition at line 7603 of file cons_knapsack.c.

References consdataChgWeight(), delCoefPos(), NULL, SCIP_GUBSet::nvars, SCIP_CALL, SCIP_Longint, SCIP_MAXSTRLEN, SCIP_OKAY, SCIPaddCons(), SCIPallocBufferArray, SCIPcalcCliquePartition(), SCIPcalcGreComDiv(), SCIPconsGetData(), SCIPconsGetHdlr(), SCIPconsGetName(), SCIPconshdlrGetData(), SCIPconsIsChecked(), SCIPconsIsDynamic(), SCIPconsIsEnforced(), SCIPconsIsInitial(), SCIPconsIsLocal(), SCIPconsIsModifiable(), SCIPconsIsPropagated(), SCIPconsIsRemovable(), SCIPconsIsSeparated(), SCIPconsIsStickingAtNode(), SCIPcreateConsSetpack(), SCIPdebugMessage, SCIPdebugPrintCons, SCIPfreeBufferArray, SCIPreleaseCons(), SCIPsnprintf(), and TRUE.

Referenced by detectRedundantVars().

static SCIP_RETCODE detectRedundantVars ( SCIP scip,
SCIP_CONS cons,
int *  ndelconss,
int *  nchgcoefs,
int *  nchgsides,
int *  naddconss 
)
static
Parameters
scipSCIP data structure
consknapsack constraint
ndelconsspointer to store the amount of deleted constraints
nchgcoefspointer to store the amount of changed coefficients
nchgsidespointer to store the amount of changed sides
naddconsspointer to count number of added constraints

Definition at line 7846 of file cons_knapsack.c.

References calcCliquepartition(), deleteRedundantVars(), FALSE, NULL, SCIP_GUBSet::nvars, SCIP_CALL, SCIP_Longint, SCIP_MAXSTRLEN, SCIP_OKAY, SCIPaddCons(), SCIPallocBufferArray, SCIPconsGetData(), SCIPconsGetHdlr(), SCIPconsGetName(), SCIPconshdlrGetData(), SCIPconsIsChecked(), SCIPconsIsDeleted(), SCIPconsIsDynamic(), SCIPconsIsEnforced(), SCIPconsIsInitial(), SCIPconsIsLocal(), SCIPconsIsModifiable(), SCIPconsIsPropagated(), SCIPconsIsRemovable(), SCIPconsIsSeparated(), SCIPconsIsStickingAtNode(), SCIPcreateConsSetpack(), SCIPdebugMessage, SCIPdebugPrintCons, SCIPdelConsLocal(), SCIPfreeBufferArray, SCIPreleaseCons(), SCIPsnprintf(), TRUE, and upgradeCons().

Referenced by simplifyInequalities().

static void normalizeWeights ( SCIP_CONS cons,
int *  nchgcoefs,
int *  nchgsides 
)
static

divides weights by their greatest common divisor and divides capacity by the same value, rounding down the result

Parameters
consknapsack constraint
nchgcoefspointer to count total number of changed coefficients
nchgsidespointer to count number of side changes

Definition at line 8035 of file cons_knapsack.c.

References consdataChgWeight(), NULL, SCIP_Longint, SCIPcalcGreComDiv(), SCIPconsGetData(), SCIPconsGetName(), SCIPconsIsModifiable(), SCIPdebugMessage, SCIPvarGetLbLocal(), SCIPvarGetUbLocal(), sortItems(), and TRUE.

Referenced by dualWeightsTightening(), and SCIP_DECL_CONSPRESOL().

static SCIP_RETCODE dualWeightsTightening ( SCIP scip,
SCIP_CONS cons,
int *  ndelconss,
int *  nchgcoefs,
int *  nchgsides,
int *  naddconss 
)
static

dual weights tightening for knapsack constraints

  1. a) check if all two pairs exceed the capacity, then we can upgrade this constraint to a set-packing constraint b) check if all but the smallest weight fit into the knapsack, then we can upgrade this constraint to a logicor constraint
  1. check if besides big coefficients, that fit only by itself, for a certain amount of variables all combination of these are a minimal cover, then might reduce the weights and the capacity, e.g.

    +219y1 + 180y2 + 74x1 + 70x2 + 63x3 + 62x4 + 53x5 <= 219 <=> 3y1 + 3y2 + x1 + x2 + x3 + x4 + x5 <= 3

  1. use the duality between a^Tx <= capacity <=> a^T~x >= weightsum - capacity to tighten weights, e.g.

    11x1 + 10x2 + 7x3 + 7x4 + 5x5 <= 27 <=> 10~x1 + 10~x2 + 7~x3 + 7~x4 + 5~x5 >= 13

    the above constraint can be changed to 8~x1 + 8~x2 + 6.5~x3 + 6.5~x4 + 5~x5 >= 13

    16~x1 + 16~x2 + 13~x3 + 13~x4 + 10~x5 >= 26 <=> 16x1 + 16x2 + 13x3 + 13x4 + 10x5 <= 42

Parameters
scipSCIP data structure
consknapsack constraint
ndelconsspointer to store the amount of deleted constraints
nchgcoefspointer to store the amount of changed coefficients
nchgsidespointer to store the amount of changed sides
naddconsspointer to count number of added constraints

Definition at line 8107 of file cons_knapsack.c.

References consdataChgWeight(), delCoefPos(), FALSE, MIN, normalizeWeights(), NULL, SCIP_GUBSet::nvars, SCIP_Bool, SCIP_CALL, SCIP_ERROR, SCIP_Longint, SCIP_OKAY, SCIPaddCons(), SCIPconsGetData(), SCIPconsGetName(), SCIPconsIsChecked(), SCIPconsIsDeleted(), SCIPconsIsDynamic(), SCIPconsIsEnforced(), SCIPconsIsInitial(), SCIPconsIsLocal(), SCIPconsIsModifiable(), SCIPconsIsPropagated(), SCIPconsIsRemovable(), SCIPconsIsSeparated(), SCIPconsIsStickingAtNode(), SCIPcreateConsSetpack(), SCIPdebugMessage, SCIPdelCons(), SCIPreleaseCons(), TRUE, and upgradeCons().

Referenced by simplifyInequalities().

static SCIP_RETCODE prepareCons ( SCIP scip,
SCIP_CONS cons,
int *  nfixedvars,
int *  ndelconss,
int *  nchgcoefs 
)
static

fixes variables with weights bigger than the capacity and delete redundant constraints, also sort weights

Parameters
scipSCIP data structure
consknapsack constraint
nfixedvarspointer to store the amount of fixed variables
ndelconsspointer to store the amount of deleted constraints
nchgcoefspointer to store the amount of changed coefficients

Definition at line 8958 of file cons_knapsack.c.

References delCoefPos(), NULL, SCIP_GUBSet::nvars, SCIP_Bool, SCIP_CALL, SCIP_Longint, SCIP_OKAY, SCIP_Real, SCIPconsGetData(), SCIPdelCons(), SCIPfixVar(), SCIPisHugeValue(), and sortItems().

Referenced by simplifyInequalities().

static SCIP_RETCODE simplifyInequalities ( SCIP scip,
SCIP_CONS cons,
int *  nfixedvars,
int *  ndelconss,
int *  nchgcoefs,
int *  nchgsides,
int *  naddconss,
SCIP_Bool cutoff 
)
static

tries to simplify weights and delete redundant variables in knapsack a^Tx <= capacity

  1. use the duality between a^Tx <= capacity <=> -a^T~x <= capacity - weightsum to tighten weights, e.g.

    11x1 + 10x2 + 7x3 + 5x4 + 5x5 <= 25 <=> -10~x1 - 10~x2 - 7~x3 - 5~x4 - 5~x5 <= -13

    the above constraint can be changed to

    -8~x1 - 8~x2 - 7~x3 - 5~x4 - 5~x5 <= -12 <=> 8x1 + 8x2 + 7x3 + 5x4 + 5x5 <= 20

  1. if variables in a constraint do not affect the (in-)feasibility of the constraint, we can delte them, e.g.

    7x1 + 6x2 + 5x3 + 5x4 + x5 + x6 <= 20 => x5 and x6 are redundant and can be removed

  1. Tries to use gcd information an all but one weight to change this not-included weight and normalize the constraint further, e.g.

    9x1 + 6x2 + 6x3 + 5x4 <= 13 => 9x1 + 6x2 + 6x3 + 6x4 <= 12 => 3x1 + 2x2 + 2x3 + 2x4 <= 4 => 4x1 + 2x2 + 2x3 + 2x4 <= 4 => 2x1 + x2 + x3 + x4 <= 2 9x1 + 6x2 + 6x3 + 7x4 <= 13 => 9x1 + 6x2 + 6x3 + 6x4 <= 12 => see above

Parameters
scipSCIP data structure
consknapsack constraint
nfixedvarspointer to store the amount of fixed variables
ndelconsspointer to store the amount of deleted constraints
nchgcoefspointer to store the amount of changed coefficients
nchgsidespointer to store the amount of changed sides
naddconsspointer to count number of added constraints
cutoffpointer to store whether the node can be cut off

Definition at line 9075 of file cons_knapsack.c.

References consdataChgWeight(), delCoefPos(), detectRedundantVars(), dualWeightsTightening(), FALSE, mergeMultiples(), NULL, SCIP_GUBSet::nvars, prepareCons(), SCIP_CALL, SCIP_Longint, SCIP_OKAY, SCIP_Real, SCIPcalcGreComDiv(), SCIPconsGetData(), SCIPconsGetName(), SCIPconsIsDeleted(), SCIPconsIsModifiable(), SCIPdebugMessage, SCIPdebugPrintCons, SCIPisHugeValue(), SCIPvarGetName(), and TRUE.

Referenced by SCIP_DECL_CONSPRESOL().

static SCIP_RETCODE applyFixings ( SCIP scip,
SCIP_CONS cons,
SCIP_Bool cutoff 
)
static

deletes all fixed variables from knapsack constraint, and replaces variables with binary representatives

Parameters
scipSCIP data structure
consknapsack constraint
cutoffpointer to store whether the node can be cut off, or NULL if this information is not needed; in this case, we apply all fixings instead of stopping after the first infeasible one

Definition at line 9328 of file cons_knapsack.c.

References addCoef(), delCoefPos(), FALSE, mergeMultiples(), NULL, SCIP_GUBSet::nvars, SCIP_Bool, SCIP_CALL, SCIP_ERROR, SCIP_Longint, SCIP_OKAY, SCIP_Real, SCIP_VARSTATUS_MULTAGGR, SCIPconsGetData(), SCIPdebugMessage, SCIPdebugPrintCons, SCIPerrorMessage, SCIPflattenVarAggregationGraph(), SCIPfloor(), SCIPgetBinvarRepresentative(), SCIPgetNegatedVar(), SCIPisFeasEQ(), SCIPisIntegral(), SCIPisNegative(), SCIPvarGetLbGlobal(), SCIPvarGetMultaggrConstant(), SCIPvarGetMultaggrNVars(), SCIPvarGetMultaggrScalars(), SCIPvarGetMultaggrVars(), SCIPvarGetNegatedVar(), SCIPvarGetStatus(), SCIPvarGetUbGlobal(), SCIPvarIsBinary(), SCIPvarIsNegated(), and TRUE.

Referenced by SCIP_DECL_CONSEXITPRE(), and SCIP_DECL_CONSPRESOL().

static SCIP_RETCODE insertZerolist ( SCIP scip,
int **  liftcands,
int *  nliftcands,
int **  firstidxs,
SCIP_Longint **  zeroweightsums,
int **  zeroitems,
int **  nextidxs,
int *  zeroitemssize,
int *  nzeroitems,
int  probindex,
SCIP_Bool  value,
int  knapsackidx,
SCIP_Longint  knapsackweight,
SCIP_Bool memlimitreached 
)
static

inserts an element into the list of binary zero implications

Parameters
scipSCIP data structure
liftcandsarray of the lifting candidates
nliftcandsnumber of lifting candidates
firstidxsarray of first zeroitems indices
zeroweightsumsarray of sums of weights of the implied-to-zero items
zeroitemspointer to zero items array
nextidxspointer to array of next zeroitems indeces
zeroitemssizepointer to size of zero items array
nzeroitemspointer to length of zero items array
probindexproblem index of variable y in implication y == v -> x == 0
valuevalue v of variable y in implication
knapsackidxindex of variable x in knapsack
knapsackweightweight of variable x in knapsack
memlimitreachedpointer to store whether the memory limit was reached

Definition at line 9538 of file cons_knapsack.c.

References FALSE, MAX_ZEROITEMS_SIZE, MIN, NULL, SCIP_CALL, SCIP_OKAY, SCIPdebugMessage, SCIPgetNContVars(), SCIPgetNVars(), SCIPreallocBufferArray, and TRUE.

Referenced by tightenWeightsLift().

static SCIP_RETCODE tightenWeightsLift ( SCIP scip,
SCIP_CONS cons,
int *  nchgcoefs,
SCIP_Bool cutoff 
)
static

applies rule (3) of the weight tightening procedure, which can lift other variables into the knapsack: (3) for a clique C let C(xi == v) := C \ {j: xi == v -> xj == 0}), let cliqueweightsum(xi == v) := sum(W(C(xi == v))) if cliqueweightsum(xi == v) < capacity:

  • fixing variable xi to v would make the knapsack constraint redundant
  • the weight of the variable or its negation (depending on v) can be increased as long as it has the same redundancy effect: wi' := capacity - cliqueweightsum(xi == v) this rule can also be applied to binary variables not in the knapsack!
Parameters
scipSCIP data structure
consknapsack constraint
nchgcoefspointer to count total number of changed coefficients
cutoffpointer to store whether the node can be cut off

Definition at line 9624 of file cons_knapsack.c.

References addCoef(), BMSclearMemoryArray, calcCliquepartition(), FALSE, insertZerolist(), MAX_CLIQUELENGTH, MAX_USECLIQUES_SIZE, MAX_ZEROITEMS_SIZE, mergeMultiples(), MIN, NULL, SCIP_GUBSet::nvars, SCIP_Bool, SCIP_BOUNDTYPE_UPPER, SCIP_CALL, SCIP_Longint, SCIP_OKAY, SCIPallocBufferArray, SCIPcliqueGetNVars(), SCIPcliqueGetValues(), SCIPcliqueGetVars(), SCIPconsGetData(), SCIPconsGetHdlr(), SCIPconsGetName(), SCIPconshdlrGetData(), SCIPconsIsModifiable(), SCIPdebugMessage, SCIPfreeBufferArray, SCIPgetNContVars(), SCIPgetNegatedVar(), SCIPgetNVars(), SCIPgetVars(), SCIPreallocMemoryArray, SCIPvarGetCliques(), SCIPvarGetImplTypes(), SCIPvarGetImplVars(), SCIPvarGetName(), SCIPvarGetNBinImpls(), SCIPvarGetNCliques(), SCIPvarGetProbindex(), SCIPvarGetProbvarBinary(), SCIPvarIsBinary(), sortItems(), and TRUE.

Referenced by tightenWeights().

static SCIP_RETCODE tightenWeights ( SCIP scip,
SCIP_CONS cons,
int *  nchgcoefs,
int *  nchgsides,
int *  naddconss,
int *  ndelconss,
SCIP_Bool cutoff 
)
static

tightens item weights and capacity in presolving: given a knapsack sum(wi*xi) <= capacity (1) let weightsum := sum(wi) if weightsum - wi < capacity:

  • not using item i would make the knapsack constraint redundant
  • wi and capacity can be changed to have the same redundancy effect and the same results for fixing xi to zero or one, but with a reduced wi and tightened capacity to tighten the LP relaxation
  • change coefficients: wi' := weightsum - capacity capacity' := capacity - (wi - wi') (2) increase weights from front to back(sortation is necessary) if there is no space left for another weight
  • determine the four(can be adjusted) minimal weightsums of the knapsack, i.e. in increasing order weights[nvars - 1], weights[nvars - 2], MIN(weights[nvars - 3], weights[nvars - 1] + weights[nvars - 2]), MIN(MAX(weights[nvars - 3], weights[nvars - 1] + weights[nvars - 2]), weights[nvars - 4]), note that there can be multiple times the same weight, this can be improved
  • check if summing up a minimal weightsum with a big weight exceeds the capacity, then we can increase the big weight, to capacity - lastmininmalweightsum, e.g. : 19x1 + 15x2 + 10x3 + 5x4 + 5x5 <= 19 -> minimal weightsums: 5, 5, 10, 10 -> 15 + 5 > 19 => increase 15 to 19 - 0 = 19 -> 10 + 10 > 19 => increase 10 to 19 - 5 = 14, resulting in 19x1 + 19x2 + 14x3 + 5x4 + 5x5 <= 19 (3) let W(C) be the maximal weight of clique C, cliqueweightsum := sum(W(C)) if cliqueweightsum - W(C) < capacity:
  • not using any item of C would make the knapsack constraint redundant
  • weights wi, i in C, and capacity can be changed to have the same redundancy effect and the same results for fixing xi, i in C, to zero or one, but with a reduced wi and tightened capacity to tighten the LP relaxation
  • change coefficients: delta := capacity - (cliqueweightsum - W(C)) wi' := max(wi - delta, 0) capacity' := capacity - delta This rule has to add the used cliques in order to ensure they are enforced - otherwise, the reduction might introduce infeasible solutions. (4) for a clique C let C(xi == v) := C \ {j: xi == v -> xj == 0}), let cliqueweightsum(xi == v) := sum(W(C(xi == v))) if cliqueweightsum(xi == v) < capacity:
  • fixing variable xi to v would make the knapsack constraint redundant
  • the weight of the variable or its negation (depending on v) can be increased as long as it has the same redundancy effect: wi' := capacity - cliqueweightsum(xi == v) This rule can also be applied to binary variables not in the knapsack! (5) if min{w} + wi > capacity:
  • using item i would force to fix other items to zero
  • wi can be increased to the capacity
Parameters
scipSCIP data structure
consknapsack constraint
nchgcoefspointer to count total number of changed coefficients
nchgsidespointer to count number of side changes
naddconsspointer to count number of added constraints
ndelconsspointer to count number of deleted constraints
cutoffpointer to store whether the node can be cut off

Definition at line 10248 of file cons_knapsack.c.

References calcCliquepartition(), consdataChgWeight(), FALSE, MAX, MAX_USECLIQUES_SIZE, mergeMultiples(), NULL, SCIP_GUBSet::nvars, removeZeroWeights(), SCIP_Bool, SCIP_CALL, SCIP_ERROR, SCIP_Longint, SCIP_MAXSTRLEN, SCIP_OKAY, SCIPaddCons(), SCIPallocBufferArray, SCIPcalcCliquePartition(), SCIPconsGetData(), SCIPconsGetHdlr(), SCIPconsGetName(), SCIPconshdlrGetData(), SCIPconsIsChecked(), SCIPconsIsDeleted(), SCIPconsIsDynamic(), SCIPconsIsEnforced(), SCIPconsIsInitial(), SCIPconsIsLocal(), SCIPconsIsModifiable(), SCIPconsIsPropagated(), SCIPconsIsRemovable(), SCIPconsIsSeparated(), SCIPconsIsStickingAtNode(), SCIPcreateConsSetpack(), SCIPdebugMessage, SCIPdebugPrintCons, SCIPdelCons(), SCIPfreeBufferArray, SCIPreleaseCons(), SCIPsnprintf(), SCIPvarGetName(), sortItems(), tightenWeightsLift(), and TRUE.

Referenced by SCIP_DECL_CONSPRESOL().

static SCIP_RETCODE addNegatedCliques ( SCIP *const  scip,
SCIP_CONS *const  cons,
SCIP_Bool *const  cutoff,
int *const  nbdchgs 
)
static

adds negated cliques of the knapsack constraint to the global clique table

Parameters
scipSCIP data structure
consknapsack constraint
cutoffpointer to store whether the node can be cut off
nbdchgspointer to count the number of performed bound changes

Definition at line 10804 of file cons_knapsack.c.

References BMSclearMemoryArray, calcCliquepartition(), FALSE, mergeMultiples(), NULL, SCIP_GUBSet::nvars, SCIP_Bool, SCIP_CALL, SCIP_Longint, SCIP_OKAY, SCIPaddClique(), SCIPallocBufferArray, SCIPconsGetData(), SCIPconsGetName(), SCIPdebugMessage, SCIPdebugPrintCons, SCIPdebugPrintf, SCIPfreeBufferArray, SCIPgetNegatedVar(), SCIPsortDownLongPtrInt(), SCIPvarGetName(), sortItems(), and TRUE.

Referenced by addCliques().

static SCIP_RETCODE addCliques ( SCIP *const  scip,
SCIP_CONS *const  cons,
SCIP_Bool *const  cutoff,
int *const  nbdchgs 
)
static

adds cliques of the knapsack constraint to the global clique table

Parameters
scipSCIP data structure
consknapsack constraint
cutoffpointer to store whether the node can be cut off
nbdchgspointer to count the number of performed bound changes

Definition at line 11012 of file cons_knapsack.c.

References addNegatedCliques(), BMSclearMemoryArray, calcCliquepartition(), FALSE, mergeMultiples(), NULL, SCIP_GUBSet::nvars, SCIP_CALL, SCIP_Longint, SCIP_OKAY, SCIPaddClique(), SCIPallocBufferArray, SCIPconsGetData(), SCIPconsGetName(), SCIPdebugMessage, SCIPdebugPrintCons, SCIPdebugPrintf, SCIPfreeBufferArray, SCIPsortDownLongPtr(), SCIPvarGetName(), sortItems(), and TRUE.

Referenced by SCIP_DECL_CONSPRESOL().

static SCIP_DECL_HASHGETKEY ( hashGetKeyKnapsackcons  )
static

gets the key of the given element

Definition at line 11245 of file cons_knapsack.c.

static SCIP_DECL_HASHKEYEQ ( hashKeyEqKnapsackcons  )
static

returns TRUE iff both keys are equal; two constraints are equal if they have the same variables and the same coefficients

Definition at line 11255 of file cons_knapsack.c.

References FALSE, NULL, SCIPconsGetData(), SCIPvarCompare(), and TRUE.

static SCIP_DECL_HASHKEYVAL ( hashKeyValKnapsackcons  )
static

returns the hash value of the key

Definition at line 11298 of file cons_knapsack.c.

References NULL, SCIPconsGetData(), SCIPvarGetIndex(), and sortItems().

static SCIP_RETCODE detectRedundantConstraints ( SCIP scip,
BMS_BLKMEM blkmem,
SCIP_CONS **  conss,
int  nconss,
SCIP_Bool cutoff,
int *  ndelconss 
)
static

compares each constraint with all other constraints for possible redundancy and removes or changes constraint accordingly; in contrast to preprocessConstraintPairs(), it uses a hash table

Parameters
scipSCIP data structure
blkmemblock memory
conssconstraint set
nconssnumber of constraints in constraint set
cutoffpointer to store whether the problem is infeasible
ndelconsspointer to count number of deleted constraints

Definition at line 11342 of file cons_knapsack.c.

References HASHSIZE_KNAPSACKCONS, MAX, NULL, SCIP_CALL, SCIP_OKAY, SCIPcalcHashtableSize(), SCIPconsGetData(), SCIPconsGetName(), SCIPconsIsActive(), SCIPconsIsModifiable(), SCIPdebugMessage, SCIPdelCons(), SCIPhashtableCreate(), SCIPhashtableFree(), SCIPhashtableInsert(), SCIPhashtableRemove(), SCIPhashtableRetrieve(), SCIPupdateConsFlags(), and TRUE.

Referenced by SCIP_DECL_CONSPRESOL().

static SCIP_RETCODE preprocessConstraintPairs ( SCIP scip,
SCIP_CONS **  conss,
int  firstchange,
int  chkind,
int *  ndelconss 
)
static

compares constraint with all prior constraints for possible redundancy or aggregation, and removes or changes constraint accordingly

Parameters
scipSCIP data structure
conssconstraint set
firstchangefirst constraint that changed since last pair preprocessing round
chkindindex of constraint to check against all prior indices upto startind
ndelconsspointer to count number of deleted constraints

Definition at line 11465 of file cons_knapsack.c.

References FALSE, NULL, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPconsGetData(), SCIPconsGetName(), SCIPconsIsActive(), SCIPconsIsModifiable(), SCIPdebugMessage, SCIPdebugPrintCons, SCIPdelCons(), SCIPisGT(), SCIPisLT(), SCIPupdateConsFlags(), sortItems(), and TRUE.

Referenced by SCIP_DECL_CONSPRESOL().

static SCIP_RETCODE createNormalizedKnapsack ( SCIP scip,
SCIP_CONS **  cons,
const char *  name,
int  nvars,
SCIP_VAR **  vars,
SCIP_Real vals,
SCIP_Real  lhs,
SCIP_Real  rhs,
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 
)
static

creates and captures a knapsack constraint out of a linear inequality

Parameters
scipSCIP data structure
conspointer to hold the created constraint
namename of constraint
nvarsnumber of variables in the constraint
varsarray with variables of constraint entries
valsarray with inequality coefficients
lhsleft hand side of inequality
rhsright hand side of inequality
initialshould the LP relaxation of constraint be in the initial LP? Usually set to TRUE. Set to FALSE for 'lazy constraints'.
separateshould the constraint be separated during LP processing? Usually set to TRUE.
enforceshould the constraint be enforced during node processing? TRUE for model constraints, FALSE for additional, redundant constraints.
checkshould the constraint be checked for feasibility? TRUE for model constraints, FALSE for additional, redundant constraints.
propagateshould the constraint be propagated during node processing? Usually set to TRUE.
localis constraint only valid locally? Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints.
modifiableis constraint modifiable (subject to column generation)? Usually set to FALSE. In column generation applications, set to TRUE if pricing adds coefficients to this constraint.
dynamicis constraint subject to aging? Usually set to FALSE. Set to TRUE for own cuts which are separated as constraints.
removableshould the relaxation be removed from the LP due to aging or cleanup? Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'.
stickingatnodeshould the constraint always be kept at the node where it was added, even if it may be moved to a more global node? Usually set to FALSE. Set to TRUE to for constraints that represent node data.

Definition at line 11659 of file cons_knapsack.c.

References NULL, SCIP_GUBSet::nvars, SCIP_CALL, SCIP_Longint, SCIP_OKAY, SCIPallocBufferArray, SCIPcreateConsKnapsack(), SCIPfeasFloor(), SCIPfreeBufferArray, SCIPgetNegatedVar(), SCIPisFeasIntegral(), and SCIPisInfinity().

Referenced by SCIP_DECL_LINCONSUPGD().

static SCIP_DECL_CONSHDLRCOPY ( conshdlrCopyKnapsack  )
static

copy method for constraint handler plugins (called when SCIP copies plugins)

Definition at line 11792 of file cons_knapsack.c.

References CONSHDLR_NAME, NULL, SCIP_CALL, SCIP_OKAY, SCIPconshdlrGetName(), SCIPincludeConshdlrKnapsack(), and TRUE.

static SCIP_DECL_CONSFREE ( consFreeKnapsack  )
static

destructor of constraint handler to free constraint handler data (called when SCIP is exiting)

Definition at line 11808 of file cons_knapsack.c.

References NULL, SCIP_OKAY, SCIPconshdlrGetData(), SCIPconshdlrSetData(), and SCIPfreeMemory.

static SCIP_DECL_CONSINIT ( consInitKnapsack  )
static

initialization method of constraint handler (called after problem was transformed)

Definition at line 11826 of file cons_knapsack.c.

References BMSclearMemoryArray, NULL, SCIP_GUBSet::nvars, SCIP_CALL, SCIP_OKAY, SCIPallocMemoryArray, SCIPconshdlrGetData(), SCIPgetNContVars(), and SCIPgetNVars().

static SCIP_DECL_CONSEXIT ( consExitKnapsack  )
static

deinitialization method of constraint handler (called before transformed problem is freed)

Definition at line 11849 of file cons_knapsack.c.

References NULL, SCIP_OKAY, SCIPconshdlrGetData(), and SCIPfreeMemoryArrayNull.

static SCIP_DECL_CONSINITPRE ( consInitpreKnapsack  )
static

presolving initialization method of constraint handler (called when presolving is about to begin)

Definition at line 11868 of file cons_knapsack.c.

References BMSclearMemoryArray, NULL, SCIP_GUBSet::nvars, SCIP_CALL, SCIP_OKAY, SCIPallocMemoryArray, SCIPconshdlrGetData(), SCIPgetNContVars(), and SCIPgetNVars().

static SCIP_DECL_CONSEXITPRE ( consExitpreKnapsack  )
static

presolving deinitialization method of constraint handler (called after presolving has been finished)

Definition at line 11916 of file cons_knapsack.c.

References applyFixings(), NULL, SCIP_CALL, SCIP_OKAY, SCIPconshdlrGetData(), SCIPconsIsDeleted(), and SCIPfreeMemoryArrayNull.

static SCIP_DECL_CONSEXITSOL ( consExitsolKnapsack  )
static

solving process deinitialization method of constraint handler (called before branch and bound process data is freed)

Definition at line 11960 of file cons_knapsack.c.

References NULL, SCIP_CALL, SCIP_OKAY, SCIPconsGetData(), and SCIPreleaseRow().

static SCIP_DECL_CONSDELETE ( consDeleteKnapsack  )
static

frees specific constraint data

Definition at line 11984 of file cons_knapsack.c.

References consdataFree(), CONSHDLR_NAME, NULL, SCIP_CALL, SCIP_OKAY, SCIPconshdlrGetData(), and SCIPconshdlrGetName().

static SCIP_DECL_CONSINITLP ( consInitlpKnapsack  )
static

LP initialization method of constraint handler (called before the initial LP relaxation at a node is solved)

Definition at line 12041 of file cons_knapsack.c.

References addRelaxation(), NULL, SCIP_Bool, SCIP_CALL, SCIP_OKAY, and SCIPconsIsInitial().

static SCIP_DECL_CONSSEPASOL ( consSepasolKnapsack  )
static
static SCIP_DECL_CONSENFOLP ( consEnfolpKnapsack  )
static

constraint enforcing method of constraint handler for LP solutions

Definition at line 12193 of file cons_knapsack.c.

References addRelaxation(), checkCons(), FALSE, NULL, SCIP_Bool, SCIP_CALL, SCIP_CUTOFF, SCIP_FEASIBLE, SCIP_OKAY, SCIP_SEPARATED, SCIPconshdlrGetData(), SCIPdebugMessage, and SCIPgetDepth().

static SCIP_DECL_CONSENFOPS ( consEnfopsKnapsack  )
static

constraint enforcing method of constraint handler for pseudo solutions

Definition at line 12246 of file cons_knapsack.c.

References checkCons(), FALSE, NULL, SCIP_Bool, SCIP_CALL, SCIP_FEASIBLE, SCIP_INFEASIBLE, SCIP_OKAY, and TRUE.

static SCIP_DECL_CONSCHECK ( consCheckKnapsack  )
static

feasibility check method of constraint handler for integral solutions

Definition at line 12267 of file cons_knapsack.c.

References checkCons(), SCIP_Bool, SCIP_CALL, SCIP_FEASIBLE, SCIP_INFEASIBLE, and SCIP_OKAY.

static SCIP_DECL_CONSPROP ( consPropKnapsack  )
static
static SCIP_DECL_CONSRESPROP ( consRespropKnapsack  )
static
static SCIP_DECL_CONSLOCK ( consLockKnapsack  )
static

variable rounding lock method of constraint handler

Definition at line 12624 of file cons_knapsack.c.

References NULL, SCIP_CALL, SCIP_OKAY, SCIPaddVarLocks(), and SCIPconsGetData().

static SCIP_DECL_CONSDELVARS ( consDelvarsKnapsack  )
static

variable deletion method of constraint handler

Definition at line 12643 of file cons_knapsack.c.

References NULL, performVarDeletions(), SCIP_CALL, and SCIP_OKAY.

static SCIP_DECL_CONSPRINT ( consPrintKnapsack  )
static

constraint display method of constraint handler

Definition at line 12659 of file cons_knapsack.c.

References NULL, SCIP_CALL, SCIP_OKAY, SCIPconsGetData(), SCIPinfoMessage(), SCIPwriteVarName(), and TRUE.

static SCIP_DECL_CONSCOPY ( consCopyKnapsack  )
static
static SCIP_DECL_CONSPARSE ( consParseKnapsack  )
static
static SCIP_DECL_CONSGETVARS ( consGetVarsKnapsack  )
static

constraint method of constraint handler which returns the variables (if possible)

Definition at line 12821 of file cons_knapsack.c.

References BMScopyMemoryArray, FALSE, NULL, SCIP_GUBSet::nvars, SCIP_OKAY, SCIPconsGetData(), and TRUE.

static SCIP_DECL_CONSGETNVARS ( consGetNVarsKnapsack  )
static

constraint method of constraint handler which returns the number of variables (if possible)

Definition at line 12843 of file cons_knapsack.c.

References NULL, SCIP_OKAY, SCIPconsGetData(), and TRUE.

SCIP_RETCODE SCIPincludeConshdlrKnapsack ( SCIP scip)

creates the handler for knapsack constraints and includes it in SCIP

Parameters
scipSCIP data structure

Definition at line 12926 of file cons_knapsack.c.

References CONSHDLR_CHECKPRIORITY, CONSHDLR_DELAYPRESOL, CONSHDLR_DELAYPROP, CONSHDLR_DELAYSEPA, CONSHDLR_DESC, CONSHDLR_EAGERFREQ, CONSHDLR_ENFOPRIORITY, CONSHDLR_MAXPREROUNDS, CONSHDLR_NAME, CONSHDLR_NEEDSCONS, CONSHDLR_PROP_TIMING, CONSHDLR_PROPFREQ, CONSHDLR_SEPAFREQ, CONSHDLR_SEPAPRIORITY, DEFAULT_DETECTCUTOFFBOUND, DEFAULT_DETECTLOWERBOUND, DEFAULT_DISAGGREGATION, DEFAULT_DUALPRESOLVING, DEFAULT_MAXCARDBOUNDDIST, DEFAULT_MAXROUNDS, DEFAULT_MAXROUNDSROOT, DEFAULT_MAXSEPACUTS, DEFAULT_MAXSEPACUTSROOT, DEFAULT_NEGATEDCLIQUE, DEFAULT_PRESOLPAIRWISE, DEFAULT_PRESOLUSEHASHING, DEFAULT_SEPACARDFREQ, DEFAULT_SIMPLIFYINEQUALITIES, DEFAULT_USEGUBS, EVENTHDLR_DESC, EVENTHDLR_NAME, FALSE, LINCONSUPGD_PRIORITY, NULL, SCIP_CALL, SCIP_OKAY, SCIP_PLUGINNOTFOUND, SCIPaddBoolParam(), SCIPaddIntParam(), SCIPaddRealParam(), SCIPallocMemory, SCIPerrorMessage, SCIPfindConshdlr(), SCIPincludeConshdlrBasic(), SCIPincludeEventhdlrBasic(), SCIPincludeLinconsUpgrade(), SCIPsetConshdlrCopy(), SCIPsetConshdlrDelete(), SCIPsetConshdlrDelvars(), SCIPsetConshdlrExit(), SCIPsetConshdlrExitpre(), SCIPsetConshdlrExitsol(), SCIPsetConshdlrFree(), SCIPsetConshdlrGetNVars(), SCIPsetConshdlrGetVars(), SCIPsetConshdlrInit(), SCIPsetConshdlrInitlp(), SCIPsetConshdlrInitpre(), SCIPsetConshdlrParse(), SCIPsetConshdlrPresol(), SCIPsetConshdlrPrint(), SCIPsetConshdlrProp(), SCIPsetConshdlrResprop(), SCIPsetConshdlrSepa(), SCIPsetConshdlrTrans(), and TRUE.

Referenced by SCIP_DECL_CONSHDLRCOPY(), and SCIPincludeDefaultPlugins().

SCIP_RETCODE SCIPcreateConsKnapsack ( SCIP scip,
SCIP_CONS **  cons,
const char *  name,
int  nvars,
SCIP_VAR **  vars,
SCIP_Longint weights,
SCIP_Longint  capacity,
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 
)

creates and captures a knapsack constraint

Note
the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
Parameters
scipSCIP data structure
conspointer to hold the created constraint
namename of constraint
nvarsnumber of items in the knapsack
varsarray with item variables
weightsarray with item weights
capacitycapacity of knapsack
initialshould the LP relaxation of constraint be in the initial LP? Usually set to TRUE. Set to FALSE for 'lazy constraints'.
separateshould the constraint be separated during LP processing? Usually set to TRUE.
enforceshould the constraint be enforced during node processing? TRUE for model constraints, FALSE for additional, redundant constraints.
checkshould the constraint be checked for feasibility? TRUE for model constraints, FALSE for additional, redundant constraints.
propagateshould the constraint be propagated during node processing? Usually set to TRUE.
localis constraint only valid locally? Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints.
modifiableis constraint modifiable (subject to column generation)? Usually set to FALSE. In column generation applications, set to TRUE if pricing adds coefficients to this constraint.
dynamicis constraint subject to aging? Usually set to FALSE. Set to TRUE for own cuts which are separated as constraints.
removableshould the relaxation be removed from the LP due to aging or cleanup? Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'.
stickingatnodeshould the constraint always be kept at the node where it was added, even if it may be moved to a more global node? Usually set to FALSE. Set to TRUE to for constraints that represent node data.

Definition at line 13056 of file cons_knapsack.c.

References consdataCreate(), CONSHDLR_NAME, NULL, SCIP_CALL, SCIP_OKAY, SCIP_PLUGINNOTFOUND, SCIPconshdlrGetData(), SCIPcreateCons(), SCIPerrorMessage, and SCIPfindConshdlr().

Referenced by createAndAddLinearCons(), createCapacityRestriction(), createNormalizedKnapsack(), SCIP_DECL_CONSPARSE(), SCIP_DECL_PRESOLEXEC(), and SCIPcreateConsBasicKnapsack().

SCIP_RETCODE SCIPcreateConsBasicKnapsack ( SCIP scip,
SCIP_CONS **  cons,
const char *  name,
int  nvars,
SCIP_VAR **  vars,
SCIP_Longint weights,
SCIP_Longint  capacity 
)

creates and captures a knapsack constraint in its most basic version, i. e., all constraint flags are set to their basic value as explained for the method SCIPcreateConsKnapsack(); all flags can be set via SCIPsetConsFLAGNAME-methods in scip.h

See Also
SCIPcreateConsKnapsack() for information about the basic constraint flag configuration
Note
the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
Parameters
scipSCIP data structure
conspointer to hold the created constraint
namename of constraint
nvarsnumber of items in the knapsack
varsarray with item variables
weightsarray with item weights
capacitycapacity of knapsack

Definition at line 13124 of file cons_knapsack.c.

References FALSE, NULL, SCIP_CALL, SCIP_OKAY, SCIPcreateConsKnapsack(), and TRUE.

SCIP_RETCODE SCIPaddCoefKnapsack ( SCIP scip,
SCIP_CONS cons,
SCIP_VAR var,
SCIP_Longint  weight 
)

adds new item to knapsack constraint

Parameters
scipSCIP data structure
consconstraint data
varitem variable
weightitem weight

Definition at line 13143 of file cons_knapsack.c.

References addCoef(), CONSHDLR_NAME, NULL, SCIP_CALL, SCIP_INVALIDDATA, SCIP_OKAY, SCIPconsGetHdlr(), SCIPconshdlrGetName(), and SCIPerrorMessage.

Referenced by addCoefTerm(), createCapacityRestriction(), and SCIPaddCoefPseudoboolean().

SCIP_Longint SCIPgetCapacityKnapsack ( SCIP scip,
SCIP_CONS cons 
)
SCIP_RETCODE SCIPchgCapacityKnapsack ( SCIP scip,
SCIP_CONS cons,
SCIP_Longint  capacity 
)

changes capacity of the knapsack constraint

Note
This method can only be called during problem creation stage (SCIP_STAGE_PROBLEM)
Parameters
scipSCIP data structure
consconstraint data
capacitynew capacity of knapsack

Definition at line 13188 of file cons_knapsack.c.

References CONSHDLR_NAME, NULL, SCIP_INVALIDDATA, SCIP_OKAY, SCIP_STAGE_PROBLEM, SCIPconsGetData(), SCIPconsGetHdlr(), SCIPconshdlrGetName(), SCIPerrorMessage, and SCIPgetStage().

SCIP_VAR** SCIPgetVarsKnapsack ( SCIP scip,
SCIP_CONS cons 
)
SCIP_Longint* SCIPgetWeightsKnapsack ( SCIP scip,
SCIP_CONS cons 
)

gets the array of weights in the knapsack constraint; the user must not modify this array!

Parameters
scipSCIP data structure
consconstraint data

Definition at line 13259 of file cons_knapsack.c.

References CONSHDLR_NAME, NULL, SCIPABORT, SCIPconsGetData(), SCIPconsGetHdlr(), SCIPconshdlrGetName(), and SCIPerrorMessage.

Referenced by addKnapsackConstraints(), checkKnapsack(), getLinearConsVarsData(), initMatrix(), SCIP_DECL_CONSCOPY(), SCIP_DECL_PRESOLEXEC(), SCIP_DECL_READERWRITE(), SCIPwriteCcg(), SCIPwriteGms(), SCIPwriteLp(), SCIPwritePbm(), SCIPwritePip(), SCIPwritePpm(), writeFzn(), and writeOpbConstraints().

SCIP_Real SCIPgetDualsolKnapsack ( SCIP scip,
SCIP_CONS cons 
)

gets the dual solution of the knapsack constraint in the current LP

Parameters
scipSCIP data structure
consconstraint data

Definition at line 13280 of file cons_knapsack.c.

References CONSHDLR_NAME, NULL, SCIP_INVALID, SCIPABORT, SCIPconsGetData(), SCIPconsGetHdlr(), SCIPconshdlrGetName(), SCIPerrorMessage, and SCIProwGetDualsol().

SCIP_Real SCIPgetDualfarkasKnapsack ( SCIP scip,
SCIP_CONS cons 
)

gets the dual Farkas value of the knapsack constraint in the current infeasible LP

Parameters
scipSCIP data structure
consconstraint data

Definition at line 13304 of file cons_knapsack.c.

References CONSHDLR_NAME, NULL, SCIP_INVALID, SCIPABORT, SCIPconsGetData(), SCIPconsGetHdlr(), SCIPconshdlrGetName(), SCIPerrorMessage, and SCIProwGetDualfarkas().

SCIP_ROW* SCIPgetRowKnapsack ( SCIP scip,
SCIP_CONS cons 
)

returns the linear relaxation of the given knapsack constraint; may return NULL if no LP row was yet created; the user must not modify the row!

Parameters
scipSCIP data structure
consconstraint data

Definition at line 13330 of file cons_knapsack.c.

References CONSHDLR_NAME, NULL, SCIPABORT, SCIPconsGetData(), SCIPconsGetHdlr(), SCIPconshdlrGetName(), and SCIPerrorMessage.