48 #define PQ_PARENT(q) (((q)+1)/2-1) 49 #define PQ_LEFTCHILD(p) (2*(p)+1) 50 #define PQ_RIGHTCHILD(p) (2*(p)+2) 57 assert(elem1 !=
NULL);
58 assert(elem2 !=
NULL);
67 assert(elem1 == elem2);
81 assert(nodepq !=
NULL);
83 if( minsize <= nodepq->size )
101 assert(nodepq !=
NULL);
104 (*nodepq)->nodesel = nodesel;
105 (*nodepq)->slots =
NULL;
106 (*nodepq)->bfsposs =
NULL;
107 (*nodepq)->bfsqueue =
NULL;
110 (*nodepq)->lowerboundsum = 0.0;
120 assert(nodepq !=
NULL);
121 assert(*nodepq !=
NULL);
140 assert(nodepq !=
NULL);
141 assert(*nodepq !=
NULL);
165 assert(nodepq !=
NULL);
167 if( nodepq->
len > 0 )
176 for( i = 0; i < nodepq->
len; ++i )
197 assert(nodepq !=
NULL);
209 assert(nodepq !=
NULL);
210 assert(*nodepq !=
NULL);
211 assert((*nodepq)->len >= 0);
212 assert(nodesel !=
NULL);
213 assert(nodesel->nodeselcomp !=
NULL);
215 if( (*nodepq)->nodesel != nodesel )
227 for( i = 0; i < (*nodepq)->len; ++i )
250 assert(nodepq !=
NULL);
273 assert(nodepq !=
NULL);
274 assert(nodepq->
len >= 0);
276 assert(node !=
NULL);
279 assert(nodesel !=
NULL);
280 assert(nodesel->nodeselcomp !=
NULL);
283 slots = nodepq->
slots;
291 while( pos > 0 && nodesel->nodeselcomp(set->scip, nodesel, node, slots[
PQ_PARENT(pos)]) < 0 )
295 bfsqueue[bfsposs[pos]] = pos;
302 bfspos = nodepq->
len-1;
305 bfsqueue[bfspos] = bfsqueue[
PQ_PARENT(bfspos)];
306 bfsposs[bfsqueue[bfspos]] = bfspos;
309 bfsqueue[bfspos] = pos;
310 bfsposs[pos] = bfspos;
312 SCIPsetDebugMsg(
set,
"inserted node %p[%g] at pos %d and bfspos %d of node queue\n", (
void*)node, lowerbound, pos, bfspos);
339 assert(nodepq !=
NULL);
340 assert(nodepq->
len > 0);
342 assert(0 <= rempos && rempos < nodepq->len);
345 assert(nodesel !=
NULL);
346 assert(nodesel->nodeselcomp !=
NULL);
348 slots = nodepq->
slots;
354 freebfspos = bfsposs[rempos];
355 assert(0 <= freebfspos && freebfspos < nodepq->len);
357 SCIPsetDebugMsg(
set,
"delete node %p[%g] at pos %d and bfspos %d of node queue\n",
371 lastnode = slots[nodepq->
len];
372 lastbfspos = bfsposs[nodepq->
len];
373 parentfelldown =
FALSE;
374 if( freepos < nodepq->len )
380 while( freepos > 0 && nodesel->nodeselcomp(set->scip, nodesel, lastnode, slots[parentpos]) < 0 )
382 slots[freepos] = slots[parentpos];
383 bfsposs[freepos] = bfsposs[parentpos];
384 bfsqueue[bfsposs[freepos]] = freepos;
387 parentfelldown =
TRUE;
389 if( !parentfelldown )
399 assert(childpos < nodepq->len);
401 if( brotherpos < nodepq->len
402 && nodesel->nodeselcomp(set->scip, nodesel, slots[brotherpos], slots[childpos]) < 0 )
403 childpos = brotherpos;
406 if( nodesel->nodeselcomp(set->scip, nodesel, lastnode, slots[childpos]) <= 0 )
410 slots[freepos] = slots[childpos];
411 bfsposs[freepos] = bfsposs[childpos];
412 bfsqueue[bfsposs[freepos]] = freepos;
416 assert(0 <= freepos && freepos < nodepq->len);
418 slots[freepos] = lastnode;
419 bfsposs[freepos] = lastbfspos;
420 bfsqueue[lastbfspos] = freepos;
424 lastbfsqueueidx = bfsqueue[nodepq->
len];
425 bfsparentfelldown =
FALSE;
426 if( freebfspos < nodepq->len )
436 bfsqueue[freebfspos] = bfsqueue[parentpos];
437 bfsposs[bfsqueue[freebfspos]] = freebfspos;
438 freebfspos = parentpos;
440 bfsparentfelldown =
TRUE;
442 if( !bfsparentfelldown )
452 assert(childpos < nodepq->len);
454 if( brotherpos < nodepq->len
456 childpos = brotherpos;
463 bfsqueue[freebfspos] = bfsqueue[childpos];
464 bfsposs[bfsqueue[freebfspos]] = freebfspos;
465 freebfspos = childpos;
468 assert(0 <= freebfspos && freebfspos < nodepq->len);
470 bfsqueue[freebfspos] = lastbfsqueueidx;
471 bfsposs[lastbfsqueueidx] = freebfspos;
474 return parentfelldown;
487 assert(nodepq !=
NULL);
488 assert(nodepq->
len >= 0);
490 assert(node !=
NULL);
493 for( pos = 0; pos < nodepq->
len && node != nodepq->
slots[pos]; ++pos )
496 if( pos == nodepq->
len )
528 assert(nodepq !=
NULL);
529 assert(nodepq->
len >= 0);
531 if( nodepq->
len == 0 )
536 return nodepq->
slots[0];
544 assert(nodepq !=
NULL);
546 return nodepq->
slots;
554 assert(nodepq !=
NULL);
555 assert(nodepq->
len >= 0);
566 assert(nodepq !=
NULL);
570 if( nodepq->
len > 0 )
575 assert(0 <= bfspos && bfspos < nodepq->len);
589 assert(nodepq !=
NULL);
594 if( nodepq->
len > 0 )
599 assert(0 <= bfspos && bfspos < nodepq->len);
601 return nodepq->
slots[bfspos];
612 assert(nodepq !=
NULL);
634 assert(nodepq !=
NULL);
636 SCIPsetDebugMsg(
set,
"bounding node queue of length %d with cutoffbound=%g\n", nodepq->
len, cutoffbound);
640 assert(pos < nodepq->len);
641 node = nodepq->
slots[pos];
642 assert(node !=
NULL);
646 SCIPsetDebugMsg(
set,
"free node in slot %d (len=%d) at depth %d with lowerbound=%g\n",
665 if( !parentfelldown )
670 if( set->reopt_enable )
672 assert(reopt !=
NULL);
703 assert(paramdata !=
NULL);
718 assert(paramdata !=
NULL);
732 assert(nodesel !=
NULL);
734 assert(set->scip !=
NULL);
736 if( nodesel->nodeselcopy !=
NULL )
739 SCIP_CALL( nodesel->nodeselcopy(set->scip, nodesel) );
768 assert(nodesel !=
NULL);
769 assert(name !=
NULL);
770 assert(desc !=
NULL);
771 assert(nodeselselect !=
NULL);
772 assert(nodeselcomp !=
NULL);
777 (*nodesel)->stdpriority = stdpriority;
778 (*nodesel)->memsavepriority = memsavepriority;
779 (*nodesel)->nodeselcopy = nodeselcopy;
780 (*nodesel)->nodeselfree = nodeselfree;
781 (*nodesel)->nodeselinit = nodeselinit;
782 (*nodesel)->nodeselexit = nodeselexit;
783 (*nodesel)->nodeselinitsol = nodeselinitsol;
784 (*nodesel)->nodeselexitsol = nodeselexitsol;
785 (*nodesel)->nodeselselect = nodeselselect;
786 (*nodesel)->nodeselcomp = nodeselcomp;
787 (*nodesel)->nodeseldata = nodeseldata;
788 (*nodesel)->initialized =
FALSE;
797 &(*nodesel)->stdpriority,
FALSE, stdpriority, INT_MIN/4, INT_MAX/2,
803 &(*nodesel)->memsavepriority,
TRUE, memsavepriority, INT_MIN/4, INT_MAX/4,
815 assert(nodesel !=
NULL);
816 assert(*nodesel !=
NULL);
817 assert(!(*nodesel)->initialized);
821 if( (*nodesel)->nodeselfree !=
NULL )
823 SCIP_CALL( (*nodesel)->nodeselfree(set->scip, *nodesel) );
843 assert(nodesel !=
NULL);
852 if( set->misc_resetstat )
858 if( nodesel->nodeselinit !=
NULL )
863 SCIP_CALL( nodesel->nodeselinit(set->scip, nodesel) );
879 assert(nodesel !=
NULL);
888 if( nodesel->nodeselexit !=
NULL )
893 SCIP_CALL( nodesel->nodeselexit(set->scip, nodesel) );
909 assert(nodesel !=
NULL);
913 if( nodesel->nodeselinitsol !=
NULL )
918 SCIP_CALL( nodesel->nodeselinitsol(set->scip, nodesel) );
933 assert(nodesel !=
NULL);
937 if( nodesel->nodeselexitsol !=
NULL )
942 SCIP_CALL( nodesel->nodeselexitsol(set->scip, nodesel) );
959 assert(nodesel !=
NULL);
960 assert(nodesel->nodeselselect !=
NULL);
962 assert(selnode !=
NULL);
967 SCIP_CALL( nodesel->nodeselselect(set->scip, nodesel, selnode) );
983 assert(nodesel !=
NULL);
984 assert(nodesel->nodeselcomp !=
NULL);
986 assert(node1 !=
NULL);
987 assert(node2 !=
NULL);
989 return nodesel->nodeselcomp(set->scip, nodesel, node1, node2);
997 assert(nodesel !=
NULL);
999 return nodesel->
name;
1007 assert(nodesel !=
NULL);
1009 return nodesel->
desc;
1017 assert(nodesel !=
NULL);
1029 assert(nodesel !=
NULL);
1030 assert(
set !=
NULL);
1033 set->nodesel =
NULL;
1041 assert(nodesel !=
NULL);
1053 assert(nodesel !=
NULL);
1054 assert(
set !=
NULL);
1057 set->nodesel =
NULL;
1065 assert(nodesel !=
NULL);
1076 assert(nodesel !=
NULL);
1089 assert(nodesel !=
NULL);
1091 nodesel->nodeselcopy = nodeselcopy;
1100 assert(nodesel !=
NULL);
1102 nodesel->nodeselfree = nodeselfree;
1111 assert(nodesel !=
NULL);
1113 nodesel->nodeselinit = nodeselinit;
1122 assert(nodesel !=
NULL);
1124 nodesel->nodeselexit = nodeselexit;
1133 assert(nodesel !=
NULL);
1135 nodesel->nodeselinitsol = nodeselinitsol;
1144 assert(nodesel !=
NULL);
1146 nodesel->nodeselexitsol = nodeselexitsol;
1154 assert(nodesel !=
NULL);
1165 assert(nodesel !=
NULL);
1176 assert(nodesel !=
NULL);
1186 assert(nodesel !=
NULL);
void SCIPnodeselSetFree(SCIP_NODESEL *nodesel, SCIP_DECL_NODESELFREE((*nodeselfree)))
void SCIPnodepqDestroy(SCIP_NODEPQ **nodepq)
SCIP_NODE ** SCIPnodepqNodes(const SCIP_NODEPQ *nodepq)
#define SCIP_DECL_NODESELCOMP(x)
SCIP_RETCODE SCIPnodepqBound(SCIP_NODEPQ *nodepq, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_Real cutoffbound)
int SCIPnodeselGetMemsavePriority(SCIP_NODESEL *nodesel)
void SCIPnodeselEnableOrDisableClocks(SCIP_NODESEL *nodesel, SCIP_Bool enable)
#define BMSfreeMemoryArrayNull(ptr)
internal methods for branch and bound tree
void SCIPnodeselSetInit(SCIP_NODESEL *nodesel, SCIP_DECL_NODESELINIT((*nodeselinit)))
SCIP_RETCODE SCIPnodeselExitsol(SCIP_NODESEL *nodesel, SCIP_SET *set)
SCIP_Real SCIPnodeGetLowerbound(SCIP_NODE *node)
SCIP_PARAMDATA * SCIPparamGetData(SCIP_PARAM *param)
int SCIPnodepqCompare(SCIP_NODEPQ *nodepq, SCIP_SET *set, SCIP_NODE *node1, SCIP_NODE *node2)
internal methods for clocks and timing issues
struct SCIP_ParamData SCIP_PARAMDATA
#define SCIP_DECL_NODESELINITSOL(x)
static SCIP_DECL_PARAMCHGD(paramChgdNodeselStdPriority)
SCIP_Real SCIPsetInfinity(SCIP_SET *set)
int SCIPnodepqLen(const SCIP_NODEPQ *nodepq)
static SCIP_DECL_SORTPTRCOMP(nodeCompNumber)
const char * SCIPnodeselGetDesc(SCIP_NODESEL *nodesel)
void SCIPclockStop(SCIP_CLOCK *clck, SCIP_SET *set)
SCIP_RETCODE SCIPsetNodeselMemsavePriority(SCIP *scip, SCIP_NODESEL *nodesel, int priority)
void SCIPclockStart(SCIP_CLOCK *clck, SCIP_SET *set)
int SCIPsnprintf(char *t, int len, const char *s,...)
SCIP_NODE * SCIPnodepqGetLowerboundNode(SCIP_NODEPQ *nodepq, SCIP_SET *set)
enum SCIP_Retcode SCIP_RETCODE
SCIP_Real SCIPnodepqGetLowerboundSum(SCIP_NODEPQ *nodepq)
SCIP_RETCODE SCIPnodeselInitsol(SCIP_NODESEL *nodesel, SCIP_SET *set)
SCIP_NODE * SCIPtreeGetFocusNode(SCIP_TREE *tree)
internal methods for handling parameter settings
int SCIPnodeGetDepth(SCIP_NODE *node)
methods for creating output for visualization tools (VBC, BAK)
void SCIPclockEnableOrDisable(SCIP_CLOCK *clck, SCIP_Bool enable)
#define BMSfreeMemory(ptr)
SCIP_NODESEL * SCIPnodepqGetNodesel(SCIP_NODEPQ *nodepq)
static int nodepqFindNode(SCIP_NODEPQ *nodepq, SCIP_SET *set, SCIP_NODE *node)
static SCIP_RETCODE nodepqResize(SCIP_NODEPQ *nodepq, SCIP_SET *set, int minsize)
#define SCIP_DECL_NODESELEXITSOL(x)
SCIP_LPSOLSTAT SCIPlpGetSolstat(SCIP_LP *lp)
internal methods for LP management
SCIP_RETCODE SCIPnodeselExit(SCIP_NODESEL *nodesel, SCIP_SET *set)
SCIP_RETCODE SCIPnodeselSelect(SCIP_NODESEL *nodesel, SCIP_SET *set, SCIP_NODE **selnode)
#define SCIP_DECL_NODESELINIT(x)
SCIP_Bool SCIPsetIsGE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
SCIP_RETCODE SCIPnodeselCopyInclude(SCIP_NODESEL *nodesel, SCIP_SET *set)
SCIP_RETCODE SCIPnodepqInsert(SCIP_NODEPQ *nodepq, SCIP_SET *set, SCIP_NODE *node)
struct SCIP_NodeselData SCIP_NODESELDATA
SCIP_Bool SCIPsetIsLT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
#define BMSfreeMemoryArray(ptr)
void SCIPsortDownPtr(void **ptrarray, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), int len)
void SCIPclockReset(SCIP_CLOCK *clck)
SCIP_RETCODE SCIPnodepqSetNodesel(SCIP_NODEPQ **nodepq, SCIP_SET *set, SCIP_NODESEL *nodesel)
SCIP_Real SCIPclockGetTime(SCIP_CLOCK *clck)
#define SCIP_DECL_NODESELFREE(x)
SCIP_RETCODE SCIPnodeselFree(SCIP_NODESEL **nodesel, SCIP_SET *set)
SCIP_NODESELDATA * SCIPnodeselGetData(SCIP_NODESEL *nodesel)
internal methods for node selectors and node priority queues
internal methods for global SCIP settings
SCIP main data structure.
SCIP_Real SCIPnodeselGetTime(SCIP_NODESEL *nodesel)
int SCIPnodeselCompare(SCIP_NODESEL *nodesel, SCIP_SET *set, SCIP_NODE *node1, SCIP_NODE *node2)
int SCIPsetCalcTreeGrowSize(SCIP_SET *set, int num)
SCIP_RETCODE SCIPsetAddIntParam(SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, BMS_BLKMEM *blkmem, const char *name, const char *desc, int *valueptr, SCIP_Bool isadvanced, int defaultvalue, int minvalue, int maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
SCIP_RETCODE SCIPnodeselInit(SCIP_NODESEL *nodesel, SCIP_SET *set)
void SCIPnodeselSetInitsol(SCIP_NODESEL *nodesel, SCIP_DECL_NODESELINITSOL((*nodeselinitsol)))
#define BMSduplicateMemoryArray(ptr, source, num)
SCIP_RETCODE SCIPnodepqFree(SCIP_NODEPQ **nodepq, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_TREE *tree, SCIP_LP *lp)
SCIP_RETCODE SCIPclockCreate(SCIP_CLOCK **clck, SCIP_CLOCKTYPE clocktype)
data structures and methods for collecting reoptimization information
public data structures and miscellaneous methods
int SCIPtreeGetEffectiveRootDepth(SCIP_TREE *tree)
SCIP_RETCODE SCIPnodeselCreate(SCIP_NODESEL **nodesel, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, BMS_BLKMEM *blkmem, const char *name, const char *desc, int stdpriority, int memsavepriority, SCIP_DECL_NODESELCOPY((*nodeselcopy)), SCIP_DECL_NODESELFREE((*nodeselfree)), SCIP_DECL_NODESELINIT((*nodeselinit)), SCIP_DECL_NODESELEXIT((*nodeselexit)), SCIP_DECL_NODESELINITSOL((*nodeselinitsol)), SCIP_DECL_NODESELEXITSOL((*nodeselexitsol)), SCIP_DECL_NODESELSELECT((*nodeselselect)), SCIP_DECL_NODESELCOMP((*nodeselcomp)), SCIP_NODESELDATA *nodeseldata)
#define SCIP_DECL_NODESELEXIT(x)
SCIP_RETCODE SCIPreoptCheckCutoff(SCIP_REOPT *reopt, SCIP_SET *set, BMS_BLKMEM *blkmem, SCIP_NODE *node, SCIP_EVENTTYPE eventtype, SCIP_LP *lp, SCIP_LPSOLSTAT lpsolstat, SCIP_Bool isrootnode, SCIP_Bool isfocusnode, SCIP_Real lowerbound, int effectiverootdepth)
static const char * paramname[]
SCIP_RETCODE SCIPnodepqRemove(SCIP_NODEPQ *nodepq, SCIP_SET *set, SCIP_NODE *node)
void SCIPnodeselSetMemsavePriority(SCIP_NODESEL *nodesel, SCIP_SET *set, int priority)
void SCIPclockFree(SCIP_CLOCK **clck)
SCIP_RETCODE SCIPnodepqCreate(SCIP_NODEPQ **nodepq, SCIP_SET *set, SCIP_NODESEL *nodesel)
void SCIPnodeselSetExit(SCIP_NODESEL *nodesel, SCIP_DECL_NODESELEXIT((*nodeselexit)))
#define SCIP_EVENTTYPE_NODEINFEASIBLE
const char * SCIPnodeselGetName(SCIP_NODESEL *nodesel)
SCIP_NODE * SCIPnodepqFirst(const SCIP_NODEPQ *nodepq)
SCIP_NODESELDATA * nodeseldata
int SCIPparamGetInt(SCIP_PARAM *param)
SCIP_Real SCIPnodeselGetSetupTime(SCIP_NODESEL *nodesel)
void SCIPnodeselSetStdPriority(SCIP_NODESEL *nodesel, SCIP_SET *set, int priority)
SCIP_Real SCIPnodepqGetLowerbound(SCIP_NODEPQ *nodepq, SCIP_SET *set)
static SCIP_Bool nodepqDelPos(SCIP_NODEPQ *nodepq, SCIP_SET *set, int rempos)
public methods for message output
data structures for node selectors and node priority queues
SCIP_RETCODE SCIPnodepqClear(SCIP_NODEPQ *nodepq, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_TREE *tree, SCIP_LP *lp)
SCIP_NODETYPE SCIPnodeGetType(SCIP_NODE *node)
void SCIPvisualCutoffNode(SCIP_VISUAL *visual, SCIP_SET *set, SCIP_STAT *stat, SCIP_NODE *node, SCIP_Bool infeasible)
internal methods for problem statistics
#define SCIP_DECL_NODESELCOPY(x)
#define BMSallocMemory(ptr)
#define BMSreallocMemoryArray(ptr, num)
void SCIPnodeselSetCopy(SCIP_NODESEL *nodesel, SCIP_DECL_NODESELCOPY((*nodeselcopy)))
common defines and data types used in all packages of SCIP
struct BMS_BlkMem BMS_BLKMEM
int SCIPnodeselGetStdPriority(SCIP_NODESEL *nodesel)
#define SCIP_DECL_NODESELSELECT(x)
void SCIPnodeselSetExitsol(SCIP_NODESEL *nodesel, SCIP_DECL_NODESELEXITSOL((*nodeselexitsol)))
void SCIPnodeselSetData(SCIP_NODESEL *nodesel, SCIP_NODESELDATA *nodeseldata)
SCIP_RETCODE SCIPnodeFree(SCIP_NODE **node, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_TREE *tree, SCIP_LP *lp)
SCIP_Bool SCIPnodeselIsInitialized(SCIP_NODESEL *nodesel)
SCIP_RETCODE SCIPsetNodeselStdPriority(SCIP *scip, SCIP_NODESEL *nodesel, int priority)