61#define PQ_PARENT(q) (((q)+1)/2-1)
62#define PQ_LEFTCHILD(p) (2*(p)+1)
63#define PQ_RIGHTCHILD(p) (2*(p)+2)
96 if( minsize <= nodepq->size )
118 (*nodepq)->nodesel = nodesel;
119 (*nodepq)->slots =
NULL;
120 (*nodepq)->bfsposs =
NULL;
121 (*nodepq)->bfsqueue =
NULL;
124 (*nodepq)->lowerboundsum = 0.0;
183 if( nodepq->
len > 0 )
192 for(
i = 0;
i < nodepq->
len; ++
i )
231 assert((*nodepq)->len >= 0);
235 if( (*nodepq)->nodesel == nodesel )
245 for(
i = 0;
i < (*nodepq)->len && retcode ==
SCIP_OKAY; ++
i )
306 slots = nodepq->
slots;
314 while( pos > 0 && nodesel->nodeselcomp(
set->scip, nodesel, node, slots[
PQ_PARENT(pos)]) < 0 )
318 bfsqueue[bfsposs[pos]] = pos;
324 bfspos = nodepq->
len-1;
325 if(
set->exact_enable )
330 bfsqueue[bfspos] = bfsqueue[
PQ_PARENT(bfspos)];
331 bfsposs[bfsqueue[bfspos]] = bfspos;
335 SCIPrationalDebugMessage(
"inserted node %p[%q] at pos %d and bfspos %d of node queue\n", (
void*)node, lowerbound, pos, bfspos);
342 bfsqueue[bfspos] = bfsqueue[
PQ_PARENT(bfspos)];
343 bfsposs[bfsqueue[bfspos]] = bfspos;
347 SCIPsetDebugMsg(
set,
"inserted node %p[%g] at pos %d and bfspos %d of node queue\n", (
void*)node, lowerbound, pos, bfspos);
349 bfsqueue[bfspos] = pos;
350 bfsposs[pos] = bfspos;
380 assert(0 <= rempos && rempos < nodepq->len);
386 slots = nodepq->
slots;
392 freebfspos = bfsposs[rempos];
393 assert(0 <= freebfspos && freebfspos < nodepq->len);
409 lastnode = slots[nodepq->
len];
410 lastbfspos = bfsposs[nodepq->
len];
411 parentfelldown =
FALSE;
412 if( freepos < nodepq->len )
418 while( freepos > 0 && nodesel->nodeselcomp(
set->scip, nodesel, lastnode, slots[parentpos]) < 0 )
420 slots[freepos] = slots[parentpos];
421 bfsposs[freepos] = bfsposs[parentpos];
422 bfsqueue[bfsposs[freepos]] = freepos;
425 parentfelldown =
TRUE;
427 if( !parentfelldown )
437 assert(childpos < nodepq->len);
439 if( brotherpos < nodepq->len
440 && nodesel->nodeselcomp(
set->scip, nodesel, slots[brotherpos], slots[childpos]) < 0 )
441 childpos = brotherpos;
444 if( nodesel->nodeselcomp(
set->scip, nodesel, lastnode, slots[childpos]) <= 0 )
448 slots[freepos] = slots[childpos];
449 bfsposs[freepos] = bfsposs[childpos];
450 bfsqueue[bfsposs[freepos]] = freepos;
454 assert(0 <= freepos && freepos < nodepq->len);
456 slots[freepos] = lastnode;
457 bfsposs[freepos] = lastbfspos;
458 bfsqueue[lastbfspos] = freepos;
462 lastbfsqueueidx = bfsqueue[nodepq->
len];
463 bfsparentfelldown =
FALSE;
464 if( freebfspos < nodepq->len )
470 if(
set->exact_enable )
475 bfsqueue[freebfspos] = bfsqueue[parentpos];
476 bfsposs[bfsqueue[freebfspos]] = freebfspos;
477 freebfspos = parentpos;
479 bfsparentfelldown =
TRUE;
481 if( !bfsparentfelldown )
491 assert(childpos < nodepq->len);
493 if( brotherpos < nodepq->len
495 childpos = brotherpos;
502 bfsqueue[freebfspos] = bfsqueue[childpos];
503 bfsposs[bfsqueue[freebfspos]] = freebfspos;
504 freebfspos = childpos;
513 bfsqueue[freebfspos] = bfsqueue[parentpos];
514 bfsposs[bfsqueue[freebfspos]] = freebfspos;
515 freebfspos = parentpos;
517 bfsparentfelldown =
TRUE;
519 if( !bfsparentfelldown )
529 assert(childpos < nodepq->len);
531 if( brotherpos < nodepq->len
533 childpos = brotherpos;
540 bfsqueue[freebfspos] = bfsqueue[childpos];
541 bfsposs[bfsqueue[freebfspos]] = freebfspos;
542 freebfspos = childpos;
546 assert(0 <= freebfspos && freebfspos < nodepq->len);
548 bfsqueue[freebfspos] = lastbfsqueueidx;
549 bfsposs[lastbfsqueueidx] = freebfspos;
552 return parentfelldown;
571 for( pos = 0; pos < nodepq->
len && node != nodepq->
slots[pos]; ++pos )
574 if( pos == nodepq->
len )
609 if( nodepq->
len == 0 )
614 return nodepq->
slots[0];
624 return nodepq->
slots;
648 if( nodepq->
len > 0 )
653 assert(0 <= bfspos && bfspos < nodepq->len);
671 if( nodepq->
len > 0 )
676 assert(0 <= bfspos && bfspos < nodepq->len);
695 if( nodepq->
len > 0 )
700 assert(0 <= bfspos && bfspos < nodepq->len);
702 return nodepq->
slots[bfspos];
738 SCIPsetDebugMsg(
set,
"bounding node queue of length %d with cutoffbound=%g\n", nodepq->
len, cutoffbound);
740 pos = nodepq->
len - 1;
744 assert(pos < nodepq->len);
745 node = nodepq->
slots[pos];
765 SCIPsetDebugMsg(
set,
"cutting off leaf node in slot %d (queuelen=%d) at depth %d with lowerbound=%g\n",
769 if(
set->reopt_enable )
785 if(
set->exact_enable )
790 if( node->
depth == 0 )
793 if(
set->exact_enable )
833 if(
set->misc_calcintegral )
901 if( nodesel->nodeselcopy !=
NULL )
945 (*nodesel)->stdpriority = stdpriority;
946 (*nodesel)->memsavepriority = memsavepriority;
947 (*nodesel)->nodeselcopy = nodeselcopy;
948 (*nodesel)->nodeselfree = nodeselfree;
949 (*nodesel)->nodeselinit = nodeselinit;
950 (*nodesel)->nodeselexit = nodeselexit;
951 (*nodesel)->nodeselinitsol = nodeselinitsol;
952 (*nodesel)->nodeselexitsol = nodeselexitsol;
953 (*nodesel)->nodeselselect = nodeselselect;
954 (*nodesel)->nodeselcomp = nodeselcomp;
955 (*nodesel)->nodeseldata = nodeseldata;
956 (*nodesel)->initialized =
FALSE;
965 &(*nodesel)->stdpriority,
FALSE, stdpriority, INT_MIN/4, INT_MAX/2,
971 &(*nodesel)->memsavepriority,
TRUE, memsavepriority, INT_MIN/4, INT_MAX/4,
1005 nodeselcopy, nodeselfree, nodeselinit, nodeselexit, nodeselinitsol, nodeselexitsol, nodeselselect, nodeselcomp,
1018 if( *nodesel ==
NULL )
1020 assert(!(*nodesel)->initialized);
1024 if( (*nodesel)->nodeselfree !=
NULL )
1026 SCIP_CALL( (*nodesel)->nodeselfree(
set->scip, *nodesel) );
1055 if(
set->misc_resetstat )
1061 if( nodesel->nodeselinit !=
NULL )
1091 if( nodesel->nodeselexit !=
NULL )
1116 if( nodesel->nodeselinitsol !=
NULL )
1121 SCIP_CALL( nodesel->nodeselinitsol(
set->scip, nodesel) );
1140 if( nodesel->nodeselexitsol !=
NULL )
1145 SCIP_CALL( nodesel->nodeselexitsol(
set->scip, nodesel) );
1169 SCIP_CALL( nodesel->nodeselselect(
set->scip, nodesel, selnode) );
1191 return nodesel->nodeselcomp(
set->scip, nodesel, node1, node2);
1201 return nodesel->
name;
1211 return nodesel->
desc;
1293 nodesel->nodeselcopy = nodeselcopy;
1304 nodesel->nodeselfree = nodeselfree;
1315 nodesel->nodeselinit = nodeselinit;
1326 nodesel->nodeselexit = nodeselexit;
1337 nodesel->nodeselinitsol = nodeselinitsol;
1348 nodesel->nodeselexitsol = nodeselexitsol;
void SCIPclockStop(SCIP_CLOCK *clck, SCIP_SET *set)
void SCIPclockEnableOrDisable(SCIP_CLOCK *clck, SCIP_Bool enable)
void SCIPclockStart(SCIP_CLOCK *clck, SCIP_SET *set)
SCIP_Real SCIPclockGetTime(SCIP_CLOCK *clck)
void SCIPclockReset(SCIP_CLOCK *clck)
void SCIPclockFree(SCIP_CLOCK **clck)
SCIP_RETCODE SCIPclockCreate(SCIP_CLOCK **clck, SCIP_CLOCKTYPE clocktype)
internal methods for clocks and timing issues
common defines and data types used in all packages of SCIP
#define SCIP_CALL_FINALLY(x, y)
SCIP_RETCODE SCIPeventProcess(SCIP_EVENT *event, SCIP_SET *set, SCIP_PRIMAL *primal, SCIP_LP *lp, SCIP_BRANCHCAND *branchcand, SCIP_EVENTFILTER *eventfilter)
SCIP_RETCODE SCIPeventChgType(SCIP_EVENT *event, SCIP_EVENTTYPE eventtype)
internal methods for managing events
SCIP_NODETYPE SCIPnodeGetType(SCIP_NODE *node)
SCIP_Real SCIPnodeGetLowerbound(SCIP_NODE *node)
SCIP_RATIONAL * SCIPnodeGetLowerboundExact(SCIP_NODE *node)
int SCIPnodeGetDepth(SCIP_NODE *node)
const char * SCIPnodeselGetDesc(SCIP_NODESEL *nodesel)
SCIP_RETCODE SCIPsetNodeselStdPriority(SCIP *scip, SCIP_NODESEL *nodesel, int priority)
void SCIPnodeselSetData(SCIP_NODESEL *nodesel, SCIP_NODESELDATA *nodeseldata)
SCIP_Bool SCIPnodeselIsInitialized(SCIP_NODESEL *nodesel)
SCIP_NODESELDATA * SCIPnodeselGetData(SCIP_NODESEL *nodesel)
int SCIPnodeselGetMemsavePriority(SCIP_NODESEL *nodesel)
int SCIPnodeselGetStdPriority(SCIP_NODESEL *nodesel)
SCIP_Real SCIPnodeselGetSetupTime(SCIP_NODESEL *nodesel)
SCIP_Real SCIPnodeselGetTime(SCIP_NODESEL *nodesel)
const char * SCIPnodeselGetName(SCIP_NODESEL *nodesel)
SCIP_RETCODE SCIPsetNodeselMemsavePriority(SCIP *scip, SCIP_NODESEL *nodesel, int priority)
void SCIPrationalSetInfinity(SCIP_RATIONAL *res)
#define SCIPrationalDebugMessage
SCIP_Bool SCIPrationalIsLT(SCIP_RATIONAL *rat1, SCIP_RATIONAL *rat2)
void SCIPrationalSetRational(SCIP_RATIONAL *res, SCIP_RATIONAL *src)
SCIP_Bool SCIPrationalIsGEReal(SCIP_RATIONAL *rat, SCIP_Real real)
SCIP_Bool SCIPrationalIsLE(SCIP_RATIONAL *rat1, SCIP_RATIONAL *rat2)
void SCIPsortDownPtr(void **ptrarray, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), int len)
int SCIPsnprintf(char *t, int len, const char *s,...)
assert(minobj< SCIPgetCutoffbound(scip))
SCIP_LPSOLSTAT SCIPlpGetSolstat(SCIP_LP *lp)
internal methods for LP management
static const char * paramname[]
#define BMSfreeMemory(ptr)
#define BMSreallocMemoryArray(ptr, num)
#define BMSduplicateMemoryArray(ptr, source, num)
#define BMSclearMemory(ptr)
struct BMS_BlkMem BMS_BLKMEM
#define BMSfreeMemoryArrayNull(ptr)
#define BMSallocMemory(ptr)
SCIP_Real SCIPnodepqGetLowerbound(SCIP_NODEPQ *nodepq, SCIP_SET *set)
void SCIPnodeselSetExit(SCIP_NODESEL *nodesel,)
void SCIPnodeselSetInit(SCIP_NODESEL *nodesel,)
int SCIPnodepqLen(const SCIP_NODEPQ *nodepq)
void SCIPnodeselSetCopy(SCIP_NODESEL *nodesel,)
void SCIPnodeselSetFree(SCIP_NODESEL *nodesel,)
void SCIPnodeselSetInitsol(SCIP_NODESEL *nodesel,)
void SCIPnodepqDestroy(SCIP_NODEPQ **nodepq)
SCIP_RETCODE SCIPnodepqRemove(SCIP_NODEPQ *nodepq, SCIP_SET *set, SCIP_NODE *node)
SCIP_RETCODE SCIPnodeselExit(SCIP_NODESEL *nodesel, SCIP_SET *set)
void SCIPnodeselEnableOrDisableClocks(SCIP_NODESEL *nodesel, SCIP_Bool enable)
int SCIPnodeselCompare(SCIP_NODESEL *nodesel, SCIP_SET *set, SCIP_NODE *node1, SCIP_NODE *node2)
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)
SCIP_RETCODE SCIPnodeselFree(SCIP_NODESEL **nodesel, SCIP_SET *set)
static int nodepqFindNode(SCIP_NODEPQ *nodepq, SCIP_SET *set, SCIP_NODE *node)
SCIP_RETCODE SCIPnodeselCopyInclude(SCIP_NODESEL *nodesel, SCIP_SET *set)
SCIP_RATIONAL * SCIPnodepqGetLowerboundExact(SCIP_NODEPQ *nodepq, SCIP_SET *set)
SCIP_RETCODE SCIPnodepqSetNodesel(SCIP_NODEPQ **nodepq, SCIP_SET *set, SCIP_NODESEL *nodesel)
static SCIP_RETCODE nodepqResize(SCIP_NODEPQ *nodepq, SCIP_SET *set, int minsize)
SCIP_RETCODE SCIPnodeselExitsol(SCIP_NODESEL *nodesel, SCIP_SET *set)
SCIP_RETCODE SCIPnodepqFree(SCIP_NODEPQ **nodepq, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_TREE *tree, SCIP_LP *lp)
void SCIPnodeselSetExitsol(SCIP_NODESEL *nodesel,)
static SCIP_Bool nodepqDelPos(SCIP_NODEPQ *nodepq, SCIP_SET *set, int rempos)
SCIP_RETCODE SCIPnodeselSelect(SCIP_NODESEL *nodesel, SCIP_SET *set, SCIP_NODE **selnode)
void SCIPnodeselSetStdPriority(SCIP_NODESEL *nodesel, SCIP_SET *set, int priority)
SCIP_NODESEL * SCIPnodepqGetNodesel(SCIP_NODEPQ *nodepq)
SCIP_RETCODE SCIPnodepqInsert(SCIP_NODEPQ *nodepq, SCIP_SET *set, SCIP_NODE *node)
SCIP_NODE * SCIPnodepqFirst(const SCIP_NODEPQ *nodepq)
SCIP_RETCODE SCIPnodepqBound(SCIP_NODEPQ *nodepq, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_Real cutoffbound)
int SCIPnodepqCompare(SCIP_NODEPQ *nodepq, SCIP_SET *set, SCIP_NODE *node1, SCIP_NODE *node2)
SCIP_RETCODE SCIPnodepqCreate(SCIP_NODEPQ **nodepq, SCIP_SET *set, SCIP_NODESEL *nodesel)
static SCIP_RETCODE doNodeselCreate(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)
SCIP_Real SCIPnodepqGetLowerboundSum(SCIP_NODEPQ *nodepq)
SCIP_RETCODE SCIPnodeselInitsol(SCIP_NODESEL *nodesel, SCIP_SET *set)
SCIP_NODE ** SCIPnodepqNodes(const SCIP_NODEPQ *nodepq)
SCIP_NODE * SCIPnodepqGetLowerboundNode(SCIP_NODEPQ *nodepq, SCIP_SET *set)
SCIP_RETCODE SCIPnodeselInit(SCIP_NODESEL *nodesel, SCIP_SET *set)
SCIP_RETCODE SCIPnodepqClear(SCIP_NODEPQ *nodepq, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_TREE *tree, SCIP_LP *lp)
void SCIPnodeselSetMemsavePriority(SCIP_NODESEL *nodesel, SCIP_SET *set, int priority)
internal methods for node selectors and node priority queues
SCIP_PARAMDATA * SCIPparamGetData(SCIP_PARAM *param)
int SCIPparamGetInt(SCIP_PARAM *param)
internal methods for handling parameter settings
internal methods for collecting primal CIP solutions and primal informations
public methods for message output
public data structures and miscellaneous methods
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)
data structures and methods for collecting reoptimization information
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)
int SCIPsetCalcTreeGrowSize(SCIP_SET *set, int num)
SCIP_Bool SCIPsetIsGE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
SCIP_Real SCIPsetInfinity(SCIP_SET *set)
SCIP_Bool SCIPsetIsLT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
internal methods for global SCIP settings
void SCIPstatUpdatePrimalDualIntegrals(SCIP_STAT *stat, SCIP_SET *set, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_Real upperbound, SCIP_Real lowerbound)
internal methods for problem statistics
SCIP_RATIONAL * lowerboundexact
SCIP_NODESELDATA * nodeseldata
SCIP_RATIONAL * lastlowerboundexact
datastructures for managing events
data structures for node selectors and node priority queues
SCIP main data structure.
SCIP_RATIONAL * SCIPtreeGetLowerboundExact(SCIP_TREE *tree, SCIP_SET *set)
SCIP_RETCODE SCIPnodeFree(SCIP_NODE **node, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_TREE *tree, SCIP_LP *lp)
SCIP_Real SCIPtreeGetLowerbound(SCIP_TREE *tree, SCIP_SET *set)
internal methods for branch and bound tree
struct SCIP_EventFilter SCIP_EVENTFILTER
#define SCIP_EVENTTYPE_NODEINFEASIBLE
struct SCIP_EventQueue SCIP_EVENTQUEUE
#define SCIP_EVENTTYPE_DUALBOUNDIMPROVED
struct SCIP_Event SCIP_EVENT
struct SCIP_Messagehdlr SCIP_MESSAGEHDLR
#define SCIP_DECL_SORTPTRCOMP(x)
#define SCIP_DECL_NODESELEXIT(x)
#define SCIP_DECL_NODESELCOMP(x)
#define SCIP_DECL_NODESELINITSOL(x)
struct SCIP_Nodesel SCIP_NODESEL
#define SCIP_DECL_NODESELCOPY(x)
#define SCIP_DECL_NODESELEXITSOL(x)
#define SCIP_DECL_NODESELINIT(x)
#define SCIP_DECL_NODESELSELECT(x)
#define SCIP_DECL_NODESELFREE(x)
struct SCIP_NodeselData SCIP_NODESELDATA
struct SCIP_NodePQ SCIP_NODEPQ
struct SCIP_ParamData SCIP_PARAMDATA
#define SCIP_DECL_PARAMCHGD(x)
struct SCIP_Rational SCIP_RATIONAL
struct SCIP_Reopt SCIP_REOPT
enum SCIP_Retcode SCIP_RETCODE
struct SCIP_Stat SCIP_STAT
struct SCIP_Node SCIP_NODE
struct SCIP_Tree SCIP_TREE
void SCIPvisualCutoffNode(SCIP_VISUAL *visual, SCIP_SET *set, SCIP_STAT *stat, SCIP_NODE *node, SCIP_Bool infeasible)
methods for creating output for visualization tools (VBC, BAK)