55#define PRESOL_NAME "convertinttobin"
56#define PRESOL_DESC "converts integer variables to binaries"
57#define PRESOL_PRIORITY +6000000
58#define PRESOL_MAXROUNDS 0
60#define PRESOL_TIMING SCIP_PRESOLTIMING_FAST
62#define DEFAULT_MAXDOMAINSIZE SCIP_LONGINT_MAX
63#define DEFAULT_ONLYPOWERSOFTWO FALSE
65#define DEFAULT_SAMELOCKSINBOTHDIRECTIONS FALSE
70 SCIP_Longint maxdomainsize;
71 SCIP_Bool onlypoweroftwo;
72 SCIP_Bool samelocksinbothdirections;
151 SCIP_Real* newbinvarcoeffs;
152 SCIP_Longint* weights;
156 SCIP_Longint domainsize;
162 SCIP_Bool infeasible;
163 SCIP_Bool aggregated;
164 SCIP_Bool noconsknapsack;
173 if( presoldata->samelocksinbothdirections
195 if( presoldata->onlypoweroftwo )
201 tmp = domainsize + 1;
203 while( tmp % 2 == 0 )
209 noconsknapsack =
FALSE;
211 nnewbinvars = (int)
SCIPfloor(
scip, (log((SCIP_Real) domainsize)/log(2.0))) + 1;
221 if( scalar == domainsize )
226 else if( scalar == domainsize + 1 )
227 noconsknapsack =
TRUE;
229 assert(scalar > domainsize);
235 for( v2 = nnewbinvars - 1; v2 >= 0; --v2 )
249 weights[v2] = scalar;
252#ifdef WITH_DEBUG_SOLUTION
254 if( SCIPdebugIsMainscip(
scip) )
263 SCIP_Real resvarval = varval;
265 for( v2 = nnewbinvars - 1; v2 >= 0; --v2 )
273 resvarval -= newbinvarcoeffs[v2];
290 if( !noconsknapsack )
294 while( domainsize % 2 == 1 )
297 domainsize = (domainsize - 1) / 2;
301 SCIP_Longint divisor;
306 for( v2 = nodd; v2 < nnewbinvars; ++v2 )
308 weights[v2] /= divisor;
313 &weights[nodd], domainsize,
320 for( v2 = nnewbinvars - 1; v2 >= 0; --v2 )
362 presolExecConvertinttobin,
372 "absolute value of maximum domain size for converting an integer variable to binaries variables",
378 "should only integer variables with a domain size of 2^p - 1 be converted(, there we don't need an knapsack-constraint for restricting the sum of the binaries)",
383 "presolving/" PRESOL_NAME "/samelocksinbothdirections",
384 "should only integer variables with uplocks equals downlocks be converted",
Constraint handler for knapsack constraints of the form , x binary and .
#define SCIPdebugGetSolVal(scip, var, val)
#define SCIPdebugAddSolVal(scip, var, val)
#define SCIP_LONGINT_FORMAT
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 SCIPaddVar(SCIP *scip, SCIP_VAR *var)
int SCIPgetNIntVars(SCIP *scip)
SCIP_RETCODE SCIPaddCons(SCIP *scip, SCIP_CONS *cons)
SCIP_VAR ** SCIPgetVars(SCIP *scip)
int SCIPgetNBinVars(SCIP *scip)
SCIP_RETCODE SCIPaddLongintParam(SCIP *scip, const char *name, const char *desc, SCIP_Longint *valueptr, SCIP_Bool isadvanced, SCIP_Longint defaultvalue, SCIP_Longint minvalue, SCIP_Longint maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
SCIP_RETCODE SCIPaddBoolParam(SCIP *scip, const char *name, const char *desc, SCIP_Bool *valueptr, SCIP_Bool isadvanced, SCIP_Bool defaultvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
SCIP_RETCODE SCIPincludePresolConvertinttobin(SCIP *scip)
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
#define SCIPallocBufferArray(scip, ptr, num)
#define SCIPfreeBufferArray(scip, ptr)
#define SCIPduplicateBufferArray(scip, ptr, source, num)
#define SCIPfreeBlockMemory(scip, ptr)
#define SCIPallocBlockMemory(scip, ptr)
SCIP_RETCODE SCIPsetPresolFree(SCIP *scip, SCIP_PRESOL *presol,)
void SCIPpresolSetData(SCIP_PRESOL *presol, SCIP_PRESOLDATA *presoldata)
SCIP_PRESOLDATA * SCIPpresolGetData(SCIP_PRESOL *presol)
SCIP_RETCODE SCIPsetPresolCopy(SCIP *scip, SCIP_PRESOL *presol,)
SCIP_RETCODE SCIPincludePresolBasic(SCIP *scip, SCIP_PRESOL **presolptr, const char *name, const char *desc, int priority, int maxrounds, SCIP_PRESOLTIMING timing, SCIP_DECL_PRESOLEXEC((*presolexec)), SCIP_PRESOLDATA *presoldata)
const char * SCIPpresolGetName(SCIP_PRESOL *presol)
SCIP_Bool SCIPisIntegral(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisPositive(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Real SCIPfloor(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
SCIP_Real SCIPceil(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisZero(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPvarIsInitial(SCIP_VAR *var)
int SCIPvarGetNLocksUpType(SCIP_VAR *var, SCIP_LOCKTYPE locktype)
SCIP_Bool SCIPdoNotMultaggrVar(SCIP *scip, SCIP_VAR *var)
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
const char * SCIPvarGetName(SCIP_VAR *var)
SCIP_RETCODE SCIPmultiaggregateVar(SCIP *scip, SCIP_VAR *var, int naggvars, SCIP_VAR **aggvars, SCIP_Real *scalars, SCIP_Real constant, SCIP_Bool *infeasible, SCIP_Bool *aggregated)
SCIP_RETCODE SCIPreleaseVar(SCIP *scip, SCIP_VAR **var)
SCIP_Bool SCIPvarIsRemovable(SCIP_VAR *var)
SCIP_RETCODE SCIPcreateVar(SCIP *scip, SCIP_VAR **var, const char *name, SCIP_Real lb, SCIP_Real ub, SCIP_Real obj, SCIP_VARTYPE vartype, SCIP_Bool initial, SCIP_Bool removable, SCIP_DECL_VARDELORIG((*vardelorig)), SCIP_DECL_VARTRANS((*vartrans)), SCIP_DECL_VARDELTRANS((*vardeltrans)), SCIP_DECL_VARCOPY((*varcopy)), SCIP_VARDATA *vardata)
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
int SCIPvarGetNLocksDownType(SCIP_VAR *var, SCIP_LOCKTYPE locktype)
int SCIPsnprintf(char *t, int len, const char *s,...)
assert(minobj< SCIPgetCutoffbound(scip))
memory allocation routines
#define DEFAULT_MAXDOMAINSIZE
#define DEFAULT_SAMELOCKSINBOTHDIRECTIONS
#define DEFAULT_ONLYPOWERSOFTWO
presolver that converts integer variables with domain [a,a+1] to binaries
public methods for message output
#define SCIPdebugPrintCons(x, y, z)
public data structures and miscellaneous methods
public methods for presolvers
public methods for problem variables
public methods for constraint handler plugins and constraints
public methods for memory management
public methods for message handling
public methods for numerical tolerances
public methods for SCIP parameter handling
public methods for presolving plugins
public methods for global and local (sub)problems
public methods for SCIP variables
#define SCIP_DECL_PRESOLCOPY(x)
struct SCIP_PresolData SCIP_PRESOLDATA
#define SCIP_DECL_PRESOLFREE(x)
#define SCIP_DECL_PRESOLEXEC(x)
enum SCIP_Retcode SCIP_RETCODE