Alps 1.5.12
Loading...
Searching...
No Matches
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-2019, 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
24class KnapSolution : public AlpsSolution {
25 private:
27 int size_;
29 int value_;
31 // I guess it is necessary to add a pointer to model (origin, prosolved)
33
34 public:
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; }
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;
79};
80
81#endif
This data structure is to contain the packed form of an encodable knowledge.
Definition AlpsEncoded.h:25
AlpsKnowledge(const AlpsKnowledge &)
AlpsSolution(const AlpsSolution &)
Diable copy constructor and assignment.
virtual void print(std::ostream &os) const
Print out the solution.
virtual double getQuality() const
const KnapModel * model_
To access model data.
virtual AlpsKnowledge * decode(AlpsEncoded &) const
The method that decodes the node from a encoded object.
int getSolution(int i) const
Get item i in the solution vector.
virtual AlpsEncoded * encode() const
The method that encodes the node into a encoded object.
int getSize() const
Get the size of the solution.
KnapSolution(int s, int *&sol, int v, const KnapModel *m)
double getObjValue() const
Get the best solution value.
int size_
The solution (indicator vector for the items) and its value.
const KnapModel * getModel() const
Get model data.
KnapSolution(const KnapModel *m)