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