Go to the documentation of this file.
27 #ifndef AlpsKnowledgeBroker_h_
28 #define AlpsKnowledgeBroker_h_
35 #include "CoinMessageHandler.hpp"
73 std::map<AlpsKnowledgeType, AlpsKnowledgePool*>*
pools_;
187 std::map<int, AlpsKnowledge*>::iterator pos, pos1;
209 std::map<int,AlpsKnowledge*>::const_iterator it =
decodeMap_.find(name);
212 throw std::exception();
224 bool showBanner =
true) = 0;
267 (std::pair<AlpsKnowledgeType, AlpsKnowledgePool*>(kt, kp));
270 throw CoinError(
"Broker doesn't manage this type of knowledge",
271 "addKnowledgePool()",
"AlpsKnowledgeBroker");
280 throw CoinError(
"Broker doesn't manage this type of knowledge",
281 "getKnowledgePool()",
"AlpsKnowledgeBroker");
293 throw CoinError(
"Broker doesn't manage this type of knowledge",
294 "getMaxNumKnowledges()",
"AlpsKnowledgeBroker");
304 throw CoinError(
"Broker doesn't manage this type of knowledge",
305 "setMaxNumKnowledges()",
"AlpsKnowledgeBroker");
315 throw CoinError(
"Broker doesn't manage this type of knowledge",
316 "hasKnowledge()",
"AlpsKnowledgeBroker");
320 virtual std::pair<AlpsKnowledge*, double>
326 throw CoinError(
"Broker doesn't manage this type of knowledge",
327 "getKnowledge()",
"AlpsKnowledgeBroker");
337 throw CoinError(
"Broker doesn't manage this type of knowledge",
338 "popKnowledge()",
"AlpsKnowledgeBroker");
343 virtual std::pair<AlpsKnowledge*, double>
349 double> >& kls)
const {
354 throw CoinError(
"Broker doesn't manage this type of knowledge",
355 "popKnowledge()",
"AlpsKnowledgeBroker");
369 throw CoinError(
"Broker doesn't manage this type of knowledge",
370 "popKnowledge()",
"AlpsKnowledgeBroker");
AlpsNodeIndex_t nextIndex_
The index to be assigned to a new search tree node.
double getPeakMemory()
Get peak memory usage.
AlpsSolutionPool * solPool_
A solution pool containing the solutions found.
void setupKnowledgePools()
Set up knowledge pools for this broker.
void setNodeProcessingTime(double npTime)
AlpsPhase phase_
Alps phase.
AlpsModel * model_
Pointer to model.
virtual void searchLog()=0
Search statistics log.
@ AlpsProcessTypeSerial
Serial.
double peakMemory_
Peak memory usage.
int getNumNodesDiscarded() const
Query the number of node processed by this process.
void setComparison(AlpsSearchStrategy< AlpsSubTree * > &compare)
Set comparison function and resort heap.
int nodeDiscardedNum_
The number of nodes that have been discarded before processing.
AlpsModel is a base class for user application problem data.
int getNumNodesProcessed() const
Query the number of node processed by this process.
int largeSize_
The size of largest message buffer can be sent or received.
AlpsNodeDesc * modifyDesc()
Access the desc so that can modify it.
virtual void printBestSolution(char *outputFile=0) const =0
The process (serial) / the master (parallel) outputs the best solution that it knows to a file or std...
void setPhase(AlpsPhase ph)
AlpsKnowledgeBroker & operator=(const AlpsKnowledgeBroker &)
int getNumNodesPartial() const
Query the number of node in the queue that are pregnant.
std::string instanceName_
The instance name.
AlpsSearchStrategy< AlpsSubTree * > * getSubTreeSelection() const
virtual double getBestQuality() const =0
The process (serial) / the master (parallel) queries the quality of the best solution that it knows.
void setExitStatus(AlpsExitStatus status)
Set terminate status.
void passInMessageHandler(CoinMessageHandler *handler)
Pass in Message handler (not deleted at end).
bool userBalancePeriod_
Has user input balance period.
AlpsSearchStrategy< AlpsSubTree * > * treeSelection_
Tree selection criterion.
CoinMessages messages()
Return messages.
const AlpsKnowledge * decoderObject(int name) const
This method returns the pointer to an empty object of the registered class name.
AlpsExitStatus getSolStatus() const
Query search termination status.
AlpsTimer tempTimer_
Secondary timer.
int nodeMemSize_
The approximate memory size (bytes) of a node with full description.
std::string logfile_
The log file.
AlpsTimer subTreeTimer_
Subtree timer.
int getMsgLevel()
Return msg level.
void setLanguage(CoinMessages::Language language)
virtual int getNumKnowledges(AlpsKnowledgeType kt) const
Query the number of knowledge in the given type of a knowledge pool.
int numNodeLog_
Times that node log is printed.
bool needWorkingSubTree_
Indicate whether need a new subtree.
virtual void search(AlpsModel *model)
Search best solution for a given model.
AlpsProcessType
This enumerative constant describes the various process types.
AlpsSearchStrategy< AlpsTreeNode * > * getNodeSelection() const
virtual AlpsTreeNode * createRoot()=0
Create the root node.
virtual int getNumNodeLeftSystem()
int msgLevel_
The leve of printing message to screen of the master and general message.
virtual double getBestEstimateQuality()
Get best estimalted quality in system.
int nodePartialNum_
The number of nodes that are pregnant.
virtual int getMasterRank() const
Query the global rank of the Master.
virtual AlpsTreeNode * getBestNode() const
Query the best node in the subtree pool.
virtual void rootSearch(AlpsTreeNode *root)=0
Explore the tree rooted as the given root.
virtual void getAllKnowledges(std::vector< std::pair< AlpsKnowledge *, double > > &kls) const =0
Get a reference to all the knowledges in the pool.*/.
int getNumNodesProcessedSystem() const
Query the number of node processed by the system.
AlpsExitStatus exitStatus_
The status of search when terminated.
virtual std::pair< AlpsKnowledge *, double > getKnowledge(AlpsKnowledgeType kt) const
Get a knowledge, but doesn't remove it from the pool.
virtual int getMaxNumKnowledges() const =0
Query the quantity limit of knowledges.
virtual void addKnowledge(AlpsKnowledge *nk, double priority)=0
Add a knowledge to pool.
AlpsSearchStrategy< AlpsTreeNode * > * getRampUpNodeSelection() const
This class holds one node of the search tree.
int nodeProcessedNum_
The number of nodes that have been processed.
void newLanguage(CoinMessages::Language language)
Set language.
int hubMsgLevel_
The leve of printing message to screen of hubs.
This is an abstract base class, fixing an API for pool types of Alps, AlpsNodePool,...
AlpsTimer & timer()
Query timer.
void setNodeSelection(AlpsSearchStrategy< AlpsTreeNode * > *nc)
void setNumNodeLog(int num)
Get times that node log has been printed.
virtual void addKnowledge(AlpsKnowledgeType kt, AlpsKnowledge *kl, double value)
Add a knowledge in the given type of knowledge pools.
void addKnowledgePool(AlpsKnowledgeType kt, AlpsKnowledgePool *kp)
Add a knowledge pool into the Knowledge pools.
std::map< int, AlpsKnowledge * > decodeMap_
Stores registered knowledge.
int solNum_
The number of solutions found.
AlpsSubTree * getWorkingSubTree()
void setSubTreeSelection(AlpsSearchStrategy< AlpsSubTree * > *tc)
AlpsTimer & subTreeTimer()
Query subtree timer.
int getNumNodeLog() const
Get times that node log has been printed.
AlpsKnowledgeType
Type of knowledge like solution, node, cut...
AlpsSubTreePool * subTreePool_
A subtree pool holding a collection of subtrees.
int workerMsgLevel_
The leve of printing message to screen of workers.
AlpsSearchStrategy< AlpsTreeNode * > * nodeSelection_
Node selection criterion.
void setBroker(AlpsKnowledgeBroker *broker)
Set knowledge broker.
The subtree pool is used to store subtrees.
CoinMessages messages_
Alps messages.
virtual std::pair< AlpsKnowledge *, double > getKnowledge() const =0
Check the first item in the pool.
virtual void setMaxNumKnowledges(AlpsKnowledgeType kt, int num)
Set the max number of knowledge can be stored in a given type o fknowledge pools.
AlpsNodeIndex_t maxIndex_
The maximum index can been assigned on this process.
The abstract base class of Alps knowledges generated during the search.
std::map< AlpsKnowledgeType, AlpsKnowledgePool * > * pools_
The collection of pools managed by the knowledge broker.
AlpsSearchStrategy< AlpsTreeNode * > * rampUpNodeSelection_
Node selection criterion.
int getNumNodesBranched() const
Query the number of node processed by this process.
void setNextNodeIndex(AlpsNodeIndex_t s)
Set nextIndex_.
The base class of knowledge broker class.
virtual void getAllKnowledges(AlpsKnowledgeType kt, std::vector< std::pair< AlpsKnowledge *, double > > &kls) const
Get all knowledges in the given type of knowledge pools.
virtual void popKnowledge()=0
Pop the first knowledge from the pool.
virtual bool hasKnowledge() const =0
Check whether the pool is empty.
void setRampUpNodeSelection(AlpsSearchStrategy< AlpsTreeNode * > *nc)
AlpsNodeIndex_t nextNodeIndex()
Query the next index assigned to a newly created node, and then increment the nextIndex_ by 1.
CoinMessages * messagesPointer()
Return pointer to messages.
double getNodeProcessingTime()
virtual double getIncumbentValue() const =0
The process queries the objective value of the incumbent that it stores.
void registerClass(int name, AlpsKnowledge *userKnowledge)
Every user derived knowledge class must register.
void setPeakMemory(double size)
Set peak memory usage.
int nodeLeftNum_
The number of nodes left.
virtual int getMaxNumKnowledges(AlpsKnowledgeType kt) const
Query the max number of knowledge can be stored in a given type of knowledge pools.
@ AlpsKnowledgeTypeSubTree
int systemNodeProcessed_
To record how many nodes processed by the system (used in parallel code).
int getTreeDepth()
Get tree depth.
int nodeBranchedNum_
The number of nodes that have been branched.
void setMaxNodeIndex(AlpsNodeIndex_t s)
Set the upper bound of node indices.
AlpsSubTree * workingSubTree_
Point to the subtree that being explored.
virtual ~AlpsKnowledgeBroker()
Destructor.
double nodeProcessingTime_
The approximately CPU time to process a node.
int logFileLevel_
The degree of log file.
AlpsNodeIndex_t getMaxNodeIndex() const
Queriy the upper bound of node indices.
AlpsTimer & tempTimer()
Query secondary timer.
void setModel(AlpsModel *m)
virtual int getProcRank() const
Qeury the global rank of process.
int getlogFileLevel()
Return log file level.
This class is a comtainer for the solutions found during the search.
virtual AlpsProcessType getProcType() const
Query the type (master, hub, or worker) of the process.
int getHubMsgLevel()
Return msg level.
virtual void popKnowledge(AlpsKnowledgeType kt)
Remove the a knowledge from the given type of knowledge pools.
This class contains the data pertaining to a particular subtree in the search tree.
virtual void setMaxNumKnowledges(int num)=0
Set the quantity limit of knowledges that can be stored in the pool.
virtual int updateNumNodesLeft()
Update the number of left nodes on this process.
virtual void initializeSearch(int argc, char *argv[], AlpsModel &model, bool showBanner=true)=0
Do some initialization for search.
AlpsKnowledgeBroker()
Default constructor.
int getMasterMsgLevel()
Return msg level.
CoinMessageHandler * messageHandler() const
Return handler.
AlpsTimer timer_
Main timer.
void setNodeMemSize(int ms)
virtual bool hasKnowledge(AlpsKnowledgeType kt) const
Query whether there are knowledges in the given type of knowledge pools.
int treeDepth_
The depth of the tree.
int bestSolNode_
The number of nodes pocessed to find the solution.
@ AlpsKnowledgeTypeSolution
AlpsKnowledgePool * getKnowledgePool(AlpsKnowledgeType kt) const
Retrieve a knowledge pool in the Knowledge base.
CoinMessageHandler * handler_
Message handler.
AlpsNodeIndex_t getNextNodeIndex() const
Query the next index assigned to a newly created node.
virtual std::pair< AlpsKnowledge *, double > getBestKnowledge(AlpsKnowledgeType kt) const
Get the best knowledge in the given type of knowledge pools.