Alps  2.0.2
AlpsSolution.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 AlpsSolution_h_
28 #define AlpsSolution_h_
29 
30 #include <iosfwd>
31 #include <map>
32 #include <vector>
33 
34 #include "AlpsKnowledge.h"
35 #include "AlpsTreeNode.h" // to get AlpsNodeIndex_t
36 
37 //#############################################################################
38 
39 class AlpsSolution : public AlpsKnowledge {
40 
41 private:
43  AlpsSolution(const AlpsSolution&);
45 
47  int index_;
48 
50  int depth_;
51 
52 public:
53 
56  index_(-1), depth_(-1) {
57  }
58 
60  AlpsSolution(const AlpsNodeIndex_t i, const int d): index_(i), depth_(d) {
62  }
63 
65  virtual ~AlpsSolution() {}
66 
69 
71  void setIndex(const AlpsNodeIndex_t i) { index_ = i; }
72 
74  int getDepth() { return depth_; }
75 
77  void setDepth(const int d) { depth_ = d; }
78 
80  virtual void print(std::ostream& os) const{
81  os << "WARNING: No solution print function is defined." << std::endl;
82  }
83 
86 
88  virtual AlpsReturnStatus encode(AlpsEncoded * encoded) const {
89  encoded->writeRep(index_);
90  encoded->writeRep(depth_);
91  return AlpsReturnStatusOk;
92  }
93 
96  encoded.readRep(index_);
97  encoded.readRep(depth_);
98  return AlpsReturnStatusOk;
99  }
100 
101 };
102 
103 #endif
AlpsSolution::~AlpsSolution
virtual ~AlpsSolution()
Destructor.
Definition: AlpsSolution.h:65
AlpsKnowledge.h
AlpsSolution::operator=
AlpsSolution & operator=(const AlpsSolution &)
AlpsSolution::getIndex
AlpsNodeIndex_t getIndex()
Get index where solution was found.
Definition: AlpsSolution.h:68
AlpsReturnStatus
AlpsReturnStatus
Definition: Alps.h:261
AlpsSolution::print
virtual void print(std::ostream &os) const
Print out the solution.
Definition: AlpsSolution.h:80
AlpsEncoded
Definition: AlpsEncoded.h:64
AlpsSolution::decodeToSelf
virtual AlpsReturnStatus decodeToSelf(AlpsEncoded &encoded)
Decode the given AlpsEncoded object into this.
Definition: AlpsSolution.h:95
AlpsTreeNode.h
AlpsEncoded::writeRep
AlpsEncoded & writeRep(const T &value)
Write a single object of type T in repsentation_ .
Definition: AlpsEncoded.h:201
AlpsEncoded::readRep
AlpsEncoded & readRep(T &value)
Read a single object of type T from repsentation_ .
Definition: AlpsEncoded.h:211
AlpsSolution
Definition: AlpsSolution.h:39
AlpsReturnStatusOk
@ AlpsReturnStatusOk
Definition: Alps.h:262
AlpsKnowledge::setType
void setType(AlpsKnowledgeType t)
Set knowledge type.
Definition: AlpsKnowledge.h:84
AlpsKnowledge
The abstract base class of Alps knowledges generated during the search.
Definition: AlpsKnowledge.h:63
AlpsKnowledge::encode
AlpsEncoded * encode() const
Encode the content of this into an AlpsEncoded object and return a pointer to it.
AlpsSolution::encode
virtual AlpsReturnStatus encode(AlpsEncoded *encoded) const
Encode this into the given AlpsEncoded object.
Definition: AlpsSolution.h:88
AlpsSolution::setDepth
void setDepth(const int d)
Set depth where solution was found.
Definition: AlpsSolution.h:77
AlpsSolution::setIndex
void setIndex(const AlpsNodeIndex_t i)
Set index where solution was found.
Definition: AlpsSolution.h:71
AlpsSolution::index_
int index_
The index of the node where the solution was found.
Definition: AlpsSolution.h:47
AlpsSolution::getDepth
int getDepth()
Get depth where solution was found.
Definition: AlpsSolution.h:74
AlpsSolution::AlpsSolution
AlpsSolution(const AlpsNodeIndex_t i, const int d)
Constructor to set index and depth.
Definition: AlpsSolution.h:60
AlpsKnowledgeTypeSolution
@ AlpsKnowledgeTypeSolution
Definition: Alps.h:228
AlpsNodeIndex_t
int AlpsNodeIndex_t
Definition: Alps.h:174
AlpsSolution::depth_
int depth_
The depth of the node where the solution was found.
Definition: AlpsSolution.h:50
AlpsSolution::AlpsSolution
AlpsSolution()
Default constructor.
Definition: AlpsSolution.h:55