/home/coin/SVN-release/CoinAll-1.1.0/Alps/examples/Knap/KnapSolution.h

Go to the documentation of this file.
00001 /*===========================================================================*
00002  * This file is part of the Abstract Library for Parallel Search (ALPS).     *
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: Yan Xu, Lehigh University                                       *
00008  *          Ted Ralphs, Lehigh University                                    *
00009  *          Laszlo Ladanyi, IBM T.J. Watson Research Center                  *
00010  *          Matthew Saltzman, Clemson University                             *
00011  *                                                                           * 
00012  *                                                                           *
00013  * Copyright (C) 2001-2007, Lehigh University, Yan Xu, and Ted Ralphs.       *
00014  *===========================================================================*/
00015 
00016 #ifndef KnapSolution_h
00017 #define KnapSolution_h
00018 
00019 #include "AlpsSolution.h"
00020 
00021 #include "KnapModel.h"
00022 
00023 
00024 class KnapSolution : public AlpsSolution {
00025  private:
00027   int  size_;
00028   int* solution_;
00029   int  value_;
00031   // I guess it is necessary to add a pointer to model (origin, prosolved)
00032   const KnapModel* model_;
00033 
00034  public:
00035   KnapSolution(const KnapModel* m) 
00036     : 
00037     size_(0), 
00038     solution_(0), 
00039     value_(0), 
00040     model_(m) 
00041     {}
00042   KnapSolution(int s, int*& sol, int v, const KnapModel* m) 
00043     : 
00044     size_(s), 
00045     solution_(sol), 
00046     value_(v),
00047     model_(m)
00048     { sol = 0; }
00049   ~KnapSolution() { 
00050     if (solution_ != 0) {
00051       delete [] solution_; 
00052       solution_ = 0;
00053     }
00054   }
00055   
00057   double getObjValue() const { return value_; }
00058   
00059   virtual double getQuality() const { return getObjValue(); }
00060 
00062   int getSize() const { return size_; }
00063 
00065   int getSolution(int i) const { return solution_[i]; }
00066 
00068   const KnapModel* getModel() const { return model_; }
00069   
00071   virtual void print(std::ostream& os) const;
00072   
00074   virtual AlpsEncoded* encode() const;
00075   
00077   // virtual AlpsKnowledge* decode(const AlpsEncoded&) const;
00078   virtual AlpsKnowledge* decode(AlpsEncoded&) const;
00079 };
00080 
00081 #endif

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