Dip  0.92.4
VRP_GSECCut.h
Go to the documentation of this file.
1 // $Id: VRP_GSECCut.hpp,v 1.2 2004/06/16 22:26:37 magh Exp $
2 
3 /*-------------------------------------------------------------------------
4  Author: Matthew Galati (magh@lehigh.edu)
5 
6  (c) Copyright 2004 Lehigh University. All Rights Reserved.
7 
8  This software is licensed under the Common Public License. Please see
9  accompanying file for terms.
10  ---------------------------------------------------------------------------*/
11 
12 #ifndef VRP_SUBTOUR_CUT
13 #define VRP_SUBTOUR_CUT
14 /*----------------------------------------------------------------------
15  Type 1: VRP_GSEC_cut
16 
17  Generalized Subtour Elimination Constraints:
18 
19  (i) ACROSS:
20  sum{e in delta(S)} x_e >= 2 * ceil( sum{i in S} d_i / C )
21 
22  (ii) SIDE:
23  sum{e in E(S) } x_e <= |S| - ceil( sum{i in S} d_i / C )
24 
25  (iii) SIDE_COMPL:
26  sum{e in E(Shat)} + 0.5 x({0} : Shat) - 0.5 x({0} : S) <= |Shat| - k(S)
27 
28  if(|S| <= n/2) use (ii), else use (iii) for sparsest form
29 
30  Shat = V \ S (note, V does not include depot here)
31  i.e., customers that are not in the set S
32  ---------------------------------------------------------------------- */
33 
34 #include "Decomp.h"
35 #include "DecompCut.h"
36 
37 #include <vector>
38 using namespace std;
39 
40 //TODO: switch to just use bool vector?
41 #include <boost/dynamic_bitset.hpp>
42 using namespace boost;
43 
44 /*---------------------------------------------------------------------- */
45 class VRP_GSECCut : public DecompCut {
46 public:
47  enum storageType {VECTOR, BITSET, BOTH, NONE};
48  enum cutType {ACROSS, SIDE, SIDE_COMPL};
49 
50 private:
52  const string m_classTag;
53 
54 
55  vector<int> m_S;
56  dynamic_bitset<> m_inS;
59  int m_nverts;
60  int m_demandS;
62 
63 public:
64  //these (pure virutal) methods are inherited from DecompCut
65  virtual void expandCutToRow(CoinPackedVector * row);
66  virtual void setBounds(double infinity);
67 
68  //these (virutal) methods are inherited from DecompCut
69  virtual void print(ostream * os = &cout) const;
70  virtual bool isSame(const DecompCut * cut) const;
71 
72 public:
73  void setStorage();
74  void create_bitset();
75  void create_vector();
76  void setCutType();
77  void setDemand(const int * vertex_wt);
78  const int getSize();
79 
80 public:
81  VRP_GSECCut(const dynamic_bitset<> & inS,
82  const int * vertex_wt,
83  const int capacity,
84  const double infinity,
85  const int demandS = 0) :
86  m_classTag("VRP-GSEC"),
87  m_inS (inS),
88  m_storage (BITSET),
89  m_nverts (m_inS.size()),
90  m_demandS (demandS),
91  m_capacity(capacity)
92  {
93  setStorage();
94  setCutType();
95  setDemand(vertex_wt);
96  setBounds(infinity);
97  }
98 
99  virtual ~VRP_GSECCut() {}
100 };
101 
102 #endif
cutType m_type
Definition: VRP_GSECCut.h:57
VRP_GSECCut(const dynamic_bitset<> &inS, const int *vertex_wt, const int capacity, const double infinity, const int demandS=0)
Definition: VRP_GSECCut.h:81
virtual ~VRP_GSECCut()
Definition: VRP_GSECCut.h:99
storageType m_storage
Definition: VRP_GSECCut.h:58
const string m_classTag
Class id tag (for log / debugging).
Definition: VRP_GSECCut.h:52
vector< int > m_S
Definition: VRP_GSECCut.h:55
#define NONE
Definition: cnrp_const.h:30
Sparse Vector.
int m_capacity
Definition: VRP_GSECCut.h:61
#define BOTH
dynamic_bitset m_inS
Definition: VRP_GSECCut.h:56