Alps
2.0.2
|
AlpsModel is a base class for user application problem data. More...
#include <AlpsModel.h>
Public Member Functions | |
Constructor and Destructor | |
AlpsModel () | |
Default construtor. More... | |
virtual | ~AlpsModel () |
Destructor. More... | |
Get methods | |
std::string | getDataFile () const |
Get the input file. More... | |
AlpsParams * | AlpsPar () |
Access Alps Parameters. More... | |
Set methods | |
void | setDataFile (std::string infile) |
Set the data file. More... | |
Virtual functions required to be implemented by sub-class. | |
virtual void | readInstance (const char *dateFile) |
Read in the instance data. More... | |
virtual void | readParameters (const int argnum, const char *const *arglist) |
Read in Alps parameters. More... | |
void | writeParameters (std::ostream &outstream) const |
Write out parameters. More... | |
virtual bool | setupSelf () |
Do necessary work to make model ready for use, such as classify variable and constraint types. More... | |
virtual void | preprocess () |
Preprocessing the model. More... | |
virtual void | postprocess () |
Postprocessing results. More... | |
virtual AlpsTreeNode * | createRoot ()=0 |
Create the root node. More... | |
virtual void | modelLog () |
Problem specific log. More... | |
virtual void | nodeLog (AlpsTreeNode *node, bool force) |
Node log. More... | |
virtual bool | fathomAllNodes () |
Return true if all nodes on this process can be fathomed. More... | |
Parallel execution related virtual functions | |
virtual AlpsReturnStatus | encode (AlpsEncoded *encoded) const |
Pack AlpsPar_ into a given encode object. More... | |
virtual AlpsReturnStatus | decodeToSelf (AlpsEncoded &encoded) |
Decode the given AlpsEncoded object into this. More... | |
virtual void | registerKnowledge () |
Register knowledge class. More... | |
virtual void | sendGeneratedKnowledge () |
Send generated knowledge. More... | |
virtual void | receiveGeneratedKnowledge () |
Receive generated knowledge. More... | |
virtual AlpsEncoded * | packSharedKnowlege () |
Pack knowledge to be shared with others into an encoded object. More... | |
virtual void | unpackSharedKnowledge (AlpsEncoded &) |
Unpack and store shared knowledge from an encoded object. More... | |
AlpsEncoded * | encode () const |
Get encode function defined in AlpsKnowledge. More... | |
virtual AlpsReturnStatus | encode (AlpsEncoded *encoded) const |
Get encode function defined in AlpsKnowledge. More... | |
Public Member Functions inherited from AlpsKnowledge | |
AlpsKnowledge () | |
Default constructor. More... | |
AlpsKnowledge (AlpsKnowledgeType type) | |
AlpsKnowledge (AlpsKnowledgeType type, AlpsKnowledgeBroker *broker) | |
virtual | ~AlpsKnowledge () |
Destructor. More... | |
AlpsKnowledgeType | getType () const |
Get knowledge type. More... | |
void | setType (AlpsKnowledgeType t) |
Set knowledge type. More... | |
AlpsKnowledgeBroker * | broker () |
Get pointer to the knowledge broker. More... | |
const AlpsKnowledgeBroker * | broker () const |
Get pointer to the knowledge broker. More... | |
void | setBroker (AlpsKnowledgeBroker *broker) |
Set knowledge broker. More... | |
AlpsEncoded * | encode () const |
Encode the content of this into an AlpsEncoded object and return a pointer to it. More... | |
virtual AlpsKnowledge * | decode (AlpsEncoded &encoded) const =0 |
Decode the given AlpsEncoded object into a new AlpsKnowledge object and return a pointer to it. More... | |
Protected Attributes | |
std::string | dataFile_ |
Data file. More... | |
AlpsParams * | AlpsPar_ |
The parameter set that is used in Alps. More... | |
Private Member Functions | |
AlpsModel (const AlpsModel &) | |
AlpsModel & | operator= (const AlpsModel &) |
Additional Inherited Members | |
Public Attributes inherited from AlpsKnowledge | |
AlpsKnowledgeBroker * | broker_ |
AlpsModel is a base class for user application problem data.
For an optimization problem problem parameters, constraint matrix, objective coeefficients, variable bounds are problem data.
User application is required to inherit this for its own model.
AlpsModel has three private data fields only, these are ::broker_, ::dataFile_ and ::AlpsPar_. Some important virtual functions defined in AlpsModel are following.
readInstance(). User application sub-class is supposed to implement this function to read problems from given input files. For example, a MILP solver should implement this function to read mps files. See examples/Abc/AbcModel.cpp. In serial execution this function will be called by the constructor of knowledge broker. In parallel case it will be called by the knowledge broker of the master process only (see Alps main page for a brief explanation of Alps design).
setupSelf(). This function is supposed to set other related problem data after the problem is read by readInstance(). In parallel execution master process's knowledge broker will read the problem data from input file and send it to other processes. Other processes' knowledge broker will receive the problem data. All processes will call setupSelf() to set the other fields of model class. Other fields may incldue fileds that are created from the problem input, which may include user application types needed during the search process. In case of Abc example these are variables, constraints etc.
preprocess(). Alps knowledge brokers will call this function after setupSelf(). It is for prerpocessing the problem before Alps starts the tree search. A MILP solver would carry preseolve operations here. See Blis for an example.
postprocess(). Alps knowledge brokers will call this function after the search is terminated. In parallel execution, only knowledge broker of master process will call this. See Blis for an example.
createRoot(). This function should create the root node to start the search. In parallel execution only master process calls this function.
modelLog(). This function is called when the search is ended. In parallel execution, only knowledge broker of master process will call this. This function is supposed to print problem information/statistics etc. See Blis for an example.
nodeLog(). This function is called every time the node counts hits a user defined value in AlpsParams::intParams::nodeLogInterval. It is supposed to print log information related to search status. In parallel execution this function will be called by master process only.
fathomAllNodes(). If this function returns true, all nodes will be fathomed in the corresponding subtree. This means all of the nodes in serial code.
encode(). This function is supposed to pack the necessary data fields into an AlpsEncoded object. In parallel execution this object will be sent/received between knowledge brokers. Once the data is received, knowledge brokers will call setupSelf() to set the rest of the fields of the user defined model sub-class. Processors other then master will get problem data through these AlpsEncoded objects received through the network (master gets problem data from readInstance()). In a sense this function should pack all the sub-class member fields into an AlpsEncoded object that readInstance() sets in the master processor.
decode(). This function should decode the user sub-class model fields into a user sub-class model object. Alps will call setupSelf() to set the rest of the fields. This is similar to decodeToSelf() except that it unpacks the data into a new user model object, not to this instance. Read decodeToSelf() for mode information.
decodeToSelf(). This function is supposed to unpack the necessary data fields from an AlpsEncoded object. In parallel execution this function will set necessary fields of the user defined model sub-class. In this sense this function is similar to readInstance(). readInstance() is called by the master process only and reads the necessary data from an input file, where this function is called by the other processors and supposed to unpack necessary data not from a file but from an AlpsEncoded object. After this function, Alps will call setupSelf() to set the rest of the fields of the user defined model sub-class. This function is similar to decode(), except that it unpacks the data into this, where decodes creates a new user model object and unpacks the data to it. Read decode() for more information.
Definition at line 132 of file AlpsModel.h.
|
private |
|
inline |
Default construtor.
Definition at line 150 of file AlpsModel.h.
|
inlinevirtual |
Destructor.
Definition at line 154 of file AlpsModel.h.
|
inline |
Get the input file.
Definition at line 160 of file AlpsModel.h.
|
inline |
Access Alps Parameters.
Definition at line 162 of file AlpsModel.h.
|
inline |
Set the data file.
Definition at line 168 of file AlpsModel.h.
|
inlinevirtual |
|
virtual |
void AlpsModel::writeParameters | ( | std::ostream & | outstream | ) | const |
Write out parameters.
|
inlinevirtual |
Do necessary work to make model ready for use, such as classify variable and constraint types.
Reimplemented in AbcModel, AbcModel, and AbcModel.
Definition at line 184 of file AlpsModel.h.
|
inlinevirtual |
Preprocessing the model.
Definition at line 186 of file AlpsModel.h.
|
inlinevirtual |
Postprocessing results.
Definition at line 188 of file AlpsModel.h.
|
pure virtual |
|
inlinevirtual |
Problem specific log.
Definition at line 192 of file AlpsModel.h.
|
virtual |
Node log.
|
inlinevirtual |
Return true if all nodes on this process can be fathomed.
Definition at line 196 of file AlpsModel.h.
|
virtual |
Pack AlpsPar_ into a given encode object.
Reimplemented from AlpsKnowledge.
Reimplemented in AbcModel, AbcModel, AbcModel, and KnapModel.
|
virtual |
Decode the given AlpsEncoded object into this.
Reimplemented from AlpsKnowledge.
Reimplemented in AbcModel, AbcModel, AbcModel, and KnapModel.
|
inlinevirtual |
Register knowledge class.
Definition at line 208 of file AlpsModel.h.
|
inlinevirtual |
Send generated knowledge.
Definition at line 210 of file AlpsModel.h.
|
inlinevirtual |
Receive generated knowledge.
Definition at line 212 of file AlpsModel.h.
|
inlinevirtual |
Pack knowledge to be shared with others into an encoded object.
Return NULL means that no knowledge can be shared.
Definition at line 215 of file AlpsModel.h.
|
inlinevirtual |
Unpack and store shared knowledge from an encoded object.
Definition at line 221 of file AlpsModel.h.
AlpsEncoded* AlpsKnowledge::encode |
Get encode function defined in AlpsKnowledge.
virtual AlpsReturnStatus AlpsKnowledge::encode |
Get encode function defined in AlpsKnowledge.
|
protected |
Data file.
Definition at line 141 of file AlpsModel.h.
|
protected |
The parameter set that is used in Alps.
Definition at line 143 of file AlpsModel.h.