AlpsDecompSolution.h

Go to the documentation of this file.
00001 //===========================================================================//
00002 // This file is part of the DIP Solver Framework.                            //
00003 //                                                                           //
00004 // DIP is distributed under the Eclipse Public License as part of the        //
00005 // COIN-OR repository (http://www.coin-or.org).                              //
00006 //                                                                           //
00007 // Author: Matthew Galati, SAS Institute Inc. (matthew.galati@sas.com)       //
00008 //                                                                           //
00009 // Conceptual Design: Matthew Galati, SAS Institute Inc.                     //
00010 //                    Ted Ralphs, Lehigh University                          //
00011 //                                                                           //
00012 // Copyright (C) 2002-2015, Lehigh University, Matthew Galati, Ted Ralphs    //
00013 // All Rights Reserved.                                                      //
00014 //===========================================================================//
00015 
00016 #ifndef AlpsDecompSolution_h
00017 #define AlpsDecompSolution_h
00018 
00019 //===========================================================================//
00020 #include "AlpsSolution.h"
00021 #include "AlpsDecompModel.h"
00022 
00023 //===========================================================================//
00024 class AlpsDecompSolution : public AlpsSolution {
00025 protected:
00027    int      m_size;
00028 
00030    double* m_values;
00031 
00033    double   m_quality;
00034 
00036    const DecompApp* m_app;
00037 
00038 public:
00042    inline const int getSize() const {
00043       return m_size;
00044    }
00045 
00047    inline const double* getValues() const {
00048       return m_values;
00049    }
00050 
00052    inline const double getQuality() const {
00053       return m_quality;
00054    }
00055 
00056 public:
00057    AlpsDecompSolution() :
00058       AlpsSolution(),
00059       m_size      (0),
00060       m_values    (0),
00061       m_quality   (1e75),
00062       m_app       (0) {}
00063 
00064    AlpsDecompSolution(const int             size,
00065                       const double*         values,
00066                       const double          quality,
00067                       const DecompApp*      app = NULL,
00068                       const int             depth = -1,
00069                       const AlpsNodeIndex_t index = -1) :
00070       AlpsSolution(index, depth),
00071       m_size      (size),
00072       m_values    (0),
00073       m_quality   (quality),
00074       m_app       (app) {
00075       CoinAssert(m_size > 0);
00076       m_values = new double[m_size];
00077       CoinAssertHint(m_values, "Error: Out of Memory");
00078       memcpy(m_values, values, sizeof(double) * m_size);
00079    }
00080 
00081    virtual ~AlpsDecompSolution() {
00082       UTIL_DELARR(m_values);
00083    };
00084 
00086    virtual void print(std::ostream& os) const {
00087       if (m_app) {
00088          DecompAlgo*           decompAlgo = m_app->getDecompAlgo();
00089          DecompConstraintSet* modelCore
00090          = decompAlgo->getModelCore().getModel();
00091          m_app->printOriginalSolution(m_size,
00092                                       modelCore->getColNames(),
00093                                       m_values);
00094       }
00095 
00096       /*int i;
00097       os << setiosflags(ios::fixed|ios::showpoint)
00098          << setw(14);
00099 
00100       os << "-------------------------" << endl;
00101       os << "Quality = " << getQuality() << endl;
00102       for (i = 0; i < m_size; i++) {
00103          if (!UtilIsZero(m_values[i])){
00104        os << setw(6) << i << " " << m_values[i] << endl;
00105          }
00106       }
00107       os << "-------------------------" << endl;
00108       os << resetiosflags(ios::fixed|ios::showpoint|ios::scientific); */
00109    }
00110 };
00111 
00112 #endif

Generated on 3 Jun 2015 for Dip-All by  doxygen 1.6.1