Alps  2.0.2
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  * Aykut Bulut, Lehigh University *
11  * Ted Ralphs, Lehigh University *
12  * *
13  * Conceptual Design: *
14  * *
15  * Yan Xu, Lehigh University *
16  * Ted Ralphs, Lehigh University *
17  * Laszlo Ladanyi, IBM T.J. Watson Research Center *
18  * Matthew Saltzman, Clemson University *
19  * *
20  * *
21  * Copyright (C) 2001-2023, Lehigh University, Yan Xu, Aykut Bulut, and *
22  * Ted Ralphs. *
23  * All Rights Reserved. *
24  *===========================================================================*/
25 
26 
27 #ifndef AlpsModel_h_
28 #define AlpsModel_h_
29 
30 #include <string>
31 
32 #include "CoinError.hpp"
33 
34 #include "AlpsKnowledge.h"
35 #include "AlpsTreeNode.h"
36 #include "AlpsParams.h"
37 
39 
132 class AlpsModel : public AlpsKnowledge {
133 
134 private:
135 
136  AlpsModel(const AlpsModel&);
137  AlpsModel& operator=(const AlpsModel&);
138 
139 protected:
141  std::string dataFile_;
144 
145 public:
146 
148 
149 
152  AlpsPar_(new AlpsParams) { }
154  virtual ~AlpsModel() { delete AlpsPar_; }
156 
158 
159 
160  inline std::string getDataFile() const { return dataFile_; }
162  AlpsParams * AlpsPar() { return AlpsPar_; }
164 
166 
167 
168  inline void setDataFile(std::string infile) { dataFile_ = infile; }
170 
172 
173 
174  virtual void readInstance(const char* dateFile) {
175  throw CoinError("readInstance() is not defined.", "readData",
176  "AlpsModel");
177  }
179  virtual void readParameters(const int argnum, const char * const * arglist);
181  void writeParameters(std::ostream& outstream) const;
184  virtual bool setupSelf() { return true; }
186  virtual void preprocess() {}
188  virtual void postprocess() {}
190  virtual AlpsTreeNode * createRoot() = 0;
192  virtual void modelLog() {}
194  virtual void nodeLog(AlpsTreeNode *node, bool force);
196  virtual bool fathomAllNodes() { return false; }
198 
200 
201  using AlpsKnowledge::encode;
204  virtual AlpsReturnStatus encode(AlpsEncoded * encoded) const;
206  virtual AlpsReturnStatus decodeToSelf(AlpsEncoded & encoded);
208  virtual void registerKnowledge() { /* Default does nothing */ }
210  virtual void sendGeneratedKnowledge() { /* Default does nothing */ }
212  virtual void receiveGeneratedKnowledge() { /* Default does nothing */ }
216  /* Default does nothing */
217  AlpsEncoded* encoded = NULL;
218  return encoded;
219  }
222  { /* Default does nothing */ }
224 };
225 #endif
AlpsModel::readInstance
virtual void readInstance(const char *dateFile)
Read in the instance data.
Definition: AlpsModel.h:174
AlpsModel::AlpsModel
AlpsModel()
Default construtor.
Definition: AlpsModel.h:150
AlpsKnowledge.h
AlpsModel
AlpsModel is a base class for user application problem data.
Definition: AlpsModel.h:132
AlpsParams
Definition: AlpsParams.h:40
AlpsReturnStatus
AlpsReturnStatus
Definition: Alps.h:261
AlpsModel::operator=
AlpsModel & operator=(const AlpsModel &)
AlpsModel::preprocess
virtual void preprocess()
Preprocessing the model.
Definition: AlpsModel.h:186
AlpsModel::sendGeneratedKnowledge
virtual void sendGeneratedKnowledge()
Send generated knowledge.
Definition: AlpsModel.h:210
AlpsEncoded
Definition: AlpsEncoded.h:64
AlpsModel::decodeToSelf
virtual AlpsReturnStatus decodeToSelf(AlpsEncoded &encoded)
Decode the given AlpsEncoded object into this.
AlpsModel::~AlpsModel
virtual ~AlpsModel()
Destructor.
Definition: AlpsModel.h:154
AlpsModel::readParameters
virtual void readParameters(const int argnum, const char *const *arglist)
Read in Alps parameters.
AlpsModel::createRoot
virtual AlpsTreeNode * createRoot()=0
Create the root node.
AlpsTreeNode.h
AlpsTreeNode
This class holds one node of the search tree.
Definition: AlpsTreeNode.h:52
AlpsModel::dataFile_
std::string dataFile_
Data file.
Definition: AlpsModel.h:141
AlpsModel::packSharedKnowlege
virtual AlpsEncoded * packSharedKnowlege()
Pack knowledge to be shared with others into an encoded object.
Definition: AlpsModel.h:215
AlpsModel::receiveGeneratedKnowledge
virtual void receiveGeneratedKnowledge()
Receive generated knowledge.
Definition: AlpsModel.h:212
AlpsModel::fathomAllNodes
virtual bool fathomAllNodes()
Return true if all nodes on this process can be fathomed.
Definition: AlpsModel.h:196
AlpsModel::writeParameters
void writeParameters(std::ostream &outstream) const
Write out parameters.
AlpsModel::modelLog
virtual void modelLog()
Problem specific log.
Definition: AlpsModel.h:192
AlpsModel::AlpsPar_
AlpsParams * AlpsPar_
The parameter set that is used in Alps.
Definition: AlpsModel.h:143
AlpsKnowledge
The abstract base class of Alps knowledges generated during the search.
Definition: AlpsKnowledge.h:63
AlpsKnowledgeBroker
The base class of knowledge broker class.
Definition: AlpsKnowledgeBroker.h:52
AlpsKnowledge::encode
AlpsEncoded * encode() const
Encode the content of this into an AlpsEncoded object and return a pointer to it.
AlpsModel::setupSelf
virtual bool setupSelf()
Do necessary work to make model ready for use, such as classify variable and constraint types.
Definition: AlpsModel.h:184
AlpsModel::AlpsPar
AlpsParams * AlpsPar()
Access Alps Parameters.
Definition: AlpsModel.h:162
AlpsModel::getDataFile
std::string getDataFile() const
Get the input file.
Definition: AlpsModel.h:160
AlpsModel::nodeLog
virtual void nodeLog(AlpsTreeNode *node, bool force)
Node log.
AlpsModel::registerKnowledge
virtual void registerKnowledge()
Register knowledge class.
Definition: AlpsModel.h:208
AlpsKnowledgeTypeModel
@ AlpsKnowledgeTypeModel
Definition: Alps.h:224
AlpsParams.h
AlpsModel::unpackSharedKnowledge
virtual void unpackSharedKnowledge(AlpsEncoded &)
Unpack and store shared knowledge from an encoded object.
Definition: AlpsModel.h:221
AlpsModel::setDataFile
void setDataFile(std::string infile)
Set the data file.
Definition: AlpsModel.h:168
AlpsModel::postprocess
virtual void postprocess()
Postprocessing results.
Definition: AlpsModel.h:188