37#ifndef __BB_PARA_NODE_POOL_H__
38#define __BB_PARA_NODE_POOL_H__
50static const double eps = 1.0e-12;
184 double globalBestBound
199 double incumbentValue
215 gzstream::ogzstream &out
254 std::multimap<BbParaNodePtr, BbParaNodePtr, BbParaNodeSortCriterion >
ascendingPool;
276 std::multimap<BbParaNodePtr, BbParaNodePtr, BbParaNodeSortCriterion >::iterator p;
279 if( p->second )
delete p->second;
317 std::multimap<BbParaNodePtr, BbParaNodePtr, BbParaNodeSortCriterion >::iterator p;
321 if( p->second->getMergeNodeInfo() )
324 if( p->second->getMergingStatus() == 4 )
338 extracted = p->second;
346 extracted = p->second;
363 std::multimap<BbParaNodePtr, BbParaNodePtr, BbParaNodeSortCriterion >::reverse_iterator rp;
368 assert( !(rp->second->getMergeNodeInfo()) );
369 extracted = rp->second;
386 std::multimap<BbParaNodePtr, BbParaNodePtr, BbParaNodeSortCriterion >::iterator p;
390 assert( !(p->second->getMergeNodeInfo()) );
407 std::multimap<BbParaNodePtr, BbParaNodePtr, BbParaNodeSortCriterion >::iterator p;
410 if( nNodes == 0 )
return extracted;
415 pos = rand()%
static_cast<int>( nNodes * 0.8 ) +
static_cast<int>(nNodes*0.1);
416 if( pos < (
static_cast<int>(nNodes*0.1)) || pos > nNodes*0.9 )
418 THROW_LOGICAL_ERROR4(
"Invalid pos in extractNodeRandomly in BbParaNodePool: pos = ", pos,
", nNodes = ", nNodes);
420 for(
int j = 0; j < pos; j++ )
430 if( p->second->getMergeNodeInfo() )
433 if( p->second->getMergingStatus() == 4 )
443 std::multimap<BbParaNodePtr, BbParaNodePtr, BbParaNodeSortCriterion >::iterator pp;
449 extracted = pp->second;
458 extracted = p->second;
465 extracted = p->second;
474 if( p->second->getMergeNodeInfo() )
477 if( p->second->getMergingStatus() == 4 )
491 extracted = p->second;
499 extracted = p->second;
515 std::multimap<BbParaNodePtr, BbParaNodePtr, BbParaNodeSortCriterion >::iterator p;
518 if( p->second->getAncestor() == 0 )
520 p->second->updateInitialDualBoundToSubtreeDualBound();
532 gzstream::ogzstream &out
536 std::multimap<BbParaNodePtr, BbParaNodePtr, BbParaNodeSortCriterion >::iterator p;
539 if( p->second->getAncestor() == 0 )
541 p->second->write(out);
557 std::multimap<BbParaNodePtr, BbParaNodePtr, BbParaNodeSortCriterion >::iterator p;
561 return p->second->getDualBoundValue();
574 double globalBestBound
596 std::multimap<BbParaNodePtr, BbParaNodePtr, BbParaNodeSortCriterion >::reverse_iterator rp;
598 ( ( ( rp->second->getDualBoundValue() ) - globalBestBound ) /
599 std::max( fabs(globalBestBound) , 1.0 ) ) >
bgap;
626 double incumbentValue
632 std::multimap<BbParaNodePtr, BbParaNodePtr, BbParaNodeSortCriterion >::iterator p;
636 if( !p->second->getMergeNodeInfo() )
638 if( p->second->getDualBoundValue() > incumbentValue || p->second->getMergingStatus() == 4 )
653 if( p->second->getDualBoundValue() > incumbentValue || p->second->getMergingStatus() == 4 )
684 std::multimap<BbParaNodePtr, BbParaNodePtr, BbParaNodeSortCriterion >::iterator p;
688 if( p->second->getMergingStatus() == 2 )
692 for( ; cur; cur=cur->
next )
694 if( p->second == cur->
node )
709 assert( cur == prev->
next );
715 assert( cur == prev->
next );
718 assert( p->second == cur->
node );
741 std::ostringstream s;
742 std::multimap<BbParaNodePtr, BbParaNodePtr, BbParaNodeSortCriterion >::iterator p;
745 s << p->second->toString();
756 std::multimap<BbParaNodePtr, BbParaNodePtr, BbParaNodeSortCriterionForCleanUp >
descendingPool;
778 std::multimap<BbParaNodePtr, BbParaNodePtr, BbParaNodeSortCriterionForCleanUp >::iterator p;
781 if( p->second )
delete p->second;
819 std::multimap<BbParaNodePtr, BbParaNodePtr, BbParaNodeSortCriterionForCleanUp >::iterator p;
823 if( p->second->getMergeNodeInfo() )
827 extracted = p->second;
842 std::cerr <<
"***** LOGICAL ERROR : should not be called *****" << std::endl;
854 std::multimap<BbParaNodePtr, BbParaNodePtr, BbParaNodeSortCriterionForCleanUp >::iterator p;
858 if( p->second->getMergeNodeInfo() )
862 extracted = p->second;
876 std::multimap<BbParaNodePtr, BbParaNodePtr, BbParaNodeSortCriterionForCleanUp >::iterator p;
879 if( p->second->getAncestor() == 0 )
881 p->second->updateInitialDualBoundToSubtreeDualBound();
893 gzstream::ogzstream &out
897 std::multimap<BbParaNodePtr, BbParaNodePtr, BbParaNodeSortCriterionForCleanUp >::iterator p;
900 if( p->second->getAncestor() == 0 )
902 p->second->write(out);
918 std::multimap<BbParaNodePtr, BbParaNodePtr, BbParaNodeSortCriterionForCleanUp >::reverse_iterator rp;
922 return rp->second->getDualBoundValue();
935 double globalBestBound
944 std::multimap<BbParaNodePtr, BbParaNodePtr, BbParaNodeSortCriterionForCleanUp >::reverse_iterator rp;
946 ( ( ( rp->second->getDualBoundValue() ) - globalBestBound ) /
947 std::max( fabs(globalBestBound) , 1.0 ) ) <
bgap;
970 double incumbentValue
976 std::multimap<BbParaNodePtr, BbParaNodePtr, BbParaNodeSortCriterionForCleanUp >::iterator p;
980 if( !p->second->getMergeNodeInfo() )
982 if( p->second->getDualBoundValue() > incumbentValue )
1020 std::ostringstream s;
1021 std::multimap<BbParaNodePtr, BbParaNodePtr, BbParaNodeSortCriterionForCleanUp >::iterator p;
1024 s << p->second->toString();
Base class for instance data.
Base class for BbParaNode.
Structs used for merging nodes.
virtual int getNBoundChanges()=0
get the number of bound changes
class BbParaNodePoolForCleanUp
const std::string toString()
stringfy this object
int writeBbParaNodesToCheckpointFile(gzstream::ogzstream &out)
write BbParaNodes to checkpoint file
unsigned int getNumOfGoodNodes(double globalBestBound)
get number of good (heavy) BbParaNodes in this pool
size_t getNumOfNodes()
get number of BbParaNodes in this pool
int removeMergedNodes(BbParaMergedNodeListElement *head)
remove merged BbParaNodes from this pool
int removeBoundedNodes(double incumbentValue)
remove bounded BbParaNodes by given incumbnet value
BbParaNodePtr extractWorstNode()
extract a BbParaNode object with the lowest priority from this pool
BbParaNodePtr extractNode()
extract a BbParaNode object from this pool
void insert(BbParaNodePtr paraNode)
insert BbParaNode to this pool
std::multimap< BbParaNodePtr, BbParaNodePtr, BbParaNodeSortCriterionForCleanUp > descendingPool
BbParaNodePoolForCleanUp(double inBgap)
constructor
~BbParaNodePoolForCleanUp()
destructor
void updateDualBoundsForSavingNodes()
update dual bound values for saving BbParaNodes to checkpoint file
double getBestDualBoundValue()
get best dual bound value of BbParaNode object in this pool
BbParaNodePtr extractNodeRandomly()
extract a BbParaNode object randomly from this pool
bool isEmpty()
check if this pool is empty or not
virtual void insert(BbParaNodePtr node)=0
insert BbParaNode to this pool
double bgap
gap which can be considered as good
size_t maxUsageOfPool
maximum usage of this pool
virtual BbParaNodePtr extractNode()=0
extract a BbParaNode object from this pool
virtual double getBestDualBoundValue()=0
get best dual bound value of BbParaNode object in this pool
virtual BbParaNodePtr extractWorstNode()=0
extract a BbParaNode object with the lowest priority from this pool
virtual bool isEmpty()=0
check if this pool is empty or not
BbParaNodePool(double inBgap)
constructor
size_t getMaxUsageOfPool()
get maximum usage of this pool
virtual int removeBoundedNodes(double incumbentValue)=0
remove bounded BbParaNodes by given incumbnet value
virtual ~BbParaNodePool()
destructor
virtual int writeBbParaNodesToCheckpointFile(gzstream::ogzstream &out)=0
write BbParaNodes to checkpoint file
virtual const std::string toString()=0
stringfy this object
virtual void updateDualBoundsForSavingNodes()=0
update dual bound values for saving BbParaNodes to checkpoint file
virtual BbParaNodePtr extractNodeRandomly()=0
extract a BbParaNode object randomly from this pool
virtual size_t getNumOfNodes()=0
get number of BbParaNodes in this pool
virtual unsigned int getNumOfGoodNodes(double globalBestBound)=0
get number of good (heavy) BbParaNodes in this pool
virtual int removeMergedNodes(BbParaMergedNodeListElement *head)=0
remove merged BbParaNodes from this pool
class BbParaNodeSortCriterionForCleanUp
bool operator()(const BbParaNodePtr &n1, const BbParaNodePtr &n2) const
()operator
class BbParaNodeSortCriterion
bool operator()(const BbParaNodePtr &n1, const BbParaNodePtr &n2) const
()operator
BbParaMergeNodeInfo * getMergeNodeInfo()
get merge node information struct
BbParaDiffSubproblem * getDiffSubproblem()
getter of diffSubproblem
double getDualBoundValue()
getter of dual bound value
#define THROW_LOGICAL_ERROR1(msg1)
#define THROW_LOGICAL_ERROR4(msg1, msg2, msg3, msg4)
@ PARA_MERGE_CHECKING_TO_OTHER_NODE
checking possibility to merge with the other nodes
@ PARA_MERGED_RPRESENTATIVE
representative node for merging
@ PARA_MERGING
in merging process
BbParaMergeNodeInfo * mergedTo
pointer to merge node info to which this node is merged */
BbParaNode * paraNode
BbParaNode corresponding to this ParaMergeModeInfo */.
enum UG::BbParaMergeNodeInfo_::@0 status
status of this ParaMargeNodeInfo
merged node list element stract
BbParaMergedNodeListElement * next
pointer to the next ParaMergedNodeListElement
BbParaNode * node
pointer to BbParaNode object