AbcSolution.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  * Ted Ralphs, Lehigh University *
11  * *
12  * Conceptual Design: *
13  * *
14  * Yan Xu, Lehigh University *
15  * Ted Ralphs, Lehigh University *
16  * Laszlo Ladanyi, IBM T.J. Watson Research Center *
17  * Matthew Saltzman, Clemson University *
18  * *
19  * *
20  * Copyright (C) 2001-2013, Lehigh University, Yan Xu, and Ted Ralphs. *
21  *===========================================================================*/
22 
23 #ifndef AbcSolution_h
24 #define AbcSolution_h
25 
26 #include "AlpsSolution.h"
27 
28 #include "AbcModel.h"
29 
31 class AbcSolution : public AlpsSolution {
32  private:
33  int size_;
34  double* value_;
35  double objective_;
36 
37  public:
39  :
40  size_(0),
41  value_(0),
42  objective_()
43  {}
44  AbcSolution(const int s, const double* val, const double obj)
45  :
46  size_(s)
47  {
48  if (size_ >= 0) {
49  value_ = new double [size_];
50  memcpy(value_, val, sizeof(double) * size_);
51  }
52  }
53 
55  if (value_ != 0) {
56  delete [] value_;
57  value_ = 0;
58  }
59  }
60 
62  double getObjValue() const { return objective_; }
63 
64  virtual double getQuality() const { return getObjValue(); }
65 
67  int getSize() const { return size_; }
68 
70  const double* getColSolution() const
71  { return value_; }
72 
74  double getColSolution(int i) const { return value_[i]; }
75 
77  virtual void print(std::ostream& os) const;
78 
80  virtual AlpsEncoded* encode() const;
81 
83  virtual AlpsKnowledge* decode(AlpsEncoded&) const;
84 };
85 
86 #endif
const double * getColSolution() const
Get the column solution.
Definition: AbcSolution.h:70
double objective_
Definition: AbcSolution.h:35
int getSize() const
Get the size of the solution.
Definition: AbcSolution.h:67
This data structure is to contain the packed form of an encodable knowledge.
Definition: AlpsEncoded.h:25
virtual double getQuality() const
Definition: AbcSolution.h:64
This class holds a MIP feasible primal solution.
Definition: AbcSolution.h:31
double * value_
Definition: AbcSolution.h:34
double getColSolution(int i) const
Get item i in the solution vector.
Definition: AbcSolution.h:74
The abstract base class of any user-defined class that Alps has to know about in order to encode/deco...
Definition: AlpsKnowledge.h:51
virtual AlpsEncoded * encode() const
The method that encodes the solution into a encoded object.
virtual void print(std::ostream &os) const
Print out the solution.
virtual AlpsKnowledge * decode(AlpsEncoded &) const
The method that decodes the solution from a encoded object.
double getObjValue() const
Get the objective value value.
Definition: AbcSolution.h:62
AbcSolution(const int s, const double *val, const double obj)
Definition: AbcSolution.h:44