coin-Cgl
|
00001 // Copyright (C) 2005-2008, Pierre Bonami and others. All Rights Reserved. 00002 // Author: Pierre Bonami 00003 // LIF 00004 // CNRS, Aix-Marseille Universites 00005 // Date: 02/23/08 00006 //--------------------------------------------------------------------------- 00007 00008 00009 #ifndef CglLandPUtils_H 00010 #define CglLandPUtils_H 00011 #include "CglLandPTabRow.hpp" 00012 00013 class OsiRowCut; 00014 class OsiCuts; 00015 #include <vector> 00016 00017 namespace LAP { 00019 double normCoef(TabRow &row, int ncols, const int * nonBasics); 00021 void scale(OsiRowCut &cut); 00023 void scale(OsiRowCut &cut, double norma); 00025 void modularizeRow(TabRow & row, const bool * integerVar); 00026 00027 00029 inline double intersectionCutCoef(double alpha_i, double beta) 00030 { 00031 if (alpha_i>0) return alpha_i* (1 - beta); 00032 else return -alpha_i * beta;// (1 - beta); 00033 } 00034 00036 inline double modularizedCoef(double alpha, double beta) 00037 { 00038 double f_i = alpha - floor(alpha); 00039 if (f_i <= beta) 00040 return f_i; 00041 else 00042 return f_i - 1; 00043 } 00044 00046 inline bool int_val(double value, double tol) 00047 { 00048 return fabs( floor( value + 0.5 ) - value ) < tol; 00049 } 00050 00051 00053 struct Cuts { 00054 Cuts(): numberCuts_(0), cuts_(0){ 00055 } 00057 int insertAll(OsiCuts & cs, CoinRelFltEq eq); 00059 ~Cuts() {} 00061 OsiRowCut * rowCut(unsigned int i) { 00062 return cuts_[i]; 00063 } 00065 const OsiRowCut * rowCut(unsigned int i) const { 00066 return cuts_[i]; 00067 } 00069 void insert(int i, OsiRowCut * cut); 00071 int numberCuts() { 00072 return numberCuts_; 00073 } 00075 void resize(unsigned int i) { 00076 cuts_.resize(i, (OsiRowCut *) NULL); 00077 } 00078 private: 00080 int numberCuts_; 00082 std::vector<OsiRowCut *> cuts_; 00083 }; 00084 00085 } 00086 #endif 00087