- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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
34 class AlpsKnowledgeBroker;
35
36 class AlpsModel : public AlpsKnowledge {
37
38 private:
39
40 AlpsModel(const AlpsModel&);
41 AlpsModel& operator=(const AlpsModel&);
42
43 protected:
44
46 AlpsKnowledgeBroker *broker_;
47
49 std::string dataFile_;
50
52 AlpsParams * AlpsPar_;
53
54 public:
55
57 AlpsModel() :
58 broker_(NULL),
59 AlpsPar_(new AlpsParams) { setType(AlpsKnowledgeTypeModel); }
60
62 virtual ~AlpsModel() { delete AlpsPar_; }
63
65 AlpsKnowledgeBroker *getKnowledgeBroker() { return broker_; }
66
68 void setKnowledgeBroker(AlpsKnowledgeBroker *b) { broker_ = b; }
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
124 AlpsReturnStatus decodeAlps(AlpsEncoded &encoded);
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
140 virtual AlpsEncoded* packSharedKnowlege() {
141 /* Default does nothing */
142 AlpsEncoded* encoded = NULL;
143 return encoded;
144 }
145
147 virtual void unpackSharedKnowledge(AlpsEncoded&)
148 { /* Default does nothing */ }
149 };
150 #endif
AlpsModel::decodeAlps
AlpsReturnStatus decodeAlps(AlpsEncoded &encoded)
Unpack Alps portion of node from an encoded object.
AlpsKnowledgeBroker
The base class of knowledge broker class.
Definition: AlpsKnowledgeBroker.h:48
AlpsModel::setDataFile
void setDataFile(std::string infile)
Set the data file.
Definition: AlpsModel.h:74
AlpsModel::broker_
AlpsKnowledgeBroker * broker_
Knowledge broker.
Definition: AlpsModel.h:46
AlpsModel::modelLog
virtual void modelLog()
Problem specific log.
Definition: AlpsModel.h:108
AlpsModel::nodeLog
virtual void nodeLog(AlpsTreeNode *node, bool force)
Node log.
AlpsModel::getKnowledgeBroker
AlpsKnowledgeBroker * getKnowledgeBroker()
Get knowledge broker.
Definition: AlpsModel.h:65
AlpsReturnStatus
AlpsReturnStatus
Definition: Alps.h:118
CoinError.hpp
AlpsModel::dataFile_
std::string dataFile_
Data file.
Definition: AlpsModel.h:49
AlpsModel::operator=
AlpsModel & operator=(const AlpsModel &)
AlpsModel
Definition: AlpsModel.h:36
AlpsParams.h
AlpsModel::registerKnowledge
virtual void registerKnowledge()
Register knowledge class.
Definition: AlpsModel.h:130
AlpsModel::writeParameters
void writeParameters(std::ostream &outstream) const
Write out parameters.
AlpsModel::AlpsPar
AlpsParams * AlpsPar()
Access Alps Parameters.
Definition: AlpsModel.h:77
AlpsModel::decodeToSelf
virtual void decodeToSelf(AlpsEncoded &encoded)
Decode model data from the encoded form and fill member data.
Definition: AlpsModel.h:127
AlpsEncoded
This data structure is to contain the packed form of an encodable knowledge.
Definition: AlpsEncoded.h:25
AlpsModel::AlpsModel
AlpsModel()
Default construtor.
Definition: AlpsModel.h:57
AlpsModel::receiveGeneratedKnowledge
virtual void receiveGeneratedKnowledge()
Receive generated knowledge.
Definition: AlpsModel.h:136
AlpsModel::postprocess
virtual void postprocess()
Postprocessing results.
Definition: AlpsModel.h:99
AlpsTreeNode
This class holds one node of the search tree.
Definition: AlpsTreeNode.h:50
AlpsModel::readParameters
virtual void readParameters(const int argnum, const char *const *arglist)
Read in Alps parameters.
AlpsModel::getDataFile
std::string getDataFile() const
Get the input file.
Definition: AlpsModel.h:71
AlpsKnowledge.h
AlpsModel::~AlpsModel
virtual ~AlpsModel()
Destructor.
Definition: AlpsModel.h:62
AlpsKnowledge
The abstract base class of any user-defined class that Alps has to know about in order to encode/deco...
Definition: AlpsKnowledge.h:51
AlpsModel::unpackSharedKnowledge
virtual void unpackSharedKnowledge(AlpsEncoded &)
Unpack and store shared knowledge from an encoded object.
Definition: AlpsModel.h:147
AlpsModel::createRoot
virtual AlpsTreeNode * createRoot()
Create the root node.
Definition: AlpsModel.h:102
AlpsModel::AlpsPar_
AlpsParams * AlpsPar_
The parameter set that is used in Alps.
Definition: AlpsModel.h:52
AlpsTreeNode.h
AlpsModel::sendGeneratedKnowledge
virtual void sendGeneratedKnowledge()
Send generated knowledge.
Definition: AlpsModel.h:133
AlpsModel::setKnowledgeBroker
void setKnowledgeBroker(AlpsKnowledgeBroker *b)
Set knowledge broker.
Definition: AlpsModel.h:68
CoinError
Error Class thrown by an exception.
Definition: CoinError.hpp:42
AlpsModel::setupSelf
virtual bool setupSelf()
Do necessary work to make model ready for use, such as classify variable and constraint types...
Definition: AlpsModel.h:93
AlpsModel::fathomAllNodes
virtual bool fathomAllNodes()
Return true if all nodes on this process can be fathomed.
Definition: AlpsModel.h:114
AlpsKnowledgeTypeModel
Definition: Alps.h:89
AlpsModel::packSharedKnowlege
virtual AlpsEncoded * packSharedKnowlege()
Pack knowledge to be shared with others into an encoded object.
Definition: AlpsModel.h:140
AlpsModel::preprocess
virtual void preprocess()
Preprocessing the model.
Definition: AlpsModel.h:96
AlpsParams
Definition: AlpsParams.h:36
AlpsModel::encodeAlps
AlpsReturnStatus encodeAlps(AlpsEncoded *encoded) const
Pack Alps portion of node into an encoded object.
AlpsModel::readInstance
virtual void readInstance(const char *dateFile)
Read in the instance data.
Definition: AlpsModel.h:80
AlpsKnowledge::setType
void setType(KnowledgeType t)
Definition: AlpsKnowledge.h:72