23 #ifndef AlpsKnowledgeBroker_h_
24 #define AlpsKnowledgeBroker_h_
81 std::map<AlpsKnowledgeType, AlpsKnowledgePool*>*
pools_;
232 std::map<int, AlpsKnowledge*>::iterator pos, pos1;
315 (std::pair<AlpsKnowledgeType, AlpsKnowledgePool*>(kt, kp));
318 throw CoinError(
"Broker doesn't manage this type of knowledge",
319 "addKnowledgePool()",
"AlpsKnowledgeBroker");
329 throw CoinError(
"Broker doesn't manage this type of knowledge",
330 "getKnowledgePool()",
"AlpsKnowledgeBroker");
344 throw CoinError(
"Broker doesn't manage this type of knowledge",
345 "getMaxNumKnowledges()",
"AlpsKnowledgeBroker");
356 throw CoinError(
"Broker doesn't manage this type of knowledge",
357 "setMaxNumKnowledges()",
"AlpsKnowledgeBroker");
367 throw CoinError(
"Broker doesn't manage this type of knowledge",
368 "hasKnowledge()",
"AlpsKnowledgeBroker");
372 virtual std::pair<AlpsKnowledge*, double>
378 throw CoinError(
"Broker doesn't manage this type of knowledge",
379 "getKnowledge()",
"AlpsKnowledgeBroker");
389 throw CoinError(
"Broker doesn't manage this type of knowledge",
390 "popKnowledge()",
"AlpsKnowledgeBroker");
395 virtual std::pair<AlpsKnowledge*, double>
401 double> >& kls)
const {
406 throw CoinError(
"Broker doesn't manage this type of knowledge",
407 "popKnowledge()",
"AlpsKnowledgeBroker");
419 throw CoinError(
"Broker doesn't manage this type of knowledge",
420 "popKnowledge()",
"AlpsKnowledgeBroker");
void setExitStatus(AlpsExitStatus status)
Set terminate status.
AlpsNodeIndex_t nextIndex_
The index to be assigned to a new search tree node.
int logFileLevel_
The degree of log file.
The base class of knowledge broker class.
void setNodeMemSize(int ms)
int nodeLeftNum_
The number of nodes left.
virtual void setMaxNumKnowledges(AlpsKnowledgeType kt, int num)
Set the max number of knowledge can be stored in a given type o fknowledge pools.
int workerMsgLevel_
The leve of printing message to screen of workers.
virtual void rootSearch(AlpsTreeNode *root)=0
Explore the tree rooted as the given root.
int solNum_
The number of solutions found.
Base class for message handling.
AlpsNodeIndex_t getNextNodeIndex() const
Query the next index assigned to a newly created node.
int getHubMsgLevel()
Return msg level.
std::map< AlpsKnowledgeType, AlpsKnowledgePool * > * pools_
The collection of pools managed by the knowledge broker.
std::map< int, AlpsKnowledge * > decodeMap_
Stores registered knowledge.
AlpsTimer tempTimer_
Secondary timer.
virtual int getNumNodeLeftSystem()
The process queries the objective value of the incumbent that it stores.
double nodeProcessingTime_
The approximately CPU time to process a node.
AlpsExitStatus exitStatus_
The status of search when terminated.
AlpsTimer & subTreeTimer()
Query subtree timer.
virtual int getMaxNumKnowledges() const
Query the quantity limit of knowledges.
void setLanguage(CoinMessages::Language language)
Pass in Message handler (not deleted at end).
virtual ~AlpsKnowledgeBroker()
Destructor.
AlpsSearchStrategy< AlpsSubTree * > * getSubTreeSelection() const
AlpsKnowledgeBroker()
Default constructor.
AlpsKnowledgeBroker & operator=(const AlpsKnowledgeBroker &)
bool userBalancePeriod_
Has user input balance period.
void setComparison(AlpsSearchStrategy< AlpsSubTree * > &compare)
Set comparison function and resort heap.
virtual void popKnowledge(AlpsKnowledgeType kt)
Remove the a knowledge from the given type of knowledge pools.
virtual void addKnowledge(AlpsKnowledge *nk, double priority)=0
Add a knowledge to pool.
virtual int updateNumNodesLeft()
Update the number of left nodes on this process.
void setNodeProcessingTime(double npTime)
virtual double getBestQuality() const =0
The process (serial) / the master (parallel) queries the quality of the best solution that it knows...
int bestSolNode_
The number of nodes pocessed to find the solution.
virtual void popKnowledge()
Remove the queried knowledge from the pool.
int numNodeLog_
Times that node log is printed.
This class contains the data pertaining to a particular subtree in the search tree.
double getNodeProcessingTime()
AlpsPhase phase_
Alps phase.
void setupKnowledgePools()
Set up knowledge pools for this broker.
virtual void search(AlpsModel *model)
Search best solution for a given model.
void setNumNodeLog(int num)
Get times that node log has been printed.
The subtree pool is used to store subtrees.
AlpsSolutionPool * solPool_
A solution pool containing the solutions found.
int getNumNodesPartial() const
Query the number of node in the queue that are pregnant.
std::string logfile_
The log file.
AlpsSearchStrategy< AlpsTreeNode * > * rampUpNodeSelection_
Node selection criterion.
int getNumNodesProcessed() const
Query the number of node processed by this process.
bool needWorkingSubTree_
Indicate whether need a new subtree.
int getTreeDepth()
Get tree depth.
void setSubTreeSelection(AlpsSearchStrategy< AlpsSubTree * > *tc)
int getNumNodesBranched() const
Query the number of node processed by this process.
int systemNodeProcessed_
To record how many nodes processed by the system (used in parallel code).
AlpsNodeIndex_t getMaxNodeIndex() const
Queriy the upper bound of node indices.
AlpsProcessType
This enumerative constant describes the various process types.
AlpsTimer & tempTimer()
Query secondary timer.
virtual AlpsProcessType getProcType() const
Query the type (master, hub, or worker) of the process.
virtual int getMasterRank() const
Query the global rank of the Master.
CoinMessages * messagesPointer()
Return pointer to messages.
This class holds one node of the search tree.
void setMaxNodeIndex(AlpsNodeIndex_t s)
Set the upper bound of node indices.
CoinMessages messages_
Alps messages.
int hubMsgLevel_
The leve of printing message to screen of hubs.
int getMsgLevel()
Return msg level.
void setPhase(AlpsPhase ph)
const AlpsKnowledge * decoderObject(int name)
This method returns the pointer to an empty object of the registered class name. ...
void passInMessageHandler(CoinMessageHandler *handler)
Pass in Message handler (not deleted at end).
AlpsNodeIndex_t maxIndex_
The maximum index can been assigned on this process.
CoinMessages messages()
Return messages.
AlpsSubTreePool * subTreePool_
A subtree pool holding a collection of subtrees.
In the solution pool we assume that the lower the priority value the more desirable the solution is...
virtual double getBestEstimateQuality()
Get best estimalted quality in system.
virtual void setMaxNumKnowledges(int num)
Set the quantity limit of knowledges that can be stored in the pool.
This is a first attempt at a message handler.
double peakMemory_
Peak memory usage.
int largeSize_
The size of largest message buffer can be sent or received.
int msgLevel_
The leve of printing message to screen of the master and general message.
virtual int getMaxNumKnowledges(AlpsKnowledgeType kt) const
Query the max number of knowledge can be stored in a given type of knowledge pools.
AlpsTimer subTreeTimer_
Subtree timer.
The abstract base class of any user-defined class that Alps has to know about in order to encode/deco...
AlpsSearchStrategy< AlpsTreeNode * > * nodeSelection_
Node selection criterion.
virtual AlpsTreeNode * createRoot()
Create the root node.
AlpsSearchStrategy< AlpsTreeNode * > * getRampUpNodeSelection() const
int getlogFileLevel()
Return log file level.
Class to hold and manipulate an array of massaged messages.
virtual void getAllKnowledges(AlpsKnowledgeType kt, std::vector< std::pair< AlpsKnowledge *, double > > &kls) const
Get all knowledges in the given type of knowledge pools.
int nodeDiscardedNum_
The number of nodes that have been discarded before processing.
void addKnowledgePool(AlpsKnowledgeType kt, AlpsKnowledgePool *kp)
Add a knowledge pool into the Knowledge pools.
int treeDepth_
The depth of the tree.
void setRampUpNodeSelection(AlpsSearchStrategy< AlpsTreeNode * > *nc)
virtual std::pair< AlpsKnowledge *, double > getBestKnowledge(AlpsKnowledgeType kt) const
Get the best knowledge in the given type of knowledge pools.
AlpsNodeIndex_t nextNodeIndex()
Query the next index assigned to a newly created node, and then increment the nextIndex_ by 1...
AlpsModel * model_
Pointer to model.
int nodeMemSize_
The approximate memory size (bytes) of a node with full description.
Error Class thrown by an exception.
double getPeakMemory()
Get peak memory usage.
virtual AlpsTreeNode * getBestNode() const
Query the best node in the subtree pool.
void setModel(AlpsModel *m)
AlpsSearchStrategy< AlpsTreeNode * > * getNodeSelection() const
AlpsSubTree * workingSubTree_
Point to the subtree that being explored.
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 s...
void setNodeSelection(AlpsSearchStrategy< AlpsTreeNode * > *nc)
AlpsKnowledgePool * getKnowledgePool(AlpsKnowledgeType kt) const
Retrieve a knowledge pool in the Knowledge base.
CoinMessageHandler * handler_
Message handler.
virtual std::pair< AlpsKnowledge *, double > getKnowledge(AlpsKnowledgeType kt) const
Get a knowledge, but doesn't remove it from the pool.
virtual std::pair< AlpsKnowledge *, double > getKnowledge() const =0
Query a knowledge, but doesn't remove it from the pool.
int getNumNodeLog() const
Get times that node log has been printed.
int getMasterMsgLevel()
Return msg level.
int nodePartialNum_
The number of nodes that are pregnant.
AlpsTimer & timer()
Query timer.
int getNumNodesDiscarded() const
Query the number of node processed by this process.
virtual int getProcRank() const
Qeury the global rank of process.
void registerClass(int name, AlpsKnowledge *userKnowledge)
Every user derived knowledge class must register.
void setNextNodeIndex(AlpsNodeIndex_t s)
Set nextIndex_.
virtual void addKnowledge(AlpsKnowledgeType kt, AlpsKnowledge *kl, double value)
Add a knowledge in the given type of knowledge pools.
virtual void getAllKnowledges(std::vector< std::pair< AlpsKnowledge *, double > > &kls) const
Get a reference to all the knowledges in the pool.
virtual void initializeSearch(int argc, char *argv[], AlpsModel &model)=0
Do some initialization for search.
int nodeBranchedNum_
The number of nodes that have been branched.
int nodeProcessedNum_
The number of nodes that have been processed.
AlpsExitStatus getSolStatus() const
Query search termination status.
virtual bool hasKnowledge(AlpsKnowledgeType kt) const
Query whether there are knowledges in the given type of knowledge pools.
virtual bool hasKnowledge() const
Check whether the pool has knowledge.
void newLanguage(CoinMessages::Language language)
Set language.
int getNumNodesProcessedSystem() const
Query the number of node processed by the system.
Language
Supported languages.
void setPeakMemory(double size)
Set peak memory usage.
virtual void searchLog()=0
Search statistics log.
std::string instanceName_
The instance name.
AlpsTimer timer_
Main timer.
virtual int getNumKnowledges(AlpsKnowledgeType kt) const
Query the number of knowledge in the given type of a knowledge pool.
virtual double getIncumbentValue() const =0
The process queries the objective value of the incumbent that it stores.
AlpsSearchStrategy< AlpsSubTree * > * treeSelection_
Tree selection criterion.
CoinMessageHandler * messageHandler() const
Return handler.