Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
MaxCPlanarMaster.h
Go to the documentation of this file.
1
37#pragma once
38
41#include <ogdf/basic/Logger.h>
44
45namespace ogdf {
46namespace cluster_planarity {
47
49 friend class MaxCPlanarSub;
50
51 // Pointers to the given Clustergraph and underlying Graph are stored.
53 const Graph* m_G;
55
56
57 // Each time the primal bound is improved, the integer solution induced Graph is built.
58 // \#m_solutionGraph is a pointer to the currently best solution induced Graph.
60
61 List<NodePair> m_allOneEdges; //<! Contains all nodePairs whose variable is set to 1.0
62 List<NodePair> m_originalOneEdges; //<! Contains original nodePairs whose variable is set to 1.0
63 List<NodePair> m_connectionOneEdges; //<! Contains connection nodePairs whose variable is set to 1.0
64 List<edge> m_deletedOriginalEdges; //<! Contains original edges whose variable is set to 0.0
65
66public:
67 // Construction and default values
69 int heuristicRuns = 2, double heuristicOEdgeBound = 0.3, int heuristicNPermLists = 5,
70 int kuratowskiIterations = 3, int subdivisions = 10, int kSupportGraphs = 3,
71 double kuratowskiHigh = 0.7, double kuratowskiLow = 0.3, bool perturbation = false,
72 double branchingGap = 0.4,
73 const char* time = "00:20:00", //maximum computation time
74 bool dopricing = true,
75 bool checkCPlanar = false, //just check c-planarity
76 int numAddVariables = 15, double strongConstraintViolation = 0.3,
77 double strongVariableViolation = 0.3);
78
81
82 // Initialisation of the first Subproblem
83 virtual abacus::Sub* firstSub() override;
84
85 // Returns the objective function coefficient of C-edges
86 double epsilon() const { return m_epsilon; }
87
88 // Returns the number of variables
89 int nMaxVars() const { return m_nMaxVars; }
90
91 // Returns a pointer to the underlying Graph
92 const Graph* getGraph() const { return m_G; }
93
94 // Returns a pointer to the given Clustergraph.
95 const ClusterGraph* getClusterGraph() const { return m_C; }
96
97 // Updates the "best" Subgraph #m_solutionGraph found so far and fills edge lists with
98 // corresponding edges (nodePairs).
100 List<edge>& deleted);
101
102 // Returns the optimal solution induced Clustergraph
103 Graph* solutionInducedGraph() { return static_cast<Graph*>(m_solutionGraph); }
104
105 // Returns nodePairs of original, connection, deleted or all optimal solution edges in list \p edges.
109 void getDeletedEdges(List<edge>& edges) const;
110
111 // Get parameters
113
114 int getNSubdivisions() const { return m_nSubdivisions; }
115
117
118 int getHeuristicLevel() const { return m_heuristicLevel; }
119
120 int getHeuristicRuns() const { return m_nHeuristicRuns; }
121
122 double getKBoundHigh() const { return m_kuratowskiBoundHigh; }
123
124 double getKBoundLow() const { return m_kuratowskiBoundLow; }
125
126 bool perturbation() const { return m_usePerturbation; }
127
128 double branchingOEdgeSelectGap() const { return m_branchingGap; }
129
131
133
134 bool getMPHeuristic() const { return m_mpHeuristic; }
135
136 bool getCheckCPlanar() const { return m_checkCPlanar; }
137
138 int getNumAddVariables() const { return m_numAddVariables; }
139
141
143
144 // Read global constraint counter, i.e. the number of added constraints of specific type.
145 int addedKConstraints() const { return m_nKConsAdded; }
146
147 int addedCConstraints() const { return m_nCConsAdded; }
148
149 // Set parameters
151
153
155
157
158 void setKBoundHigh(double n) { m_kuratowskiBoundHigh = ((n > 0.0 && n < 1.0) ? n : 0.8); }
159
160 void setKBoundLow(double n) { m_kuratowskiBoundLow = ((n > 0.0 && n < 1.0) ? n : 0.2); }
161
162 void heuristicLevel(int level) { m_heuristicLevel = level; }
163
165
166 void setPertubation(bool b) { m_usePerturbation = b; }
167
169
171
173 void setMPHeuristic(bool b) { m_mpHeuristic = b; }
174
176
178
180
182 void setPortaFile(bool b) { m_porta = b; }
183
184 // Updating global constraint counter
185 void updateAddedCCons(int n) { m_nCConsAdded += n; }
186
187 void updateAddedKCons(int n) { m_nKConsAdded += n; }
188
189 // Returns global primal and dual bounds.
191
192 double getDualBound() { return globalDualBound; }
193
194 // Cut pools for connectivity and planarity
199
204
208
209#ifdef OGDF_DEBUG
210 bool m_solByHeuristic; //solution computed by heuristic or ILP
211 // Simple output function to print the given graph to the console.
212 // Used for debugging only.
213 void printGraph(const Graph& G);
214#endif
215
218 const char* getStdConstraintsFileName() { return "StdConstraints.txt"; }
219
221
222protected:
223 // Initializes constraints and variables and an initial dual bound.
224 virtual void initializeOptimization() override;
225
226 // Function that is invoked at the end of the optimization
227 virtual void terminateOptimization() override;
228
230
231private:
232 // Computes a dual bound for the optimal solution.
233 // Tries to find as many edge-disjoint Kuratowski subdivisions as possible.
234 // If k edge-disjoint groups of subdivisions are found, the upper bound can be
235 // initialized with number of edges in underlying graph minus k.
237
238 // Is invoked by heuristicInitialUpperBound()
240
241 // Computes the graphtheoretical distances of edges incident to node \p u.
243
244
245 // Parameters
246 int m_nKuratowskiSupportGraphs; // Maximal number of times the Kuratowski support graph is computed
247 int m_nKuratowskiIterations; // Maximal number of times BoyerMyrvold is invoked
248 int m_nSubdivisions; // Maximal number of extracted Kuratowski subdivisions
249 int m_nMaxVars; // Max Number of variables
250 int m_heuristicLevel; // Indicates if primal heuristic shall be used or not
251 int m_nHeuristicRuns; // Counts how often the primal heuristic has been called
252
253 bool m_usePerturbation; // Indicates whether C-variables should be perturbated or not
254 double m_branchingGap; // Modifies the branching behaviour
256 int m_nHeuristicPermutationLists; // The number of permutation lists used in the primal heuristic
258
259 double m_kuratowskiBoundHigh; // Upper bound for deterministic edge addition in computation of the Supportgraph
260 double m_kuratowskiBoundLow; // Lower bound for deterministic edge deletion in computation of the Supportgraph
261
262 int m_numAddVariables; // how many variables should i add maximally per pricing round?
263 double m_strongConstraintViolation; // when do i consider a constraint strongly violated -> separate in first stage
264 double m_strongVariableViolation; // when do i consider a variable strongly violated (red.cost) -> separate in first stage
265
266 string* m_maxCpuTime; // Time threshold for optimization
267
268
269 // The basic objective function coefficient for connection edges.
270 double m_epsilon;
271 // If pertubation is used, this variable stores the largest occuring coeff,
272 // i.e. the one closest to 0. Otherwise it corresponds to #m_epsilon
274
275 // Counters for the number of added constraints
289
290 inline void clearActiveRepairs() {
291 if (m_activeRepairs) {
293 m_activeRepairs = 0;
294 }
295 }
296
299
300 inline double getDoubleTime(const Stopwatch* act) {
301 int64_t tempo = act->centiSeconds() + 100 * act->seconds() + 6000 * act->minutes()
302 + 360000 * act->hours();
303 return ((double)tempo) / 100.0;
304 }
305
306 //number of calls of the fast max planar subgraph heuristic
308
312
316
321
322 double m_delta;
324
326 // TODO: Test whether this implementation is working.
327 return (m_checkCPlanar ? -1 : -m_epsilon) + m_deltaCount-- * m_delta;
328 }
329
331 ++m_varsAdded;
332 EdgeVar* v = new EdgeVar(this, nextConnectCoeff(), EdgeVar::EdgeType::Connect, (*it).source,
333 (*it).target);
335 m_inactiveVariables.del(it);
336 return v;
337 }
338
342
343 bool goodVar(node a, node b);
344
351};
352
353}
354}
Declaration and implementation of ArrayBuffer class.
Declaration of the variable class for the Branch&Cut algorithm for the Maximum C-Planar SubGraph prob...
Declaration of graph copy classes.
Contains logging functionality.
Declaration of the master class for the Branch&Cut algorithm for the Maximum C-Planar SubGraph proble...
Forms the virtual base class for all possible constraints given in pool format.
Definition constraint.h:56
The master of the optimization.
Definition master.h:69
double upperBound() const
Returns the value of the global upper bound.
Definition master.h:1530
Standard pools.
The subproblem.
Definition sub.h:68
An array that keeps track of the number of inserted elements; also usable as an efficient stack.
Definition ArrayBuffer.h:56
void push(E e)
Puts a new element in the buffer.
Representation of clusters in a clustered graph.
Representation of clustered graphs.
Dynamic arrays indexed with edges.
Definition EdgeArray.h:125
Copies of graphs supporting edge splitting.
Definition GraphCopy.h:254
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:521
Doubly linked lists (maintaining the length of the list).
Definition List.h:1435
Encapsulates a pointer to a list element.
Definition List.h:103
static std::ostream & slout(Level level=Level::Default)
stream for logging-output (global)
Definition Logger.h:167
Dynamic arrays indexed with nodes.
Definition NodeArray.h:125
Class for the representation of nodes.
Definition Graph_d.h:177
Realizes a stopwatch for measuring elapsed time.
Definition Stopwatch.h:42
int64_t hours() const
Returns the currently elapsed time in hours.
Definition Stopwatch.h:123
int64_t centiSeconds() const
Returns the currently elapsed time in 1/100-seconds.
Definition Stopwatch.h:102
int64_t seconds() const
Returns the currently elapsed time in seconds.
Definition Stopwatch.h:109
int64_t minutes() const
Returns the currently elapsed time in minutes.
Definition Stopwatch.h:116
virtual void printMe(std::ostream &out)
Definition EdgeVar.h:69
void setPortaFile(bool b)
If set to true, PORTA output is written in a file.
void getCoefficients(abacus::Constraint *con, const List< EdgeVar * > &orig, const List< EdgeVar * > &connect, List< double > &coeffs)
writes coefficients of all orig and connect variables in constraint con into emptied list coeffs
abacus::StandardPool< abacus::Constraint, abacus::Variable > * getCutConnPool()
Returns cut pool for connectivity.
void generateVariablesForFeasibility(const List< ChunkConnection * > &ccons, List< EdgeVar * > &connectVars)
void updateBestSubGraph(List< NodePair > &original, List< NodePair > &connection, List< edge > &deleted)
abacus::StandardPool< abacus::Constraint, abacus::Variable > * getCutKuraPool()
Returns cut pool for planarity.
bool m_mpHeuristic
Indicates if simple max planar subgraph heuristic should be used to derive lower bound if only root c...
virtual abacus::Sub * firstSub() override
Should return a pointer to the first subproblem of the optimization, i.e., the root node of the enume...
bool m_useDefaultCutPool
Defines if the ABACUS default cut pool or the separate Connectivity and Kuratowski constraint pools a...
abacus::StandardPool< abacus::Constraint, abacus::Variable > * m_cutConnPool
Cut pools for connectivity and Kuratowski constraints.
MaxCPlanarMaster(const ClusterGraph &C, const EdgeArray< double > *pCost, int heuristicLevel=1, int heuristicRuns=2, double heuristicOEdgeBound=0.3, int heuristicNPermLists=5, int kuratowskiIterations=3, int subdivisions=10, int kSupportGraphs=3, double kuratowskiHigh=0.7, double kuratowskiLow=0.3, bool perturbation=false, double branchingGap=0.4, const char *time="00:20:00", bool dopricing=true, bool checkCPlanar=false, int numAddVariables=15, double strongConstraintViolation=0.3, double strongVariableViolation=0.3)
void getDeletedEdges(List< edge > &edges) const
const char * getStdConstraintsFileName()
The name of the file that contains the standard, i.e., non-cut, constraints (may be deleted by ABACUS...
EdgeVar * createVariable(ListIterator< NodePair > &it)
void getConnectionOptimalSolutionEdges(List< NodePair > &egdes) const
bool m_porta
If set to true, PORTA output is written in a file.
virtual void terminateOptimization() override
The default implementation of terminateOptimization() does nothing.
void getOriginalOptimalSolutionEdges(List< NodePair > &edges) const
void getAllOptimalSolutionEdges(List< NodePair > &edges) const
abacus::StandardPool< abacus::Constraint, abacus::Variable > * m_cutKuraPool
Kuratowski Cuts.
bool m_checkCPlanar
Defines if only clustered planarity is checked, i.e., all edges of the original graph need to be fixe...
double getDoubleTime(const Stopwatch *act)
virtual void initializeOptimization() override
The default implementation of initializeOptimization() does nothing.
void setMPHeuristic(bool b)
Switches use of lower bound heuristic.
bool & useDefaultCutPool()
Returns true if default cut pool is used. Otherwise, separate connectivity and Kuratowski pools are g...
void clusterConnection(cluster c, GraphCopy &GC, double &upperBound)
const ClusterGraph * getClusterGraph() const
void nodeDistances(node u, NodeArray< NodeArray< int > > &dist)
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.