32 #define COMPR_NAME "weakcompr" 33 #define COMPR_DESC "reduce the search frontier to k+1 or max{2, |C|+1} nodes." 34 #define COMPR_PRIORITY 1000 35 #define COMPR_MINNNODES 50 37 #define DEFAULT_MEM_REPR 2 48 int representativessize;
64 unsigned int* childids,
73 for( i = 0; i < nchildids; i++ )
96 assert(comprdata != NULL);
98 if( comprdata->representativessize < nrepresentatives )
101 comprdata->representativessize = nrepresentatives;
129 unsigned int* leaveids;
140 assert(scip != NULL);
141 assert(comprdata != NULL);
152 assert(currentnode != NULL);
168 SCIPdebugMsg(scip,
"-> skip compression (k = %d, nleaves = %d)\n", 1, nleaveids);
172 SCIPdebugMsg(scip,
"-> try compression with %d node(s)\n", 1);
180 assert(nids == nleaveids);
203 for( k = size-1; k < 1; k++ )
218 assert(reoptnode != NULL);
220 SCIPgetReoptnodePath(scip, reoptnode, vars[k], vals[k], boundtypes[k], mem_vars, &nvars2, &nafterdualvars);
221 assert(mem_vars >= nvars2 + nafterdualvars);
223 nvars[k] = nvars2 + nafterdualvars;
233 SCIPreoptnodeGetConss(reoptnode, conss_var[k], conss_val[k], conss_boundtypes[k], mem_conss, &nconss[k],
235 assert(mem_conss == nconss[k]);
238 for( c = 0; c < mem_conss; c++ )
244 assert(reoptnode != NULL);
246 SCIPdebugMsg(scip,
"-> use node at id %u, %d vars, %d conss, lowerbound = %.g\n", leaveids[k], nvars[k],
252 assert(comprdata->nrepresentatives == 0);
257 comprdata->nrepresentatives = (nvars[0] > 0 ? 2 : 1);
258 comprdata->nrepresentatives += nconss[0];
262 assert(comprdata->nrepresentatives <= comprdata->representativessize);
273 assert(pos_repr_fix < comprdata->nrepresentatives);
279 for( r = pos_repr_fix; r < comprdata->nrepresentatives; r++ )
282 assert(comprdata->representatives[r] != NULL);
284 for( v = 0; v < nvars[0]; v++ )
294 assert(comprdata->representatives[pos_repr_fix-1] != NULL);
300 assert(0 <= pos_repr_fix && pos_repr_fix < comprdata->nrepresentatives);
303 for( k = 0; k < nconss[0]; k++ )
308 assert(pos_repr_fix < comprdata->nrepresentatives);
315 for( v = 0; v < conss_nvars[0][k]; v++ )
322 for( r = pos_repr_fix + 1; r < comprdata->nrepresentatives; r++ )
335 SCIPdebugMsg(scip,
"-> found representation of size %d.\n", comprdata->nrepresentatives);
338 for( k = size-1; k >= 0; k-- )
374 assert(scip != NULL);
375 assert(compr != NULL);
376 assert(comprdata != NULL);
380 if( comprdata->nrepresentatives == 0 )
384 for( r = 0; r < comprdata->nrepresentatives; r++ )
404 assert(
scip != NULL);
405 assert(compr != NULL);
420 assert(
scip != NULL);
421 assert(compr != NULL);
424 assert(comprdata != NULL);
438 assert(
scip != NULL);
439 assert(compr != NULL);
442 assert(comprdata != NULL);
444 if( comprdata->initialized )
448 for( r = 0; r < comprdata->nrepresentatives; r++ )
453 if( comprdata->representativessize > 0 )
458 comprdata->representatives = NULL;
459 comprdata->representativessize = 0;
460 comprdata->nrepresentatives = 0;
461 comprdata->initialized =
FALSE;
476 assert(comprdata != NULL);
478 if( !comprdata->initialized )
483 comprdata->nrepresentatives = 0;
485 comprdata->initialized =
TRUE;
520 assert(comprdata != NULL);
521 comprdata->initialized =
FALSE;
525 comprExecWeakcompr, comprdata) );
527 assert(compr != NULL);
enum SCIP_Result SCIP_RESULT
#define SCIPfreeBlockMemoryArray(scip, ptr, num)
enum SCIP_BoundType SCIP_BOUNDTYPE
int SCIPgetNIntVars(SCIP *scip)
#define SCIPreallocBlockMemoryArray(scip, ptr, oldnum, newnum)
SCIP_RETCODE SCIPsetComprFree(SCIP *scip, SCIP_COMPR *compr, SCIP_DECL_COMPRFREE((*comprfree)))
#define SCIPallocBlockMemoryArray(scip, ptr, num)
SCIP_Bool SCIPisFeasEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_NODE * SCIPgetCurrentNode(SCIP *scip)
SCIP_STAGE SCIPgetStage(SCIP *scip)
int SCIPcomprGetMinNodes(SCIP_COMPR *compr)
SCIP_Bool SCIPcomprIsInitialized(SCIP_COMPR *compr)
static SCIP_DECL_COMPRCOPY(comprCopyWeakcompr)
SCIP_Real SCIPinfinity(SCIP *scip)
SCIP_RETCODE SCIPincludeComprBasic(SCIP *scip, SCIP_COMPR **compr, const char *name, const char *desc, int priority, int minnnodes, SCIP_DECL_COMPREXEC((*comprexec)), SCIP_COMPRDATA *comprdata)
enum SCIP_Retcode SCIP_RETCODE
static SCIP_RETCODE sortIDs(SCIP *scip, unsigned int *childids, int nchildids)
static SCIP_RETCODE checkMemSize(SCIP *scip, SCIP_COMPRDATA *comprdata, int nrepresentatives)
#define SCIPfreeBlockMemory(scip, ptr)
public methods for reoptimization
SCIP_RETCODE SCIPinitRepresentation(SCIP *scip, SCIP_REOPTNODE **representatives, int nrepresentatives)
void SCIPsortDownRealInt(SCIP_Real *realarray, int *intarray, int len)
int SCIPnodeGetDepth(SCIP_NODE *node)
#define SCIPfreeBufferArray(scip, ptr)
SCIP_COMPRDATA * SCIPcomprGetData(SCIP_COMPR *compr)
#define SCIPallocBlockMemory(scip, ptr)
SCIP_RETCODE SCIPdeleteReoptnode(SCIP *scip, SCIP_REOPTNODE **reoptnode)
SCIP_Longint SCIPnodeGetNumber(SCIP_NODE *node)
SCIP_RETCODE SCIPsetReoptCompression(SCIP *scip, SCIP_REOPTNODE **representation, int nrepresentatives, SCIP_Bool *success)
weakcompr tree compression
SCIP_RETCODE SCIPsetComprCopy(SCIP *scip, SCIP_COMPR *compr, SCIP_DECL_COMPRCOPY((*comprcopy)))
methods for block memory pools and memory buffers
void SCIPreoptnodeSetParentID(SCIP_REOPTNODE *reoptnode, unsigned int parentid)
internal miscellaneous methods
static SCIP_DECL_COMPREXEC(comprExecWeakcompr)
static SCIP_DECL_COMPREXIT(comprExitWeakcompr)
struct SCIP_ComprData SCIP_COMPRDATA
#define SCIPallocBufferArray(scip, ptr, num)
int SCIPreoptnodeGetNVars(SCIP_REOPTNODE *reoptnode)
SCIP_Real SCIPreoptnodeGetLowerbound(SCIP_REOPTNODE *reoptnode)
static SCIP_RETCODE applyCompression(SCIP *scip, SCIP_COMPR *compr, SCIP_COMPRDATA *comprdata, SCIP_RESULT *result)
SCIP_RETCODE SCIPaddReoptnodeCons(SCIP *scip, SCIP_REOPTNODE *reoptnode, SCIP_VAR **vars, SCIP_Real *vals, SCIP_BOUNDTYPE *boundtypes, SCIP_Real lhs, SCIP_Real rhs, int nvars, REOPT_CONSTYPE constype, SCIP_Bool linear)
SCIP_RETCODE SCIPaddReoptnodeBndchg(SCIP *scip, SCIP_REOPTNODE *reoptnode, SCIP_VAR *var, SCIP_Real bound, SCIP_BOUNDTYPE boundtype)
void SCIPgetReoptnodePath(SCIP *scip, SCIP_REOPTNODE *reoptnode, SCIP_VAR **vars, SCIP_Real *vals, SCIP_BOUNDTYPE *boundtypes, int mem, int *nvars, int *nafterdualvars)
SCIP_RETCODE SCIPincludeComprWeakcompr(SCIP *scip)
int SCIPgetNBinVars(SCIP *scip)
#define SCIPallocClearMemoryArray(scip, ptr, num)
int SCIPgetNVars(SCIP *scip)
const char * SCIPcomprGetName(SCIP_COMPR *compr)
internal methods for tree compressions
void SCIPreoptnodeGetConss(SCIP_REOPTNODE *reoptnode, SCIP_VAR ***vars, SCIP_Real **bounds, SCIP_BOUNDTYPE **boundtypes, int mem, int *nconss, int *nvars)
SCIP_RETCODE SCIPsetComprExit(SCIP *scip, SCIP_COMPR *compr, SCIP_DECL_COMPREXIT((*comprexit)))
SCIP_RETCODE SCIPgetReoptLeaveIDs(SCIP *scip, SCIP_NODE *node, unsigned int *ids, int idssize, int *nids)
static SCIP_RETCODE constructCompression(SCIP *scip, SCIP_COMPR *compr, SCIP_COMPRDATA *comprdata, SCIP_RESULT *result)
void SCIPcomprSetData(SCIP_COMPR *compr, SCIP_COMPRDATA *comprdata)
SCIP_REOPTNODE * SCIPgetReoptnode(SCIP *scip, unsigned int id)
int SCIPgetNReoptLeaves(SCIP *scip, SCIP_NODE *node)
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)
static SCIP_DECL_COMPRFREE(comprFreeWeakcompr)
int SCIPreoptnodeGetNConss(SCIP_REOPTNODE *reoptnode)