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;
139 assert(scip !=
NULL);
140 assert(comprdata !=
NULL);
151 assert(currentnode !=
NULL);
167 SCIPdebugMsg(scip,
"-> skip compression (k = %d, nleaves = %d)\n", 1, nleaveids);
171 SCIPdebugMsg(scip,
"-> try compression with %d node(s)\n", 1);
179 assert(nids == nleaveids);
200 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);
223 if( mem_vars < nvars2 + nafterdualvars )
225 mem_vars = nvars2 + nafterdualvars;
231 SCIPgetReoptnodePath(scip, reoptnode, vars[k], vals[k], boundtypes[k], mem_vars, &nvars2, &nafterdualvars);
234 nvars[k] = nvars2 + nafterdualvars;
244 SCIPreoptnodeGetConss(reoptnode, conss_var[k], conss_val[k], conss_boundtypes[k], mem_conss, &nconss[k],
246 assert(mem_conss == nconss[k]);
249 for( c = 0; c < mem_conss; c++ )
255 assert(reoptnode !=
NULL);
257 SCIPdebugMsg(scip,
"-> use node at id %u, %d vars, %d conss, lowerbound = %.g\n", leaveids[k], nvars[k],
263 assert(comprdata->nrepresentatives == 0);
268 comprdata->nrepresentatives = (nvars[0] > 0 ? 2 : 1);
269 comprdata->nrepresentatives += nconss[0];
273 assert(comprdata->nrepresentatives <= comprdata->representativessize);
284 assert(pos_repr_fix < comprdata->nrepresentatives);
290 for( r = pos_repr_fix; r < comprdata->nrepresentatives; r++ )
293 assert(comprdata->representatives[r] !=
NULL);
295 for( v = 0; v < nvars[0]; v++ )
305 assert(comprdata->representatives[pos_repr_fix-1] !=
NULL);
311 assert(0 <= pos_repr_fix && pos_repr_fix < comprdata->nrepresentatives);
314 for( k = 0; k < nconss[0]; k++ )
319 assert(pos_repr_fix < comprdata->nrepresentatives);
326 for( v = 0; v < conss_nvars[0][k]; v++ )
333 for( r = pos_repr_fix + 1; r < comprdata->nrepresentatives; r++ )
346 SCIPdebugMsg(scip,
"-> found representation of size %d.\n", comprdata->nrepresentatives);
349 for( k = size-1; k >= 0; k-- )
385 assert(scip !=
NULL);
386 assert(compr !=
NULL);
387 assert(comprdata !=
NULL);
391 if( comprdata->nrepresentatives == 0 )
395 for( r = 0; r < comprdata->nrepresentatives; r++ )
416 assert(compr !=
NULL);
432 assert(compr !=
NULL);
435 assert(comprdata !=
NULL);
450 assert(compr !=
NULL);
453 assert(comprdata !=
NULL);
455 if( comprdata->initialized )
459 for( r = 0; r < comprdata->nrepresentatives; r++ )
464 if( comprdata->representativessize > 0 )
469 comprdata->representatives =
NULL;
470 comprdata->representativessize = 0;
471 comprdata->nrepresentatives = 0;
472 comprdata->initialized =
FALSE;
487 assert(comprdata !=
NULL);
489 if( !comprdata->initialized )
494 comprdata->nrepresentatives = 0;
496 comprdata->initialized =
TRUE;
531 assert(comprdata !=
NULL);
532 comprdata->initialized =
FALSE;
536 comprExecWeakcompr, comprdata) );
538 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)
#define SCIPfreeMemoryArray(scip, ptr)
#define SCIPreallocMemoryArray(scip, ptr, newnum)
void SCIPgetReoptnodePath(SCIP *scip, SCIP_REOPTNODE *reoptnode, SCIP_VAR **vars, SCIP_Real *vals, SCIP_BOUNDTYPE *boundtypes, int mem, int *nvars, int *nafterdualvars)
#define SCIPallocMemoryArray(scip, ptr, num)
SCIP_RETCODE SCIPincludeComprWeakcompr(SCIP *scip)
int SCIPgetNBinVars(SCIP *scip)
#define SCIPallocClearMemoryArray(scip, ptr, num)
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)