Alps  2.0.2
KnapSolution.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-2019, Lehigh University, Yan Xu, Aykut Bulut, and *
22  * Ted Ralphs. *
23  * All Rights Reserved. *
24  *===========================================================================*/
25 
26 
27 #ifndef KnapSolution_h
28 #define KnapSolution_h
29 
30 #include "AlpsSolution.h"
31 
32 class KnapSolution : public AlpsSolution {
35  int size_;
36  int* solution_;
37  int value_;
38 
39 public:
40  KnapSolution(KnapModel * model);
41  KnapSolution(KnapModel * model, int s, int*& sol, int v);
42  virtual ~KnapSolution();
43 
45  double getObjValue() const { return value_; }
46 
47  virtual double getQuality() const { return getObjValue(); }
48 
50  int getSize() const { return size_; }
51 
53  int getSolution(int i) const { return solution_[i]; }
54 
56  virtual void print(std::ostream& os) const;
57 
60  virtual AlpsReturnStatus encode(AlpsEncoded * encoded) const;
63  std::cerr << "Not implemented!" << std::endl;
64  throw std::exception();
65  }
68  virtual AlpsKnowledge * decode(AlpsEncoded & encoded) const;
69 private:
71  KnapSolution(KnapSolution const & other);
73  KnapSolution & operator=(KnapSolution const & rhs);
74 };
75 
76 #endif
KnapSolution::value_
int value_
Definition: KnapSolution.h:37
AlpsReturnStatus
AlpsReturnStatus
Definition: Alps.h:261
AlpsEncoded
Definition: AlpsEncoded.h:64
KnapSolution::operator=
KnapSolution & operator=(KnapSolution const &rhs)
Disable copy assignment operator.
KnapSolution::decodeToSelf
virtual AlpsReturnStatus decodeToSelf(AlpsEncoded &encoded)
Decode the given AlpsEncoded object into this.
Definition: KnapSolution.h:62
KnapSolution::getSize
int getSize() const
Get the size of the solution.
Definition: KnapSolution.h:50
AlpsSolution.h
AlpsSolution
Definition: AlpsSolution.h:39
KnapSolution::getObjValue
double getObjValue() const
Get the best solution value.
Definition: KnapSolution.h:45
KnapSolution::getQuality
virtual double getQuality() const
Definition: KnapSolution.h:47
KnapSolution::print
virtual void print(std::ostream &os) const
Print out the solution.
KnapModel
Definition: KnapModel.h:39
AlpsKnowledge
The abstract base class of Alps knowledges generated during the search.
Definition: AlpsKnowledge.h:63
KnapSolution::KnapSolution
KnapSolution(KnapModel *model)
AlpsKnowledge::encode
AlpsEncoded * encode() const
Encode the content of this into an AlpsEncoded object and return a pointer to it.
KnapSolution
Definition: KnapSolution.h:32
KnapSolution::decode
virtual AlpsKnowledge * decode(AlpsEncoded &encoded) const
Decode the given AlpsEncoded object into a new KnapSolution and return a pointer to it.
KnapSolution::getSolution
int getSolution(int i) const
Get item i in the solution vector.
Definition: KnapSolution.h:53
KnapSolution::model_
KnapModel * model_
Definition: KnapSolution.h:33
KnapSolution::size_
int size_
The solution (indicator vector for the items) and its value.
Definition: KnapSolution.h:35
KnapSolution::~KnapSolution
virtual ~KnapSolution()
KnapSolution::solution_
int * solution_
Definition: KnapSolution.h:36