36 #define PRESOL_NAME "convertinttobin" 37 #define PRESOL_DESC "converts integer variables to binaries" 38 #define PRESOL_PRIORITY +6000000 39 #define PRESOL_MAXROUNDS 0 41 #define PRESOL_TIMING SCIP_PRESOLTIMING_FAST 43 #define DEFAULT_MAXDOMAINSIZE SCIP_LONGINT_MAX 44 #define DEFAULT_ONLYPOWERSOFTWO FALSE 46 #define DEFAULT_SAMELOCKSINBOTHDIRECTIONS FALSE 49 struct SCIP_PresolData
65 assert(presol != NULL);
82 assert(presoldata != NULL);
101 assert(
scip != NULL);
102 assert(presol != NULL);
104 assert(result != NULL);
117 assert(presoldata != NULL);
129 for( v = 0; v < nintvars; ++v )
168 assert(domainsize >= 0);
175 if( presoldata->onlypoweroftwo )
181 tmp = domainsize + 1;
183 while( tmp % 2 == 0 )
189 noconsknapsack =
FALSE;
193 SCIPdebugMsg(
scip,
"integer variable <%s> [%g,%g], domainsize %" SCIP_LONGINT_FORMAT
"\n, <uplocks = %d, downlocks = %d will be 'binarized' by %d binary variables\n ",
196 assert(nnewbinvars > 0);
200 if( scalar == domainsize )
205 else if( scalar == domainsize + 1 )
206 noconsknapsack =
TRUE;
208 assert(scalar > domainsize);
214 for( v2 = nnewbinvars - 1; v2 >= 0; --v2 )
228 weights[v2] = scalar;
238 if( !noconsknapsack )
242 while( domainsize % 2 == 1 )
245 domainsize = (domainsize - 1) / 2;
252 assert(divisor >= 2);
254 for( v2 = nodd; v2 < nnewbinvars; ++v2 )
256 weights[v2] /= divisor;
261 &weights[nodd], domainsize,
268 for( v2 = nnewbinvars - 1; v2 >= 0; --v2 )
310 presolExecConvertinttobin,
312 assert(presolptr != NULL);
320 "absolute value of maximum domain size for converting an integer variable to binaries variables",
326 "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)",
331 "presolving/" PRESOL_NAME "/samelocksinbothdirections",
332 "should only integer variables with uplocks equals downlocks be converted",
presolver that converts integer variables with domain [a,a+1] to binaries
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)
int SCIPgetNIntVars(SCIP *scip)
struct SCIP_PresolData SCIP_PRESOLDATA
SCIP_RETCODE SCIPsetPresolFree(SCIP *scip, SCIP_PRESOL *presol, SCIP_DECL_PRESOLFREE((*presolfree)))
#define DEFAULT_MAXDOMAINSIZE
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
SCIP_Bool SCIPvarIsInitial(SCIP_VAR *var)
SCIPInterval pow(const SCIPInterval &x, const SCIPInterval &y)
SCIP_RETCODE SCIPreleaseVar(SCIP *scip, SCIP_VAR **var)
static SCIP_DECL_PRESOLCOPY(presolCopyConvertinttobin)
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)
int SCIPsnprintf(char *t, int len, const char *s,...)
enum SCIP_Retcode SCIP_RETCODE
SCIP_PRESOLDATA * SCIPpresolGetData(SCIP_PRESOL *presol)
#define SCIPfreeBlockMemory(scip, ptr)
#define SCIPduplicateBufferArray(scip, ptr, source, num)
#define SCIPfreeBufferArray(scip, ptr)
SCIP_Bool SCIPvarIsRemovable(SCIP_VAR *var)
#define SCIPallocBlockMemory(scip, ptr)
#define SCIPdebugPrintCons(x, y, z)
SCIP_Real SCIPvarGetUbGlobal(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)
Constraint handler for knapsack constraints of the form , x binary and .
SCIP_RETCODE SCIPaddCons(SCIP *scip, SCIP_CONS *cons)
SCIP_Bool SCIPdoNotMultaggrVar(SCIP *scip, SCIP_VAR *var)
#define DEFAULT_ONLYPOWERSOFTWO
void SCIPpresolSetData(SCIP_PRESOL *presol, SCIP_PRESOLDATA *presoldata)
const char * SCIPvarGetName(SCIP_VAR *var)
#define DEFAULT_SAMELOCKSINBOTHDIRECTIONS
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)
#define SCIPallocBufferArray(scip, ptr, num)
public data structures and miscellaneous methods
int SCIPvarGetNLocksUp(SCIP_VAR *var)
const char * SCIPpresolGetName(SCIP_PRESOL *presol)
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)
SCIPInterval log(const SCIPInterval &x)
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
int SCIPgetNBinVars(SCIP *scip)
static SCIP_DECL_PRESOLFREE(presolFreeConvertinttobin)
int SCIPvarGetNLocksDown(SCIP_VAR *var)
SCIP_Bool SCIPisIntegral(SCIP *scip, SCIP_Real val)
SCIP_RETCODE SCIPaddVar(SCIP *scip, SCIP_VAR *var)
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
SCIP_RETCODE SCIPsetPresolCopy(SCIP *scip, SCIP_PRESOL *presol, SCIP_DECL_PRESOLCOPY((*presolcopy)))
SCIP_VAR ** SCIPgetVars(SCIP *scip)
static SCIP_DECL_PRESOLEXEC(presolExecConvertinttobin)
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
SCIP_Real SCIPceil(SCIP *scip, SCIP_Real val)
SCIP_Real SCIPfloor(SCIP *scip, SCIP_Real val)
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)