Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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
00077
00078 using AlpsKnowledge::encode ;
00080 virtual AlpsEncoded* encode() const {
00081 AlpsEncoded* encoded = new AlpsEncoded(AlpsKnowledgeTypeSolution);
00082 encodeBcps(encoded);
00083
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