CglClique.hpp
Go to the documentation of this file.
1 // $Id: CglClique.hpp 1119 2013-04-06 20:24:18Z stefan $
2 // Copyright (C) 2000, International Business Machines
3 // Corporation and others. All Rights Reserved.
4 // This code is licensed under the terms of the Eclipse Public License (EPL).
5 
6 #ifndef _CglClique_h_
7 #define _CglClique_h_
8 
9 #include "CglCutGenerator.hpp"
10 
11 //class OsiCuts;
12 //class OsiSolverInterface;
13 
14 class CglClique : public CglCutGenerator {
15 
16  friend void CglCliqueUnitTest(const OsiSolverInterface * siP,
17  const std::string mpdDir );
18 public:
20  CglClique(const CglClique& rhs);
22  virtual CglCutGenerator * clone() const;
23 
25  CglClique& operator=(const CglClique& rhs);
26 
27 public:
28 
29  virtual void
30  generateCuts(const OsiSolverInterface& si, OsiCuts & cs,
31  const CglTreeInfo info = CglTreeInfo());
32 
53  CglClique(bool setPacking = false, bool justOriginalRows = false);
55  virtual ~CglClique() {}
57  virtual std::string generateCpp( FILE * fp);
58 
59  void considerRows(const int numRows, const int* rowInd);
60 
61 public:
68  };
69 
71  scl_next_node_rule = method;
72  }
73 
76  }
79  }
80 
81  void setStarCliqueReport(bool yesno = true) { scl_report_result = yesno; }
82  void setRowCliqueReport(bool yesno = true) { rcl_report_result = yesno; }
83 
84  void setDoStarClique(bool yesno = true) { do_star_clique = yesno; }
85  void setDoRowClique(bool yesno = true) { do_row_clique = yesno; }
86 
87  void setMinViolation(double minviol) { petol = minviol; }
88  double getMinViolation() const { return petol; }
89 
90 private:
91 
92  struct frac_graph ;
93  friend struct frac_graph ;
94 
97  struct fnode {
99  int *nbrs;
102  double *edgecosts;
104  int degree;
106  double val;
107  };
108 
111  struct frac_graph {
113  int nodenum;
115  int edgenum;
117  double density;
126  int *all_nbr;
128  double *all_edgecost;
129 
131  nodenum(0), edgenum(0), density(0),
133  nodes(0), all_nbr(0), all_edgecost(0) {}
134  };
135 
136 protected:
147  double* sp_colsol;
152 
156  bool* node_node;
157 
159  double petol;
160 
169 
179 
194  const int* cl_perm_indices;
197 
203 
210 
213 private:
219  void selectFractionals(const OsiSolverInterface& si);
221  void selectRowCliques(const OsiSolverInterface& si,int numOriginalRows);
225  void createFractionalGraph();
227  int createNodeNode();
231  void deleteFractionalGraph();
233  void find_scl(OsiCuts& cs);
235  void find_rcl(OsiCuts& cs);
237  int scl_choose_next_node(const int current_nodenum,
238  const int *current_indices,
239  const int *current_degrees,
240  const double *current_values);
242  void scl_delete_node(const int del_ind, int& current_nodenum,
243  int *current_indices, int *current_degrees,
244  double *current_values);
246  int enumerate_maximal_cliques(int& pos, bool* scl_label, OsiCuts& cs);
250  void recordClique(const int len, int* indices, OsiCuts& cs);
251 };
252 //#############################################################################
258 void CglCliqueUnitTest(const OsiSolverInterface * siP,
259  const std::string mpdDir);
261 class CglProbing;
262 class CglFakeClique : public CglClique {
263 
264 public:
266  CglFakeClique(const CglFakeClique& rhs);
268  virtual CglCutGenerator * clone() const;
269 
272 
273  virtual void
274  generateCuts(const OsiSolverInterface& si, OsiCuts & cs,
275  const CglTreeInfo info = CglTreeInfo());
276 
296  CglFakeClique(OsiSolverInterface * solver=NULL,bool setPacking = false);
298  virtual ~CglFakeClique();
300  void assignSolver(OsiSolverInterface * fakeSolver);
301 protected:
306 };
307 
308 #endif
A graph corresponding to a fractional solution of an LP.
Definition: CglClique.hpp:111
int createNodeNode()
int * cl_del_indices
An array of nodes discarded from the candidate list.
Definition: CglClique.hpp:207
void CglCliqueUnitTest(const OsiSolverInterface *siP, const std::string mpdDir)
A function that tests the methods in the CglClique class.
bool justOriginalRows_
True if just look at original rows.
Definition: CglClique.hpp:141
int scl_choose_next_node(const int current_nodenum, const int *current_indices, const int *current_degrees, const double *current_values)
double petol
The primal tolerance in the solverinterface.
Definition: CglClique.hpp:159
double * edgecosts
1-x_i-x_j, needed for odd holes, in the same order as the adj list, pointer into all_edgecost ...
Definition: CglClique.hpp:102
int cl_perm_length
The length of cl_perm_indices.
Definition: CglClique.hpp:196
void scl_delete_node(const int del_ind, int &current_nodenum, int *current_indices, int *current_degrees, double *current_values)
OsiSolverInterface * fakeSolver_
fake solver to use
Definition: CglClique.hpp:303
double density
density= edgenum/(nodenum choose 2)
Definition: CglClique.hpp:117
CglClique & operator=(const CglClique &rhs)
Assignment operator.
virtual CglCutGenerator * clone() const
Clone.
int * sp_orig_row_ind
possible choices for selecting the next node in the star clique search
Definition: CglClique.hpp:144
virtual std::string generateCpp(FILE *fp)
Create C++ lines to get to current state.
void selectFractionalBinaries(const OsiSolverInterface &si)
Scan through the variables and select those that are binary and are at a fractional level...
bool * node_node
the node-node incidence matrix of the intersection graph.
Definition: CglClique.hpp:156
int * all_nbr
The array of all the neighbors.
Definition: CglClique.hpp:126
virtual void generateCuts(const OsiSolverInterface &si, OsiCuts &cs, const CglTreeInfo info=CglTreeInfo())
Generate cuts for the model data contained in si.
void deleteFractionalGraph()
void setRowCliqueReport(bool yesno=true)
possible choices for selecting the next node in the star clique search
Definition: CglClique.hpp:82
void selectRowCliques(const OsiSolverInterface &si, int numOriginalRows)
int * sp_orig_col_ind
possible choices for selecting the next node in the star clique search
Definition: CglClique.hpp:146
void deleteSetPackingSubMatrix()
void setStarCliqueCandidateLengthThreshold(int maxlen)
possible choices for selecting the next node in the star clique search
Definition: CglClique.hpp:74
void find_rcl(OsiCuts &cs)
void find_scl(OsiCuts &cs)
Collections of row cuts and column cuts.
Definition: OsiCuts.hpp:19
int cl_length
The length of cl_indices.
Definition: CglClique.hpp:202
fnode * nodes
The array of the nodes in the graph.
Definition: CglClique.hpp:123
scl_next_node_method scl_next_node_rule
How the next node to be added to the star clique should be selected.
Definition: CglClique.hpp:171
void createSetPackingSubMatrix(const OsiSolverInterface &si)
void setStarCliqueReport(bool yesno=true)
possible choices for selecting the next node in the star clique search
Definition: CglClique.hpp:81
int greedy_maximal_clique(OsiCuts &cs)
virtual CglCutGenerator * clone() const
Clone.
CglFakeClique & operator=(const CglFakeClique &rhs)
Assignment operator.
int cl_del_length
The length of cl_del_indices.
Definition: CglClique.hpp:209
void setDoStarClique(bool yesno=true)
possible choices for selecting the next node in the star clique search
Definition: CglClique.hpp:84
friend void CglCliqueUnitTest(const OsiSolverInterface *siP, const std::string mpdDir)
A function that tests the methods in the CglClique class.
Probing Cut Generator Class.
Definition: CglProbing.hpp:25
bool setPacking_
An indicator showing whether the whole matrix in the solverinterface is a set packing problem or not...
Definition: CglClique.hpp:139
int nodenum
of nodes = # of fractional values in the LP solution
Definition: CglClique.hpp:113
void setMinViolation(double minviol)
possible choices for selecting the next node in the star clique search
Definition: CglClique.hpp:87
int sp_numcols
possible choices for selecting the next node in the star clique search
Definition: CglClique.hpp:145
void selectFractionals(const OsiSolverInterface &si)
Scan through the variables and select those that are at a fractional level.
double val
the fractional value of the variable corresponding to this node
Definition: CglClique.hpp:106
A node of the fractional graph.
Definition: CglClique.hpp:97
void recordClique(const int len, int *indices, OsiCuts &cs)
int * nbrs
pointer into all_nbr
Definition: CglClique.hpp:99
int * sp_row_ind
possible choices for selecting the next node in the star clique search
Definition: CglClique.hpp:151
bool do_star_clique
whether to do the star clique algorithm or not.
Definition: CglClique.hpp:168
void setDoRowClique(bool yesno=true)
possible choices for selecting the next node in the star clique search
Definition: CglClique.hpp:85
Abstract Base Class for describing an interface to a solver.
int sp_numrows
pieces of the set packing part of the solverinterface
Definition: CglClique.hpp:143
Cut Generator Base Class.
void setStarCliqueNextNodeMethod(scl_next_node_method method)
possible choices for selecting the next node in the star clique search
Definition: CglClique.hpp:70
int * cl_indices
List of indices that should be considered for extending the ones listed in cl_perm_indices.
Definition: CglClique.hpp:200
scl_next_node_method
possible choices for selecting the next node in the star clique search
Definition: CglClique.hpp:64
int rcl_candidate_length_threshold
In the row clique method the maximal length of the candidate list (those nodes that can extend the ro...
Definition: CglClique.hpp:184
void createFractionalGraph()
int edgenum
of edges in the graph
Definition: CglClique.hpp:115
int * sp_col_start
possible choices for selecting the next node in the star clique search
Definition: CglClique.hpp:148
frac_graph fgraph
the intersection graph corresponding to the set packing problem
Definition: CglClique.hpp:154
CglProbing * probing_
Probing object.
Definition: CglClique.hpp:305
int enumerate_maximal_cliques(int &pos, bool *scl_label, OsiCuts &cs)
bool rcl_report_result
whether to give a detailed statistics on the row clique method
Definition: CglClique.hpp:186
int * sp_col_ind
possible choices for selecting the next node in the star clique search
Definition: CglClique.hpp:149
double * sp_colsol
possible choices for selecting the next node in the star clique search
Definition: CglClique.hpp:147
void setRowCliqueCandidateLengthThreshold(int maxlen)
possible choices for selecting the next node in the star clique search
Definition: CglClique.hpp:77
double * all_edgecost
The array of the costs of the edges going to the neighbors.
Definition: CglClique.hpp:128
Information about where the cut generator is invoked from.
Definition: CglTreeInfo.hpp:15
int scl_candidate_length_threshold
In the star clique method the maximal length of the candidate list (those nodes that are in a star...
Definition: CglClique.hpp:176
int * sp_row_start
possible choices for selecting the next node in the star clique search
Definition: CglClique.hpp:150
const int * cl_perm_indices
variables/arrays that are used across many methods
Definition: CglClique.hpp:194
CglFakeClique(const CglFakeClique &rhs)
Copy constructor.
int degree
degree of the node
Definition: CglClique.hpp:104
bool do_row_clique
data for the star clique algorithm
Definition: CglClique.hpp:166
bool scl_report_result
whether to give a detailed statistics on the star clique method
Definition: CglClique.hpp:178
void considerRows(const int numRows, const int *rowInd)
possible choices for selecting the next node in the star clique search
virtual void generateCuts(const OsiSolverInterface &si, OsiCuts &cs, const CglTreeInfo info=CglTreeInfo())
Generate cuts for the model data contained in si.
virtual ~CglClique()
Destructor.
Definition: CglClique.hpp:55
void assignSolver(OsiSolverInterface *fakeSolver)
Assign solver (generator takes over ownership)
virtual ~CglFakeClique()
Destructor.
double getMinViolation() const
possible choices for selecting the next node in the star clique search
Definition: CglClique.hpp:88
CglClique(const CglClique &rhs)
Copy constructor.