- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# /home/coin/SVN-release/Blis-0.91.2/Cgl/src/CglSimpleRounding/CglSimpleRounding.hpp

Go to the documentation of this file.

    00001 // Copyright (C) 2000, International Business Machines
    00002 // Corporation and others.  All Rights Reserved.
    00003 #ifndef CglSimpleRounding_H
    00004 #define CglSimpleRounding_H
    00005
    00006 #include <string>
    00007
    00008 #include "CglCutGenerator.hpp"
    00009 #include "CoinPackedMatrix.hpp"
    00010
    00026 class CglSimpleRounding : public CglCutGenerator {
    00027    friend void CglSimpleRoundingUnitTest(const OsiSolverInterface * siP,
    00028                                          const std::string mpdDir );
    00029
    00030 public:
    00031
    00037   virtual void generateCuts( const OsiSolverInterface & si, OsiCuts & cs,
    00038                              const CglTreeInfo info = CglTreeInfo()) const;
    00040
    00043
    00044   CglSimpleRounding ();
    00045
    00047   CglSimpleRounding (
    00048     const CglSimpleRounding &);
    00049
    00051   virtual CglCutGenerator * clone() const;
    00052
    00054   CglSimpleRounding &
    00055     operator=(
    00056     const CglSimpleRounding& rhs);
    00057
    00059   virtual
    00060     ~CglSimpleRounding ();
    00062   virtual std::string generateCpp( FILE * fp);
    00064
    00065 private:
    00066
    00067   // Private member methods
    00068
    00071
    00073   bool deriveAnIntegerRow(
    00074                           const OsiSolverInterface & si,
    00075                           int rowIndex,
    00076                           const CoinShallowPackedVector & matrixRow,
    00077                           CoinPackedVector & irow,
    00078                           double & b,
    00079                           bool * negative) const;
    00080
    00081
    00097   int power10ToMakeDoubleAnInt(
    00098        int size,               // the length of the vector x
    00099        const double * x,
    00100        double dataTol ) const; // the precision of the data, i.e. the positive
    00101                                // epsilon, which is equivalent to zero
    00102
    00105
    00106   inline  int gcd(int a, int b) const;
    00107
    00111   inline  int gcdv(int n, const int * const vi) const;
    00113
    00115
    00118
    00119   double epsilon_;
    00121 };
    00122
    00123
    00124 //-------------------------------------------------------------------
    00125 // Returns the greatest common denominator of two
    00126 // positive integers, a and b, found using Euclid's algorithm
    00127 //-------------------------------------------------------------------
    00128 int
    00129 CglSimpleRounding::gcd(int a, int b) const
    00130 {
    00131   if(a > b) {
    00132     // Swap a and b
    00133     int temp = a;
    00134     a = b;
    00135     b = temp;
    00136   }
    00137   int remainder = b % a;
    00138   if (remainder == 0) return a;
    00139   else return gcd(remainder,a);
    00140 }
    00141
    00142 //-------------------------------------------------------------------
    00143 // Returns the greatest common denominator of a vector of
    00144 // positive integers, vi, of length n.
    00145 //-------------------------------------------------------------------
    00146 int
    00147 CglSimpleRounding::gcdv(int n, const int* const vi) const
    00148 {
    00149   if (n==0)
    00150     abort();
    00151
    00152   if (n==1)
    00153     return vi[0];
    00154
    00155   int retval=gcd(vi[0], vi[1]);
    00156   for (int i=2; i<n; i++){
    00157      retval=gcd(retval,vi[i]);
    00158   }
    00159   return retval;
    00160 }
    00161
    00162 //#############################################################################
    00168 void CglSimpleRoundingUnitTest(const OsiSolverInterface * siP,
    00169                                const std::string mpdDir );
    00170
    00171 #endif