AlpsModel.h
Go to the documentation of this file.
1 /*===========================================================================*
2  * This file is part of the Abstract Library for Parallel Search (ALPS). *
3  * *
4  * ALPS is distributed under the Eclipse Public License as part of the *
5  * COIN-OR repository (http://www.coin-or.org). *
6  * *
7  * Authors: *
8  * *
9  * Yan Xu, Lehigh University *
10  * Ted Ralphs, Lehigh University *
11  * *
12  * Conceptual Design: *
13  * *
14  * Yan Xu, Lehigh University *
15  * Ted Ralphs, Lehigh University *
16  * Laszlo Ladanyi, IBM T.J. Watson Research Center *
17  * Matthew Saltzman, Clemson University *
18  * *
19  * *
20  * Copyright (C) 2001-2013, Lehigh University, Yan Xu, and Ted Ralphs. *
21  *===========================================================================*/
22 
23 #ifndef AlpsModel_h
24 #define AlpsModel_h
25 
26 #include <string>
27 
28 #include "CoinError.hpp"
29 
30 #include "AlpsKnowledge.h"
31 #include "AlpsTreeNode.h"
32 #include "AlpsParams.h"
33 
35 
36 class AlpsModel : public AlpsKnowledge {
37 
38  private:
39 
40  AlpsModel(const AlpsModel&);
41  AlpsModel& operator=(const AlpsModel&);
42 
43  protected:
44 
47 
49  std::string dataFile_;
50 
53 
54  public:
55 
58  broker_(NULL),
60 
62  virtual ~AlpsModel() { delete AlpsPar_; }
63 
66 
69 
71  inline std::string getDataFile() const { return dataFile_; }
72 
74  inline void setDataFile(std::string infile) { dataFile_ = infile; }
75 
77  AlpsParams * AlpsPar() { return AlpsPar_; }
78 
80  virtual void readInstance(const char* dateFile) {
81  throw CoinError("readInstance() is not defined.", "readData",
82  "AlpsModel");
83  }
84 
86  virtual void readParameters(const int argnum, const char * const * arglist);
87 
89  void writeParameters(std::ostream& outstream) const;
90 
93  virtual bool setupSelf() { return true; }
94 
96  virtual void preprocess() {}
97 
99  virtual void postprocess() {}
100 
102  virtual AlpsTreeNode * createRoot() {
103  throw CoinError("createRoot is not defined.", "createRoot",
104  "AlpsModel");
105  }
106 
108  virtual void modelLog() {}
109 
111  virtual void nodeLog(AlpsTreeNode *node, bool force);
112 
114  virtual bool fathomAllNodes() { return false; }
115 
116  //------------------------------------------------------
117  // For parallel.
118  //------------------------------------------------------
119 
121  AlpsReturnStatus encodeAlps(AlpsEncoded *encoded) const;
122 
125 
127  virtual void decodeToSelf(AlpsEncoded& encoded) {}
128 
130  virtual void registerKnowledge() { /* Default does nothing */ }
131 
133  virtual void sendGeneratedKnowledge() { /* Default does nothing */ }
134 
136  virtual void receiveGeneratedKnowledge() { /* Default does nothing */ }
137 
141  /* Default does nothing */
142  AlpsEncoded* encoded = NULL;
143  return encoded;
144  }
145 
148  { /* Default does nothing */ }
149 };
150 #endif
AlpsReturnStatus decodeAlps(AlpsEncoded &encoded)
Unpack Alps portion of node from an encoded object.
The base class of knowledge broker class.
void setDataFile(std::string infile)
Set the data file.
Definition: AlpsModel.h:74
AlpsKnowledgeBroker * broker_
Knowledge broker.
Definition: AlpsModel.h:46
virtual void modelLog()
Problem specific log.
Definition: AlpsModel.h:108
virtual void nodeLog(AlpsTreeNode *node, bool force)
Node log.
AlpsKnowledgeBroker * getKnowledgeBroker()
Get knowledge broker.
Definition: AlpsModel.h:65
AlpsReturnStatus
Definition: Alps.h:118
std::string dataFile_
Data file.
Definition: AlpsModel.h:49
AlpsModel & operator=(const AlpsModel &)
virtual void registerKnowledge()
Register knowledge class.
Definition: AlpsModel.h:130
void writeParameters(std::ostream &outstream) const
Write out parameters.
AlpsParams * AlpsPar()
Access Alps Parameters.
Definition: AlpsModel.h:77
virtual void decodeToSelf(AlpsEncoded &encoded)
Decode model data from the encoded form and fill member data.
Definition: AlpsModel.h:127
This data structure is to contain the packed form of an encodable knowledge.
Definition: AlpsEncoded.h:25
AlpsModel()
Default construtor.
Definition: AlpsModel.h:57
virtual void receiveGeneratedKnowledge()
Receive generated knowledge.
Definition: AlpsModel.h:136
virtual void postprocess()
Postprocessing results.
Definition: AlpsModel.h:99
This class holds one node of the search tree.
Definition: AlpsTreeNode.h:50
virtual void readParameters(const int argnum, const char *const *arglist)
Read in Alps parameters.
std::string getDataFile() const
Get the input file.
Definition: AlpsModel.h:71
virtual ~AlpsModel()
Destructor.
Definition: AlpsModel.h:62
The abstract base class of any user-defined class that Alps has to know about in order to encode/deco...
Definition: AlpsKnowledge.h:51
virtual void unpackSharedKnowledge(AlpsEncoded &)
Unpack and store shared knowledge from an encoded object.
Definition: AlpsModel.h:147
virtual AlpsTreeNode * createRoot()
Create the root node.
Definition: AlpsModel.h:102
AlpsParams * AlpsPar_
The parameter set that is used in Alps.
Definition: AlpsModel.h:52
virtual void sendGeneratedKnowledge()
Send generated knowledge.
Definition: AlpsModel.h:133
void setKnowledgeBroker(AlpsKnowledgeBroker *b)
Set knowledge broker.
Definition: AlpsModel.h:68
Error Class thrown by an exception.
Definition: CoinError.hpp:42
virtual bool setupSelf()
Do necessary work to make model ready for use, such as classify variable and constraint types...
Definition: AlpsModel.h:93
virtual bool fathomAllNodes()
Return true if all nodes on this process can be fathomed.
Definition: AlpsModel.h:114
virtual AlpsEncoded * packSharedKnowlege()
Pack knowledge to be shared with others into an encoded object.
Definition: AlpsModel.h:140
virtual void preprocess()
Preprocessing the model.
Definition: AlpsModel.h:96
AlpsReturnStatus encodeAlps(AlpsEncoded *encoded) const
Pack Alps portion of node into an encoded object.
virtual void readInstance(const char *dateFile)
Read in the instance data.
Definition: AlpsModel.h:80
void setType(KnowledgeType t)
Definition: AlpsKnowledge.h:72