Dip-All  0.91.0
AlpsDecompSolution.h
Go to the documentation of this file.
1 //===========================================================================//
2 // This file is part of the DIP Solver Framework. //
3 // //
4 // DIP is distributed under the Eclipse Public License as part of the //
5 // COIN-OR repository (http://www.coin-or.org). //
6 // //
7 // Author: Matthew Galati, SAS Institute Inc. (matthew.galati@sas.com) //
8 // //
9 // Conceptual Design: Matthew Galati, SAS Institute Inc. //
10 // Ted Ralphs, Lehigh University //
11 // //
12 // Copyright (C) 2002-2015, Lehigh University, Matthew Galati, Ted Ralphs //
13 // All Rights Reserved. //
14 //===========================================================================//
15 
16 #ifndef AlpsDecompSolution_h
17 #define AlpsDecompSolution_h
18 
19 //===========================================================================//
20 #include "AlpsSolution.h"
21 #include "AlpsDecompModel.h"
22 
23 //===========================================================================//
25 protected:
27  int m_size;
28 
30  double* m_values;
31 
33  double m_quality;
34 
36  const DecompApp* m_app;
37 
38 public:
42  inline const int getSize() const {
43  return m_size;
44  }
45 
47  inline const double* getValues() const {
48  return m_values;
49  }
50 
52  inline const double getQuality() const {
53  return m_quality;
54  }
55 
56 public:
58  AlpsSolution(),
59  m_size (0),
60  m_values (0),
61  m_quality (1e75),
62  m_app (0) {}
63 
64  AlpsDecompSolution(const int size,
65  const double* values,
66  const double quality,
67  const DecompApp* app = NULL,
68  const int depth = -1,
69  const AlpsNodeIndex_t index = -1) :
70  AlpsSolution(index, depth),
71  m_size (size),
72  m_values (0),
73  m_quality (quality),
74  m_app (app) {
75  CoinAssert(m_size > 0);
76  m_values = new double[m_size];
77  CoinAssertHint(m_values, "Error: Out of Memory");
78  memcpy(m_values, values, sizeof(double) * m_size);
79  }
80 
81  virtual ~AlpsDecompSolution() {
83  };
84 
86  virtual void print(std::ostream& os) const {
87  if (m_app) {
88  DecompAlgo* decompAlgo = m_app->getDecompAlgo();
89  DecompConstraintSet* modelCore
90  = decompAlgo->getModelCore().getModel();
92  modelCore->getColNames(),
93  m_values);
94  }
95 
96  /*int i;
97  os << setiosflags(ios::fixed|ios::showpoint)
98  << setw(14);
99 
100  os << "-------------------------" << endl;
101  os << "Quality = " << getQuality() << endl;
102  for (i = 0; i < m_size; i++) {
103  if (!UtilIsZero(m_values[i])){
104  os << setw(6) << i << " " << m_values[i] << endl;
105  }
106  }
107  os << "-------------------------" << endl;
108  os << resetiosflags(ios::fixed|ios::showpoint|ios::scientific); */
109  }
110 };
111 
112 #endif
DecompConstraintSet * getModel() const
Definition: DecompModel.h:38
const int getSize() const
Get length of solution.
virtual void print(std::ostream &os) const
Print out the solution.
virtual ~AlpsDecompSolution()
Get length of solution.
const DecompApp * m_app
Pointer to DecompApp for the print function.
AlpsDecompSolution(const int size, const double *values, const double quality, const DecompApp *app=NULL, const int depth=-1, const AlpsNodeIndex_t index=-1)
Get length of solution.
#define UTIL_DELARR(x)
Definition: UtilMacros.h:29
#define CoinAssertHint(expression, hint)
Definition: CoinError.hpp:180
const DecompAlgoModel & getModelCore() const
Get a ptr to the current solution (in x-space).
Definition: DecompAlgo.h:682
double * m_values
Solution values.
double m_quality
Quality of solution (bound wrt to objective).
DecompAlgo * getDecompAlgo() const
Get a pointer to the base algorithm class.
Definition: DecompApp.h:288
int AlpsNodeIndex_t
Definition: AlpsTreeNode.h:37
int m_size
Length of solution (number of columns).
const std::vector< std::string > & getColNames() const
const double * getValues() const
Get solution values.
virtual void printOriginalSolution(const int n_cols, const std::vector< std::string > &colNames, const double *solution, std::ostream *os=&std::cout) const
Initialize the dual vector for PhaseII of PC.
#define CoinAssert(expression)
Definition: CoinError.hpp:179
Base class for DECOMP algorithms.
Definition: DecompAlgo.h:63
The main application class.
Definition: DecompApp.h:50
AlpsDecompSolution()
Get length of solution.
const double getQuality() const
Get quality of solution.