DecompSolution.h

Go to the documentation of this file.
00001 //===========================================================================//
00002 // This file is part of the Decomp Solver Framework.                         //
00003 //                                                                           //
00004 // Decomp is distributed under the Common Public License as part of the      //
00005 // COIN-OR repository (http://www.coin-or.org).                              //
00006 //                                                                           //
00007 // Author: Matthew Galati, Lehigh University                                 //
00008 //                                                                           //
00009 // Copyright (C) 2002-2007, Lehigh University, Matthew Galati, and Ted Ralphs//
00010 // All Rights Reserved.                                                      //
00011 //===========================================================================//
00012 
00013 #ifndef DECOMP_SOLUTION_INCLUDED
00014 #define DECOMP_SOLUTION_INCLUDED
00015 
00016 class DecompSolution {
00017 protected:
00019    int      m_size;
00020 
00022    double* m_values;
00023 
00025    double   m_quality;
00026 
00027 public:
00031    inline const int getSize() const {
00032       return m_size;
00033    }
00034 
00036    inline const double* getValues() const {
00037       return m_values;
00038    }
00039 
00041    inline const double getQuality() const {
00042       return m_quality;
00043    }
00044 
00045 public:
00046    virtual void print(ostream& os = cout) const {
00047       int i;
00048       os << setiosflags(ios::fixed | ios::showpoint)
00049          << setw(14);
00050       os << "-------------------------" << endl;
00051 
00052       for (i = 0; i < m_size; i++) {
00053          if (!UtilIsZero(m_values[i])) {
00054             os << setw(6) << i << " " << m_values[i] << endl;
00055          }
00056       }
00057 
00058       os << "-------------------------" << endl;
00059       os << resetiosflags(ios::fixed | ios::showpoint | ios::scientific);
00060    }
00061 
00062 public:
00064    DecompSolution(const DecompSolution& source) :
00065       m_size(source.m_size),
00066       m_values(0),
00067       m_quality(source.m_quality) {
00068       m_values = new double[m_size];
00069       CoinAssertHint(m_values, "Error: Out of Memory");
00070       memcpy(m_values, source.m_values, m_size * sizeof(double));
00071    }
00072    DecompSolution& operator=(const DecompSolution& rhs) {
00073       if (this != &rhs) {
00074          m_size    = rhs.m_size;
00075          m_quality = rhs.m_quality;
00076          m_values = new double[m_size];
00077          CoinAssertHint(m_values, "Error: Out of Memory");
00078          memcpy(m_values, rhs.m_values, m_size * sizeof(double));
00079       }
00080 
00081       return *this;
00082    }
00083 
00084 public:
00088    DecompSolution() :
00089       m_size(0),
00090       m_values(0),
00091       m_quality(DecompInf) {
00092    }
00093 
00095    DecompSolution(const int      size,
00096                   const double* values,
00097                   const double   quality) :
00098       m_size(size),
00099       m_values(0),
00100       m_quality(quality) {
00101       CoinAssert(m_size > 0);
00102       m_values = new double[m_size];
00103       CoinAssertHint(m_values, "Error: Out of Memory");
00104       memcpy(m_values, values, m_size * sizeof(double));
00105    }
00106 
00107    virtual ~DecompSolution() {
00108       UTIL_DELARR(m_values);
00109    };
00110 };
00111 
00112 #endif

Generated on 12 Feb 2015 for Dip-All by  doxygen 1.6.1