/home/coin/SVN-release/CoinAll-1.1.0/Blis/src/BlisSolution.h

Go to the documentation of this file.
00001 /*===========================================================================*
00002  * This file is part of the BiCePS Linear Integer Solver (BLIS).             *
00003  *                                                                           *
00004  * ALPS is distributed under the Common Public License as part of the        *
00005  * COIN-OR repository (http://www.coin-or.org).                              *
00006  *                                                                           *
00007  * Authors:                                                                  *
00008  *                                                                           *
00009  *          Yan Xu, Lehigh University                                        *
00010  *          Ted Ralphs, Lehigh University                                    *
00011  *                                                                           *
00012  * Conceptual Design:                                                        *
00013  *                                                                           *
00014  *          Yan Xu, Lehigh University                                        *
00015  *          Ted Ralphs, Lehigh University                                    *
00016  *          Laszlo Ladanyi, IBM T.J. Watson Research Center                  *
00017  *          Matthew Saltzman, Clemson University                             *
00018  *                                                                           * 
00019  *                                                                           *
00020  * Copyright (C) 2001-2007, Lehigh University, Yan Xu, and Ted Ralphs.       *
00021  * All Rights Reserved.                                                      *
00022  *===========================================================================*/
00023 
00024 #ifndef BlisSolution_h_
00025 #define BlisSolution_h_
00026 
00027 #include "Alps.h"
00028 #include "BcpsSolution.h"
00029 
00030 //#############################################################################
00034 //#############################################################################
00035 
00036 class BlisSolution : public BcpsSolution {
00037 
00038  protected:
00039 
00040  public:
00041     
00043     BlisSolution() 
00044         : 
00045         BcpsSolution()
00046         {}
00047 
00049     BlisSolution(int s, const double *values, double objValue)
00050         :
00051         BcpsSolution(s, values, objValue)
00052         {}
00053 
00055     virtual ~BlisSolution() { }
00056 
00059     virtual void print(std::ostream& os) const {
00060         double nearInt = 0.0;
00061         for (int j = 0; j < size_; ++j) {
00062             if (values_[j] > 1.0e-15 || values_[j] < -1.0e-15) {
00063                 nearInt = floor(values_[j] + 0.5);
00064                 if (ALPS_FABS(nearInt - values_[j]) < 1.0e-6) {
00065                     os << "x[" << j << "] = " << nearInt << std::endl;
00066                 }
00067                 else {
00068                     os << "x[" << j << "] = " << values_[j] << std::endl;
00069                 }   
00070             }
00071         }
00072     }
00073     
00076     // BlisIpSolution* testIntegrality(const double etol = 1e-5) const; 
00077     
00078     using AlpsKnowledge::encode ;
00080     virtual AlpsEncoded* encode() const {
00081         AlpsEncoded* encoded = new AlpsEncoded(AlpsKnowledgeTypeSolution);
00082         encodeBcps(encoded);
00083         // Nothing to do for Blis part.
00084         return encoded;
00085     }
00086   
00088     virtual AlpsKnowledge* decode(AlpsEncoded& encoded) const {
00089         BlisSolution * sol = new BlisSolution();
00090         sol->decodeBcps(encoded);
00091         return sol;
00092     }
00093     
00094 };
00095 
00096 //#############################################################################
00097 //#############################################################################
00098 
00099 #endif

Generated on Sun Nov 14 14:06:30 2010 for Coin-All by  doxygen 1.4.7