- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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: Yan Xu, Lehigh University *
8 * Ted Ralphs, Lehigh University *
9 * Laszlo Ladanyi, IBM T.J. Watson Research Center *
10 * Matthew Saltzman, Clemson University *
11 * *
12 * *
13 * Copyright (C) 2001-2013, Lehigh University, Yan Xu, and Ted Ralphs. *
14 *===========================================================================*/
15
16 #ifndef KnapSolution_h
17 #define KnapSolution_h
18
19 #include "AlpsSolution.h"
20
21 #include "KnapModel.h"
22
23
24 class KnapSolution : public AlpsSolution {
25 private:
27 int size_;
28 int* solution_;
29 int value_;
31 // I guess it is necessary to add a pointer to model (origin, prosolved)
32 const KnapModel* model_;
33
34 public:
35 KnapSolution(const KnapModel* m)
36 :
37 size_(0),
38 solution_(0),
39 value_(0),
40 model_(m)
41 {}
42 KnapSolution(int s, int*& sol, int v, const KnapModel* m)
43 :
44 size_(s),
45 solution_(sol),
46 value_(v),
47 model_(m)
48 { sol = 0; }
49 ~KnapSolution() {
50 if (solution_ != 0) {
51 delete [] solution_;
52 solution_ = 0;
53 }
54 }
55
57 double getObjValue() const { return value_; }
58
59 virtual double getQuality() const { return getObjValue(); }
60
62 int getSize() const { return size_; }
63
65 int getSolution(int i) const { return solution_[i]; }
66
68 const KnapModel* getModel() const { return model_; }
69
71 virtual void print(std::ostream& os) const;
72
74 virtual AlpsEncoded* encode() const;
75
77 // virtual AlpsKnowledge* decode(const AlpsEncoded&) const;
78 virtual AlpsKnowledge* decode(AlpsEncoded&) const;
79 };
80
81 #endif
KnapSolution::solution_
int * solution_
Definition: KnapSolution.h:28
KnapSolution
Definition: KnapSolution.h:24
KnapSolution::KnapSolution
KnapSolution(const KnapModel *m)
Definition: KnapSolution.h:35
KnapSolution::decode
virtual AlpsKnowledge * decode(AlpsEncoded &) const
The method that decodes the node from a encoded object.
KnapSolution::size_
int size_
The solution (indicator vector for the items) and its value.
Definition: KnapSolution.h:27
AlpsEncoded
This data structure is to contain the packed form of an encodable knowledge.
Definition: AlpsEncoded.h:25
KnapSolution::getSize
int getSize() const
Get the size of the solution.
Definition: KnapSolution.h:62
KnapSolution::~KnapSolution
~KnapSolution()
Definition: KnapSolution.h:49
KnapSolution::model_
const KnapModel * model_
To access model data.
Definition: KnapSolution.h:32
KnapSolution::KnapSolution
KnapSolution(int s, int *&sol, int v, const KnapModel *m)
Definition: KnapSolution.h:42
KnapSolution::print
virtual void print(std::ostream &os) const
Print out the solution.
KnapSolution::encode
virtual AlpsEncoded * encode() const
The method that encodes the node into a encoded object.
KnapModel.h
AlpsKnowledge
The abstract base class of any user-defined class that Alps has to know about in order to encode/deco...
Definition: AlpsKnowledge.h:51
KnapSolution::value_
int value_
Definition: KnapSolution.h:29
KnapSolution::getSolution
int getSolution(int i) const
Get item i in the solution vector.
Definition: KnapSolution.h:65
KnapSolution::getModel
const KnapModel * getModel() const
Get model data.
Definition: KnapSolution.h:68
KnapSolution::getObjValue
double getObjValue() const
Get the best solution value.
Definition: KnapSolution.h:57
AlpsSolution
Definition: AlpsSolution.h:35
KnapSolution::getQuality
virtual double getQuality() const
Definition: KnapSolution.h:59
AlpsSolution.h
KnapModel
Definition: KnapModel.h:26