Debian Codegraph @

Cgl/src/CglClique/CglClique.hpp

raw symbols SCIP
1 // $Id$cxx . . $ `<file>/Cgl/src/CglClique/CglClique.hpp`/
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_cxx . . $ `Cgl/src/CglClique/CglClique.hpp:7:9`!
8
9 #include "CglCutGenerator.hpp"cxx . . $ `<file>/Cgl/src/CglCutGenerator.hpp`/
10
11 //class OsiCuts;
12 //class OsiSolverInterface;
13
14 class CglCliquecxx . . $ CglClique# : public CglCutGeneratorcxx . . $ CglCutGenerator# {
15
16 friend void CglCliqueUnitTestcxx . . $ CglCliqueUnitTest(d8c7ffe7dd7e392).(const OsiSolverInterfacecxx . . $ OsiSolverInterface# * siP,
17 const stdcxx . . $ std/::stringcxx . . $ std/string# mpdDir );
18 public:
19 /// Copy constructor
20 CglCliquecxx . . $ CglClique#CglClique(ad4924728babd88f).(const CglCliquecxx . . $ CglClique#& rhs);
21 /// Clone
22 virtual CglCutGeneratorcxx . . $ CglCutGenerator# * clonecxx . . $ CglClique#clone(ff686f57cc59f31d).() const;
23
24 /// Assignment operator
25 CglCliquecxx . . $ CglClique#& operatorcxx . . $ CglClique#`operator=`(7316e47392e8c2cb).=(const CglCliquecxx . . $ CglClique#& rhs);
26
27 public:
28
29 virtual void
30 generateCutscxx . . $ CglClique#generateCuts(a7cd996c3d1130d3).(const OsiSolverInterfacecxx . . $ OsiSolverInterface#& si, OsiCutscxx . . $ OsiCuts# & cs,
31 const CglTreeInfocxx . . $ CglTreeInfo# info = CglTreeInfocxx . . $ CglTreeInfo#CglTreeInfo(49f6e7a06ebc5aa8).());
32
33 /**@name Constructors and destructors */
34 //@{
35 /** Default constructor.
36 If the setPacking argument is set to true then CglClique will assume that the
37 problem in the solverinterface passed to the generateCuts() method
38 describes a set packing problem, i.e.,
39 - all variables are binary
40 - the matrix is a 0-1 matrix
41 - all constraints are '= 1' or '<= 1'
42
43 Otherwise the user can use the considerRows() method to set the list of
44 clique rows, that is,
45 - all coeffs corresponding to binary variables at fractional level is 1
46 - all other coeffs are non-negative
47 - the constraint is '= 1' or '<= 1'.
48
49 If the user does not set the list of clique rows then CglClique will
50 start the generateCuts() methods by scanning the matrix for them.
51 Also justOriginalRows can be set to true to limit clique creation
52 */
53 CglCliquecxx . . $ CglClique#CglClique(b0b38cda41d4ede4).(bool setPacking = false, bool justOriginalRows = false);
54 /// Destructor
55 virtual ~cxx . . $ CglClique#`~CglClique`(ced63f7c635d850d).CglCliquecxx . . $ CglClique#() {}
56 /// Create C++ lines to get to current state
57 virtual stdcxx . . $ std/::stringcxx . . $ std/string# generateCppcxx . . $ CglClique#generateCpp(d8c45821d4afeee5).( FILEcxx . . $ FILE# * fp);
58
59 void considerRowscxx . . $ CglClique#considerRows(f4da74bb73d50818).(const int numRows, const int* rowInd);
60
61 public:
62 /** possible choices for selecting the next node in the star clique search
63 */
64 enum scl_next_node_methodcxx . . $ CglClique#scl_next_node_method# {
65 SCL_MIN_DEGREEcxx . . $ CglClique#SCL_MIN_DEGREE.,
66 SCL_MAX_DEGREEcxx . . $ CglClique#SCL_MAX_DEGREE.,
67 SCL_MAX_XJ_MAX_DEGcxx . . $ CglClique#SCL_MAX_XJ_MAX_DEG.
68 };
69
70 void setStarCliqueNextNodeMethodcxx . . $ CglClique#setStarCliqueNextNodeMethod(cb1d4f7e578f7cf9).(scl_next_node_methodcxx . . $ CglClique#scl_next_node_method# method) {
71 scl_next_node_rulecxx . . $ CglClique#scl_next_node_rule. = method;
72 }
73
74 void setStarCliqueCandidateLengthThresholdcxx . . $ CglClique#setStarCliqueCandidateLengthThreshold(d4f767463ce0a6b3).(int maxlen) {
75 scl_candidate_length_thresholdcxx . . $ CglClique#scl_candidate_length_threshold. = maxlen;
76 }
77 void setRowCliqueCandidateLengthThresholdcxx . . $ CglClique#setRowCliqueCandidateLengthThreshold(d4f767463ce0a6b3).(int maxlen) {
78 rcl_candidate_length_thresholdcxx . . $ CglClique#rcl_candidate_length_threshold. = maxlen;
79 }
80
81 void setStarCliqueReportcxx . . $ CglClique#setStarCliqueReport(b45ddcbc8423892c).(bool yesno = true) { scl_report_resultcxx . . $ CglClique#scl_report_result. = yesno; }
82 void setRowCliqueReportcxx . . $ CglClique#setRowCliqueReport(b45ddcbc8423892c).(bool yesno = true) { rcl_report_resultcxx . . $ CglClique#rcl_report_result. = yesno; }
83
84 void setDoStarCliquecxx . . $ CglClique#setDoStarClique(b45ddcbc8423892c).(bool yesno = true) { do_star_cliquecxx . . $ CglClique#do_star_clique. = yesno; }
85 void setDoRowCliquecxx . . $ CglClique#setDoRowClique(b45ddcbc8423892c).(bool yesno = true) { do_row_cliquecxx . . $ CglClique#do_row_clique. = yesno; }
86
87 void setMinViolationcxx . . $ CglClique#setMinViolation(ba8836b59fb42830).(double minviol) { petolcxx . . $ CglClique#petol. = minviol; }
88 double getMinViolationcxx . . $ CglClique#getMinViolation(21b6c25e127938e2).() const { return petolcxx . . $ CglClique#petol.; }
89 /// Maximum number of binaries for looking at all
90 inline void setMaxNumbercxx . . $ CglClique#setMaxNumber(d4f767463ce0a6b3).(int value) { maxNumber_cxx . . $ CglClique#maxNumber_. = value; }
91
92 private:
93
94 struct frac_graphcxx . . $ CglClique#frac_graph# ;
95 friend struct frac_graphcxx . . $ CglClique#frac_graph# ;
96
97 /** A node of the fractional graph. There is a node for every variable at
98 fractional level. */
99 struct fnodecxx . . $ CglClique#fnode# {
100 /** pointer into all_nbr */
101 int *nbrscxx . . $ CglClique#fnode#nbrs.;
102 /** 1-x_i-x_j, needed for odd holes, in the same order as the adj list,
103 pointer into all_edgecost */
104 double *edgecostscxx . . $ CglClique#fnode#edgecosts.;
105 /** degree of the node */
106 int degreecxx . . $ CglClique#fnode#degree.;
107 /** the fractional value of the variable corresponding to this node */
108 double valcxx . . $ CglClique#fnode#val.;
109 };
110
111 /** A graph corresponding to a fractional solution of an LP. Two nodes are
112 adjacent iff their columns are non-orthogonal. */
113 struct frac_graphcxx . . $ CglClique#frac_graph# {
114 /** # of nodes = # of fractional values in the LP solution */
115 int nodenumcxx . . $ CglClique#frac_graph#nodenum.;
116 /** # of edges in the graph */
117 int edgenumcxx . . $ CglClique#frac_graph#edgenum.;
118 /** density= edgenum/(nodenum choose 2) */
119 double densitycxx . . $ CglClique#frac_graph#density.;
120 int min_deg_nodecxx . . $ CglClique#frac_graph#min_deg_node.;
121 int min_degreecxx . . $ CglClique#frac_graph#min_degree.;
122 int max_deg_nodecxx . . $ CglClique#frac_graph#max_deg_node.;
123 int max_degreecxx . . $ CglClique#frac_graph#max_degree.;
124 /** The array of the nodes in the graph */
125 fnodecxx . . $ CglClique#fnode# *nodescxx . . $ CglClique#frac_graph#nodes.;
126 /** The array of all the neighbors. First the indices of the nodes
127 adjacent to node 0 are listed, then those adjacent to node 1, etc. */
128 int *all_nbrcxx . . $ CglClique#frac_graph#all_nbr.;
129 /** The array of the costs of the edges going to the neighbors */
130 double *all_edgecostcxx . . $ CglClique#frac_graph#all_edgecost.;
131
132 frac_graphcxx . . $ CglClique#frac_graph#frac_graph(49f6e7a06ebc5aa8).() :
133 nodenumcxx . . $ CglClique#frac_graph#nodenum.(0), edgenumcxx . . $ CglClique#frac_graph#edgenum.(0), densitycxx . . $ CglClique#frac_graph#density.(0),
134 min_deg_nodecxx . . $ CglClique#frac_graph#min_deg_node.(0), min_degreecxx . . $ CglClique#frac_graph#min_degree.(0), max_deg_nodecxx . . $ CglClique#frac_graph#max_deg_node.(0), max_degreecxx . . $ CglClique#frac_graph#max_degree.(0),
135 nodescxx . . $ CglClique#frac_graph#nodes.(0), all_nbrcxx . . $ CglClique#frac_graph#all_nbr.(0), all_edgecostcxx . . $ CglClique#frac_graph#all_edgecost.(0) {}
136 };
137
138 protected:
139 /** An indicator showing whether the whole matrix in the solverinterface is
140 a set packing problem or not */
141 bool setPacking_cxx . . $ CglClique#setPacking_.;
142 /// True if just look at original rows
143 bool justOriginalRows_cxx . . $ CglClique#justOriginalRows_.;
144 /** pieces of the set packing part of the solverinterface */
145 int sp_numrowscxx . . $ CglClique#sp_numrows.;
146 int* sp_orig_row_indcxx . . $ CglClique#sp_orig_row_ind.;
147 int sp_numcolscxx . . $ CglClique#sp_numcols.;
148 int* sp_orig_col_indcxx . . $ CglClique#sp_orig_col_ind.;
149 double* sp_colsolcxx . . $ CglClique#sp_colsol.;
150 int* sp_col_startcxx . . $ CglClique#sp_col_start.;
151 int* sp_col_indcxx . . $ CglClique#sp_col_ind.;
152 int* sp_row_startcxx . . $ CglClique#sp_row_start.;
153 int* sp_row_indcxx . . $ CglClique#sp_row_ind.;
154
155 /** the intersection graph corresponding to the set packing problem */
156 frac_graphcxx . . $ CglClique#frac_graph# fgraphcxx . . $ CglClique#fgraph.;
157 /** the node-node incidence matrix of the intersection graph. */
158 bool* node_nodecxx . . $ CglClique#node_node.;
159
160 /** The primal tolerance in the solverinterface. */
161 double petolcxx . . $ CglClique#petol.;
162 /// Maximum number of binaries for looking at all
163 int maxNumber_cxx . . $ CglClique#maxNumber_.;
164
165 /** data for the star clique algorithm */
166
167 /** Parameters */
168 /**@{*/
169 /** whether to do the row clique algorithm or not. */
170 bool do_row_cliquecxx . . $ CglClique#do_row_clique.;
171 /** whether to do the star clique algorithm or not. */
172 bool do_star_cliquecxx . . $ CglClique#do_star_clique.;
173
174 /** How the next node to be added to the star clique should be selected */
175 scl_next_node_methodcxx . . $ CglClique#scl_next_node_method# scl_next_node_rulecxx . . $ CglClique#scl_next_node_rule.;
176 /** In the star clique method the maximal length of the candidate list
177 (those nodes that are in a star, i.e., connected to the center of the
178 star) to allow complete enumeration of maximal cliques. Otherwise a
179 greedy algorithm is used. */
180 int scl_candidate_length_thresholdcxx . . $ CglClique#scl_candidate_length_threshold.;
181 /** whether to give a detailed statistics on the star clique method */
182 bool scl_report_resultcxx . . $ CglClique#scl_report_result.;
183
184 /** In the row clique method the maximal length of the candidate list
185 (those nodes that can extend the row clique, i.e., connected to all
186 nodes in the row clique) to allow complete enumeration of maximal
187 cliques. Otherwise a greedy algorithm is used. */
188 int rcl_candidate_length_thresholdcxx . . $ CglClique#rcl_candidate_length_threshold.;
189 /** whether to give a detailed statistics on the row clique method */
190 bool rcl_report_resultcxx . . $ CglClique#rcl_report_result.;
191 /**@}*/
192
193 /** variables/arrays that are used across many methods */
194 /**@{*/
195 /** List of indices that must be in the to be created clique. This is just
196 a pointer, it is never new'd and therefore does not need to be
197 delete[]'d either. */
198 const int* cl_perm_indicescxx . . $ CglClique#cl_perm_indices.;
199 /** The length of cl_perm_indices */
200 int cl_perm_lengthcxx . . $ CglClique#cl_perm_length.;
201
202 /** List of indices that should be considered for extending the ones listed
203 in cl_perm_indices. */
204 int* cl_indicescxx . . $ CglClique#cl_indices.;
205 /** The length of cl_indices */
206 int cl_lengthcxx . . $ CglClique#cl_length.;
207
208 /** An array of nodes discarded from the candidate list. These are
209 rechecked when a maximal clique is found just to make sure that the
210 clique is really maximal. */
211 int* cl_del_indicescxx . . $ CglClique#cl_del_indices.;
212 /** The length of cl_del_indices */
213 int cl_del_lengthcxx . . $ CglClique#cl_del_length.;
214
215 /**@}*/
216
217 private:
218 /** Scan through the variables and select those that are binary and are at
219 a fractional level. */
220 void selectFractionalBinariescxx . . $ CglClique#selectFractionalBinaries(33d731a8b759e8a8).(const OsiSolverInterfacecxx . . $ OsiSolverInterface#& si);
221 /** Scan through the variables and select those that are at a fractional
222 level. We already know that everything is binary. */
223 void selectFractionalscxx . . $ CglClique#selectFractionals(33d731a8b759e8a8).(const OsiSolverInterfacecxx . . $ OsiSolverInterface#& si);
224 /** */
225 void selectRowCliquescxx . . $ CglClique#selectRowCliques(790740e3776b4dcf).(const OsiSolverInterfacecxx . . $ OsiSolverInterface#& si,int numOriginalRows);
226 /** */
227 void createSetPackingSubMatrixcxx . . $ CglClique#createSetPackingSubMatrix(33d731a8b759e8a8).(const OsiSolverInterfacecxx . . $ OsiSolverInterface#& si);
228 /** */
229 void createFractionalGraphcxx . . $ CglClique#createFractionalGraph(49f6e7a06ebc5aa8).();
230 /** */
231 int createNodeNodecxx . . $ CglClique#createNodeNode(b126dc7c1de90089).();
232 /** */
233 void deleteSetPackingSubMatrixcxx . . $ CglClique#deleteSetPackingSubMatrix(49f6e7a06ebc5aa8).();
234 /** */
235 void deleteFractionalGraphcxx . . $ CglClique#deleteFractionalGraph(49f6e7a06ebc5aa8).();
236 /** */
237 void find_sclcxx . . $ CglClique#find_scl(b09e1f7d44b991dc).(OsiCutscxx . . $ OsiCuts#& cs);
238 /** */
239 void find_rclcxx . . $ CglClique#find_rcl(b09e1f7d44b991dc).(OsiCutscxx . . $ OsiCuts#& cs);
240 /** */
241 int scl_choose_next_nodecxx . . $ CglClique#scl_choose_next_node(93ad394ee8ed04a2).(const int current_nodenum,
242 const int *current_indices,
243 const int *current_degrees,
244 const double *current_values);
245 /** */
246 void scl_delete_nodecxx . . $ CglClique#scl_delete_node(eab7615aeb6725ee).(const int del_ind, int& current_nodenum,
247 int *current_indices, int *current_degrees,
248 double *current_values);
249 /** */
250 int enumerate_maximal_cliquescxx . . $ CglClique#enumerate_maximal_cliques(f807dd92366c25cd).(int& pos, bool* scl_label, OsiCutscxx . . $ OsiCuts#& cs);
251 /** */
252 int greedy_maximal_cliquecxx . . $ CglClique#greedy_maximal_clique(e4c311137c372c4a).(OsiCutscxx . . $ OsiCuts#& cs);
253 /** */
254 void recordCliquecxx . . $ CglClique#recordClique(30499c45229835f2).(const int len, int* indices, OsiCutscxx . . $ OsiCuts#& cs);
255 };
256 //#############################################################################
257 /** A function that tests the methods in the CglClique class. The
258 only reason for it not to be a member method is that this way it doesn't
259 have to be compiled into the library. And that's a gain, because the
260 library should be compiled with optimization on, but this method should be
261 compiled with debugging. */
262 void CglCliqueUnitTestcxx . . $ CglCliqueUnitTest(d8c7ffe7dd7e392).(const OsiSolverInterfacecxx . . $ OsiSolverInterface# * siP,
263 const stdcxx . . $ std/::stringcxx . . $ std/string# mpdDir);
264 /// This works on a fake solver i.e. invented rows
265 class CglProbingcxx . . $ CglProbing#;
266 class CglFakeCliquecxx . . $ CglFakeClique# : public CglCliquecxx . . $ CglClique# {
267
268 public:
269 /// Copy constructor
270 CglFakeCliquecxx . . $ CglFakeClique#CglFakeClique(fc46a9b9774977a6).(const CglFakeCliquecxx . . $ CglFakeClique#& rhs);
271 /// Clone
272 virtual CglCutGeneratorcxx . . $ CglCutGenerator# * clonecxx . . $ CglFakeClique#clone(ff686f57cc59f31d).() const;
273
274 /// Assignment operator
275 CglFakeCliquecxx . . $ CglFakeClique#& operatorcxx . . $ CglFakeClique#`operator=`(c47caef3c1029a71).=(const CglFakeCliquecxx . . $ CglFakeClique#& rhs);
276
277 virtual void
278 generateCutscxx . . $ CglFakeClique#generateCuts(a7cd996c3d1130d3).(const OsiSolverInterfacecxx . . $ OsiSolverInterface#& si, OsiCutscxx . . $ OsiCuts# & cs,
279 const CglTreeInfocxx . . $ CglTreeInfo# info = CglTreeInfocxx . . $ CglTreeInfo#CglTreeInfo(49f6e7a06ebc5aa8).());
280
281 /**@name Constructors and destructors */
282 //@{
283 /** Default constructor.
284 If the setPacking argument is set to true then CglFakeClique will assume that the
285 problem in the solverinterface passed to the generateCuts() method
286 describes a set packing problem, i.e.,
287 - all variables are binary
288 - the matrix is a 0-1 matrix
289 - all constraints are '= 1' or '<= 1'
290
291 Otherwise the user can use the considerRows() method to set the list of
292 clique rows, that is,
293 - all coeffs corresponding to binary variables at fractional level is 1
294 - all other coeffs are non-negative
295 - the constraint is '= 1' or '<= 1'.
296
297 If the user does not set the list of clique rows then CglFakeClique will
298 start the generateCuts() methods by scanning the matrix for them.
299 */
300 CglFakeCliquecxx . . $ CglFakeClique#CglFakeClique(38eea468112823b4).(OsiSolverInterfacecxx . . $ OsiSolverInterface# * solver=NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!,bool setPacking = false);
301 /// Destructor
302 virtual ~cxx . . $ CglFakeClique#`~CglFakeClique`(ced63f7c635d850d).CglFakeCliquecxx . . $ CglFakeClique#();
303 /// Assign solver (generator takes over ownership)
304 void assignSolvercxx . . $ CglFakeClique#assignSolver(148ed51524aa7e8b).(OsiSolverInterfacecxx . . $ OsiSolverInterface# * fakeSolver);
305 protected:
306 /// fake solver to use
307 OsiSolverInterfacecxx . . $ OsiSolverInterface# * fakeSolver_cxx . . $ CglFakeClique#fakeSolver_.;
308 /// Probing object
309 CglProbingcxx . . $ CglProbing# * probing_cxx . . $ CglFakeClique#probing_.;
310 };
311
312 #endif