coin-Cgl
CglLandPUtils.hpp
Go to the documentation of this file.
1 // Copyright (C) 2005-2008, Pierre Bonami and others. All Rights Reserved.
2 // Author: Pierre Bonami
3 // LIF
4 // CNRS, Aix-Marseille Universites
5 // Date: 02/23/08
6 //---------------------------------------------------------------------------
7 
8 
9 #ifndef CglLandPUtils_H
10 #define CglLandPUtils_H
11 #include "CglLandPTabRow.hpp"
12 
13 class OsiRowCut;
14 class OsiCuts;
15 #include <vector>
16 
17 namespace LAP {
19 double normCoef(TabRow &row, int ncols, const int * nonBasics);
21 void scale(OsiRowCut &cut);
23 void scale(OsiRowCut &cut, double norma);
25 void modularizeRow(TabRow & row, const bool * integerVar);
26 
27 
29 inline double intersectionCutCoef(double alpha_i, double beta)
30 {
31  if (alpha_i>0) return alpha_i* (1 - beta);
32  else return -alpha_i * beta;// (1 - beta);
33 }
34 
36 inline double modularizedCoef(double alpha, double beta)
37 {
38  double f_i = alpha - floor(alpha);
39  if (f_i <= beta)
40  return f_i;
41  else
42  return f_i - 1;
43 }
44 
46 inline bool int_val(double value, double tol)
47 {
48  return fabs( floor( value + 0.5 ) - value ) < tol;
49 }
50 
51 
53 struct Cuts {
54  Cuts(): numberCuts_(0), cuts_(0){
55  }
57  int insertAll(OsiCuts & cs, CoinRelFltEq eq);
59  ~Cuts() {}
61  OsiRowCut * rowCut(unsigned int i) {
62  return cuts_[i];
63  }
65  const OsiRowCut * rowCut(unsigned int i) const {
66  return cuts_[i];
67  }
69  void insert(int i, OsiRowCut * cut);
71  int numberCuts() {
72  return numberCuts_;
73  }
75  void resize(unsigned int i) {
76  cuts_.resize(i, (OsiRowCut *) NULL);
77  }
78 private:
82  std::vector<OsiRowCut *> cuts_;
83 };
84 
85 }
86 #endif
87 
std::vector< OsiRowCut * > cuts_
Store the cuts by index of the generating simple disjunction.
const OsiRowCut * rowCut(unsigned int i) const
const access to row cut indexed by i
double normCoef(TabRow &row, int ncols, const int *nonBasics)
Compute $ {{j=1}^n | a_{ij} |}{1 - a_{i0}} $ for row passed as argument.
double modularizedCoef(double alpha, double beta)
compute the modularized row coefficient for an integer variable
void modularizeRow(TabRow &row, const bool *integerVar)
Modularize row.
int numberCuts_
Stores the number of cuts.
void insert(int i, OsiRowCut *cut)
insert a cut for variable i and count number of cuts.
void resize(unsigned int i)
resize vector.
OsiRowCut * rowCut(unsigned int i)
Access to row cut indexed by i.
bool int_val(double value, double tol)
Says is value is integer.
void scale(OsiRowCut &cut)
scale the cut passed as argument
~Cuts()
Destructor.
int numberCuts()
Access to number of cuts.
int insertAll(OsiCuts &cs, CoinRelFltEq eq)
Puts all the cuts into an OsiCuts.
double intersectionCutCoef(double alpha_i, double beta)
return the coefficients of the intersection cut
To store extra cuts generated by columns from which they origin.