Cgl  0.60.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CglLandPUtils.hpp
Go to the documentation of this file.
1 // Copyright (C) 2005-2009, 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 // $Id: CglLandPUtils.hpp 1122 2013-04-06 20:39:53Z stefan $
8 //
9 // This code is licensed under the terms of the Eclipse Public License (EPL).
10 //---------------------------------------------------------------------------
11 
12 #ifndef CglLandPUtils_H
13 #define CglLandPUtils_H
14 #include "CglLandPTabRow.hpp"
15 
16 class CoinRelFltEq;
17 class OsiRowCut;
18 class OsiCuts;
19 #include <vector>
20 #include <cmath>
21 
22 namespace LAP
23 {
25 double normCoef(TabRow &row, int ncols, const int * nonBasics);
27 void scale(OsiRowCut &cut);
29 void scale(OsiRowCut &cut, double norma);
31 void modularizeRow(TabRow & row, const bool * integerVar);
32 
33 
35 inline double intersectionCutCoef(double alpha_i, double beta)
36 {
37  if (alpha_i>0) return alpha_i* (1 - beta);
38  else return -alpha_i * beta;// (1 - beta);
39 }
40 
42 inline double modularizedCoef(double alpha, double beta)
43 {
44  double f_i = alpha - floor(alpha);
45  if (f_i <= beta)
46  return f_i;
47  else
48  return f_i - 1;
49 }
50 
52 inline bool int_val(double value, double tol)
53 {
54  return fabs( floor( value + 0.5 ) - value ) < tol;
55 }
56 
57 
59 struct Cuts
60 {
62  {
63  }
65  int insertAll(OsiCuts & cs, CoinRelFltEq& eq);
67  ~Cuts() {}
69  OsiRowCut * rowCut(unsigned int i)
70  {
71  return cuts_[i];
72  }
74  const OsiRowCut * rowCut(unsigned int i) const
75  {
76  return cuts_[i];
77  }
79  void insert(int i, OsiRowCut * cut);
81  int numberCuts()
82  {
83  return numberCuts_;
84  }
86  void resize(unsigned int i)
87  {
88  cuts_.resize(i, reinterpret_cast<OsiRowCut *> (NULL));
89  }
90 private:
94  std::vector<OsiRowCut *> cuts_;
95 };
96 
97 }
98 #endif
99 
double modularizedCoef(double alpha, double beta)
compute the modularized row coefficient for an integer variable
void resize(unsigned int i)
resize vector.
int numberCuts_
Stores the number of cuts.
int insertAll(OsiCuts &cs, CoinRelFltEq &eq)
Puts all the cuts into an OsiCuts.
void modularizeRow(TabRow &row, const bool *integerVar)
Modularize row.
Collections of row cuts and column cuts.
Definition: OsiCuts.hpp:19
double normCoef(TabRow &row, int ncols, const int *nonBasics)
Compute $ {{j=1}^n | a_{ij} |}{1 - a_{i0}} $ for row passed as argument.
OsiRowCut * rowCut(unsigned int i)
Access to row cut indexed by i.
Equality to a scaled tolerance.
double intersectionCutCoef(double alpha_i, double beta)
return the coefficients of the intersection cut
bool int_val(double value, double tol)
Says is value is integer.
void scale(OsiRowCut &cut)
scale the cut passed as argument
const OsiRowCut * rowCut(unsigned int i) const
const access to row cut indexed by i
Row Cut Class.
Definition: OsiRowCut.hpp:29
int numberCuts()
Access to number of cuts.
std::vector< OsiRowCut * > cuts_
Store the cuts by index of the generating simple disjunction.
To store extra cuts generated by columns from which they origin.
~Cuts()
Destructor.
void insert(int i, OsiRowCut *cut)
insert a cut for variable i and count number of cuts.