Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

ILPClusterPlanarity.h
Go to the documentation of this file.
1 
33 #pragma once
34 
35 #include <ogdf/basic/Graph.h>
36 #include <ogdf/basic/List.h>
37 #include <ogdf/basic/Stopwatch.h>
38 #include <ogdf/basic/basic.h>
43 
44 #include <ogdf/external/abacus.h>
45 
46 #include <cstdint>
47 #include <iosfwd>
48 #include <string>
49 
50 namespace abacus {
51 template<class BaseType, class CoType>
53 } // namespace abacus
54 
55 namespace ogdf {
56 
58 
62 public:
65 
69  enum class solmeth { Fallback, New };
70 
73  : m_heuristicLevel(1)
74  , m_heuristicRuns(1)
75  , m_heuristicOEdgeBound(0.4)
76  , m_heuristicNPermLists(5)
77  , m_kuratowskiIterations(10)
78  , m_subdivisions(10)
79  , m_kSupportGraphs(10)
80  , m_kuratowskiHigh(0.8)
81  , m_kuratowskiLow(0.8)
82  , m_perturbation(false)
83  , m_branchingGap(0.4)
84  , m_time("00:20:00")
85  , m_pricing(false)
86  , m_numAddVariables(15)
87  , m_strongConstraintViolation(0.3)
88  , m_strongVariableViolation(0.3)
89  , m_solmeth(solmeth::New)
90  , m_optStatus(abacus::Master::STATUS::Unprocessed)
91  , m_totalTime(-1.0)
92  , m_heurTime(-1.0)
93  , m_lpTime(-1.0)
94  , m_lpSolverTime(-1.0)
95  , m_sepTime(-1.0)
96  , m_totalWTime(-1.0)
97  , m_numCCons(-1)
98  , m_numKCons(-1)
99  , m_numLPs(-1)
100  , m_numBCs(-1)
101  , m_numSubSelected(-1)
102  , m_numVars(-1)
103  , m_portaOutput(false)
104  , m_defaultCutPool(true)
105 #ifdef OGDF_DEBUG
106  , m_solByHeuristic(false)
107 #endif
108  {
109  }
110 
111  //destruction
113 
116  bool isClusterPlanar(const ClusterGraph& CG, NodePairs& addedEdges);
117 
119  bool isClusterPlanar(const ClusterGraph& CG) override;
120 
122  return isClusterPlanar(CG);
123  }
124 
125  bool clusterPlanarEmbedClusterPlanarGraph(ClusterGraph& CG, Graph& G) override;
126 
127  //setter methods for the module parameters
128  void setHeuristicLevel(int i) { m_heuristicLevel = i; }
129 
130  void setHeuristicRuns(int i) { m_heuristicRuns = i; }
131 
132  void setHeuristicBound(double d) { m_heuristicOEdgeBound = d; }
133 
134  void setNumberOfPermutations(int i) { m_heuristicNPermLists = i; }
135 
136  void setNumberOfKuraIterations(int i) { m_kuratowskiIterations = i; }
137 
138  void setNumberOfSubDivisions(int i) { m_subdivisions = i; }
139 
140  void setNumberOfSupportGraphs(int i) { m_kSupportGraphs = i; }
141 
142  void setUpperRounding(double d) { m_kuratowskiHigh = d; }
143 
144  void setLowerRounding(double d) { m_kuratowskiLow = d; }
145 
146  void setPerturbation(bool b) { m_perturbation = b; }
147 
148  void setBranchingGap(double d) { m_branchingGap = d; }
149 
150  void setTimeLimit(string s) { m_time = s.c_str(); }
151 
152  void setPortaOutput(bool b) { m_portaOutput = b; }
153 
154  void setPricing(bool b) { m_pricing = b; }
155 
156  void setNumAddVariables(int n) { m_numAddVariables = n; }
157 
158  void setStrongConstraintViolation(double d) { m_strongConstraintViolation = d; }
159 
160  void setStrongVariableViolation(double d) { m_strongVariableViolation = d; }
161 
164  bool& useDefaultCutPool() { return m_defaultCutPool; }
165 
166  //getter methods for results
167  abacus::Master::STATUS getOptStatus() { return m_optStatus; }
168 
169  double getTotalTime() { return m_totalTime; }
170 
171  double getHeurTime() { return m_heurTime; }
172 
173  double getLPTime() { return m_lpTime; }
174 
175  double getLPSolverTime() { return m_lpSolverTime; }
176 
177  double getSeparationTime() { return m_sepTime; }
178 
179  double getTotalWTime() { return m_totalWTime; }
180 
182  int getNumCCons() { return m_numCCons; }
183 
185  int getNumKCons() { return m_numKCons; }
186 
188  int getNumLPs() { return m_numLPs; }
189 
191  int getNumBCs() { return m_numBCs; }
192 
194  int getNumSubSelected() { return m_numSubSelected; }
195 
197  int getNumVars() { return m_numVars; }
198 
200  void writeFeasible(const char* filename, CP_MasterBase& master, abacus::Master::STATUS& status);
201 #ifdef OGDF_DEBUG
202  bool getSolByHeuristic() { return m_solByHeuristic; }
203 #endif
204 
205  solmeth& solutionMethod() { return m_solmeth; }
206 
207 protected:
208  // Performs a c-planarity test on CG.
209  bool doTest(const ClusterGraph& CG);
210 
211  //as above, on success also returns the set of edges that were
212  //added to construct a completely connected planar graph.
213  bool doTest(const ClusterGraph& G, NodePairs& addedEdges);
214 
215  // Performs a c-planarity test using only a reduced set
216  // of allowed extension edges, returns c-planarity status
217 #if 0
218  virtual bool doFastTest(const ClusterGraph &G);
219 #endif
220 
221  double getDoubleTime(const Stopwatch& act) {
222  int64_t tempo = act.centiSeconds() + 100 * act.seconds() + 6000 * act.minutes()
223  + 360000 * act.hours();
224  return ((double)tempo) / 100.0;
225  }
226 
228  void getBottomUpClusterList(const cluster c, List<cluster>& theList);
229 
230 private:
231  //Abacus Master class settings in order of appearance
232  int m_heuristicLevel, m_heuristicRuns;
234  int m_heuristicNPermLists, m_kuratowskiIterations;
235  int m_subdivisions, m_kSupportGraphs;
236  double m_kuratowskiHigh, m_kuratowskiLow;
239  string m_time;
240  bool m_pricing; //<! Decides if pricing is used
244 
246 
247  const char* getPortaFileName() { return "porta.poi"; }
248 
249  const char* getIeqFileName() { return "porta.ieq"; }
250 
251  int maxConLength() { return 1024; }
252 
253  void outputCons(std::ofstream& os,
256 
257  //results
258  abacus::Master::STATUS m_optStatus; //<! Status of optimization, returned from abacus
259  double m_totalTime; //<! Total computation time, returned from abacus
260  double m_heurTime; //<! Time spent in heuristic, returned from abacus
261  double m_lpTime; //<! Cpu time spent in members of the LP-interface, returned from abacus
262  double m_lpSolverTime; //<! Cpu time required by the LP solver, returned from abacus
263  double m_sepTime; //<! Cpu time spent in the separation of cutting planes, returned from abacus
264  double m_totalWTime; //<! Total wall clock time, returned from abacus
265  int m_numCCons; //<! Number of added connectivity constraints
266  int m_numKCons; //<! Number of added kuratowski constraints
267  int m_numLPs; //<! The number of optimized linear programs (LP-relax.).
268  int m_numBCs; //<! The number of generated subproblems.
269  int m_numSubSelected; //<! The number of subproblems selected by ABACUS.
270  int m_numVars; //<! The number of global variables.
271  bool m_portaOutput; //<! If set to true, output for PORTA in ieq format is generated.
272  bool m_defaultCutPool; //<! Passed through to master
273 #ifdef OGDF_DEBUG
275 #endif
276 };
277 
278 }
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
ogdf::ILPClusterPlanarity::getDoubleTime
double getDoubleTime(const Stopwatch &act)
Definition: ILPClusterPlanarity.h:221
Graph.h
Includes declaration of graph class.
ogdf::ILPClusterPlanarity::setPerturbation
void setPerturbation(bool b)
Definition: ILPClusterPlanarity.h:146
ogdf::ILPClusterPlanarity::m_kuratowskiIterations
int m_kuratowskiIterations
Definition: ILPClusterPlanarity.h:234
ogdf::ILPClusterPlanarity::getNumKCons
int getNumKCons()
Returns number of Kuratowski constraints added during computation.
Definition: ILPClusterPlanarity.h:185
ogdf::ILPClusterPlanarity::m_branchingGap
double m_branchingGap
Definition: ILPClusterPlanarity.h:238
abacus.h
Includes Abacus.
ogdf::ILPClusterPlanarity::m_defaultCutPool
bool m_defaultCutPool
Definition: ILPClusterPlanarity.h:272
ClusterPlanarityModule.h
Declaration of ClusterPlanarityModule which implements a cluster-planarity test and,...
ogdf::ILPClusterPlanarity::m_lpSolverTime
double m_lpSolverTime
Definition: ILPClusterPlanarity.h:262
abacus::Master::STATUS
STATUS
The various statuses of the optimization process.
Definition: master.h:77
ogdf::ILPClusterPlanarity::m_optStatus
abacus::Master::STATUS m_optStatus
Definition: ILPClusterPlanarity.h:258
ogdf::ILPClusterPlanarity::getSeparationTime
double getSeparationTime()
Definition: ILPClusterPlanarity.h:177
ogdf::ILPClusterPlanarity::getNumCCons
int getNumCCons()
Returns number of connectivity constraints added during computation.
Definition: ILPClusterPlanarity.h:182
ogdf::ILPClusterPlanarity::maxConLength
int maxConLength()
Definition: ILPClusterPlanarity.h:251
ogdf::ILPClusterPlanarity::setTimeLimit
void setTimeLimit(string s)
Definition: ILPClusterPlanarity.h:150
ogdf::ILPClusterPlanarity::getHeurTime
double getHeurTime()
Definition: ILPClusterPlanarity.h:171
ogdf::ILPClusterPlanarity::m_heuristicOEdgeBound
double m_heuristicOEdgeBound
Definition: ILPClusterPlanarity.h:233
ogdf::ILPClusterPlanarity::getIeqFileName
const char * getIeqFileName()
Definition: ILPClusterPlanarity.h:249
CPlanarityMaster.h
Declaration of the CPlanarityMaster class for the Branch&Cut algorithm for c-planarity testing via an...
abacus
Definition: ILPClusterPlanarity.h:50
ogdf::ILPClusterPlanarity::setNumAddVariables
void setNumAddVariables(int n)
Definition: ILPClusterPlanarity.h:156
ogdf::ILPClusterPlanarity::useDefaultCutPool
bool & useDefaultCutPool()
Use default abacus master cut pool or dedicated connectivity and kuratowski cut pools.
Definition: ILPClusterPlanarity.h:164
ogdf::ILPClusterPlanarity::solmeth
solmeth
Solution method, fallback to old version (allowing all extension edges, based on c-planar subgraph co...
Definition: ILPClusterPlanarity.h:69
ogdf::ILPClusterPlanarity::m_time
string m_time
Definition: ILPClusterPlanarity.h:239
ogdf::ILPClusterPlanarity::m_numKCons
int m_numKCons
Definition: ILPClusterPlanarity.h:266
ogdf::ILPClusterPlanarity::getLPSolverTime
double getLPSolverTime()
Definition: ILPClusterPlanarity.h:175
ogdf::ILPClusterPlanarity::m_perturbation
bool m_perturbation
Definition: ILPClusterPlanarity.h:237
ogdf::ILPClusterPlanarity::setUpperRounding
void setUpperRounding(double d)
Definition: ILPClusterPlanarity.h:142
ogdf::Stopwatch::hours
int64_t hours() const
Returns the currently elapsed time in hours.
Definition: Stopwatch.h:126
ogdf::ILPClusterPlanarity::setStrongVariableViolation
void setStrongVariableViolation(double d)
Definition: ILPClusterPlanarity.h:160
abacus::StandardPool
Standard pools.
Definition: ILPClusterPlanarity.h:52
ogdf::ClusterElement
Representation of clusters in a clustered graph.
Definition: ClusterGraph.h:62
ogdf::ILPClusterPlanarity::m_heurTime
double m_heurTime
Definition: ILPClusterPlanarity.h:260
ogdf::Stopwatch::seconds
int64_t seconds() const
Returns the currently elapsed time in seconds.
Definition: Stopwatch.h:112
ogdf::ILPClusterPlanarity::getLPTime
double getLPTime()
Definition: ILPClusterPlanarity.h:173
ogdf::ILPClusterPlanarity::setHeuristicBound
void setHeuristicBound(double d)
Definition: ILPClusterPlanarity.h:132
ogdf::ILPClusterPlanarity::m_portaOutput
bool m_portaOutput
Definition: ILPClusterPlanarity.h:271
ogdf::ILPClusterPlanarity::setPortaOutput
void setPortaOutput(bool b)
Definition: ILPClusterPlanarity.h:152
ogdf::ILPClusterPlanarity::m_lpTime
double m_lpTime
Definition: ILPClusterPlanarity.h:261
ogdf::ILPClusterPlanarity::getPortaFileName
const char * getPortaFileName()
Definition: ILPClusterPlanarity.h:247
ogdf::ILPClusterPlanarity::m_kuratowskiLow
double m_kuratowskiLow
Definition: ILPClusterPlanarity.h:236
ogdf::ILPClusterPlanarity::setStrongConstraintViolation
void setStrongConstraintViolation(double d)
Definition: ILPClusterPlanarity.h:158
Stopwatch.h
Declaration of stopwatch classes.
ogdf::Stopwatch::minutes
int64_t minutes() const
Returns the currently elapsed time in minutes.
Definition: Stopwatch.h:119
ogdf::ILPClusterPlanarity::m_pricing
bool m_pricing
Definition: ILPClusterPlanarity.h:240
ogdf::ILPClusterPlanarity::setNumberOfSubDivisions
void setNumberOfSubDivisions(int i)
Definition: ILPClusterPlanarity.h:138
ogdf::Stopwatch::centiSeconds
int64_t centiSeconds() const
Returns the currently elapsed time in 1/100-seconds.
Definition: Stopwatch.h:105
ogdf::ILPClusterPlanarity::ILPClusterPlanarity
ILPClusterPlanarity()
Construction.
Definition: ILPClusterPlanarity.h:72
ogdf::List
Doubly linked lists (maintaining the length of the list).
Definition: DfsMakeBiconnected.h:40
ogdf::ILPClusterPlanarity::m_strongVariableViolation
double m_strongVariableViolation
Definition: ILPClusterPlanarity.h:243
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:869
ogdf::ILPClusterPlanarity::getOptStatus
abacus::Master::STATUS getOptStatus()
Definition: ILPClusterPlanarity.h:167
ogdf::ILPClusterPlanarity::setNumberOfPermutations
void setNumberOfPermutations(int i)
Definition: ILPClusterPlanarity.h:134
ogdf::ILPClusterPlanarity::setNumberOfKuraIterations
void setNumberOfKuraIterations(int i)
Definition: ILPClusterPlanarity.h:136
ogdf::ILPClusterPlanarity::m_numCCons
int m_numCCons
Definition: ILPClusterPlanarity.h:265
ogdf::ILPClusterPlanarity::m_totalWTime
double m_totalWTime
Definition: ILPClusterPlanarity.h:264
ogdf::ILPClusterPlanarity::m_numLPs
int m_numLPs
Definition: ILPClusterPlanarity.h:267
ogdf::ILPClusterPlanarity::m_heuristicRuns
int m_heuristicRuns
Definition: ILPClusterPlanarity.h:232
ogdf::ILPClusterPlanarity::getNumSubSelected
int getNumSubSelected()
Returns number of subproblems selected by ABACUS.
Definition: ILPClusterPlanarity.h:194
ogdf::ILPClusterPlanarity::m_subdivisions
int m_subdivisions
Definition: ILPClusterPlanarity.h:235
ogdf::ILPClusterPlanarity::setHeuristicRuns
void setHeuristicRuns(int i)
Definition: ILPClusterPlanarity.h:130
ogdf::ILPClusterPlanarity::m_sepTime
double m_sepTime
Definition: ILPClusterPlanarity.h:263
ogdf::cluster_planarity::CP_MasterBase
Definition: CP_MasterBase.h:60
ogdf::ILPClusterPlanarity::getTotalTime
double getTotalTime()
Definition: ILPClusterPlanarity.h:169
ogdf::ILPClusterPlanarity::getSolByHeuristic
bool getSolByHeuristic()
Definition: ILPClusterPlanarity.h:202
ogdf::ILPClusterPlanarity
C-planarity testing via completely connected graph extension.
Definition: ILPClusterPlanarity.h:61
ogdf::ILPClusterPlanarity::getNumBCs
int getNumBCs()
Returns number of generated LPs.
Definition: ILPClusterPlanarity.h:191
ogdf::ILPClusterPlanarity::m_numVars
int m_numVars
Definition: ILPClusterPlanarity.h:270
ogdf::ILPClusterPlanarity::setLowerRounding
void setLowerRounding(double d)
Definition: ILPClusterPlanarity.h:144
basic.h
Basic declarations, included by all source files.
ogdf::ILPClusterPlanarity::solutionMethod
solmeth & solutionMethod()
Definition: ILPClusterPlanarity.h:205
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
ogdf::Stopwatch
Realizes a stopwatch for measuring elapsed time.
Definition: Stopwatch.h:45
ogdf::ILPClusterPlanarity::setPricing
void setPricing(bool b)
Definition: ILPClusterPlanarity.h:154
ogdf::ILPClusterPlanarity::m_solByHeuristic
bool m_solByHeuristic
Definition: ILPClusterPlanarity.h:274
ClusterGraph.h
Derived class of GraphObserver providing additional functionality to handle clustered graphs.
ogdf::ILPClusterPlanarity::setBranchingGap
void setBranchingGap(double d)
Definition: ILPClusterPlanarity.h:148
ogdf::ILPClusterPlanarity::m_numAddVariables
int m_numAddVariables
Definition: ILPClusterPlanarity.h:241
List.h
Declaration of doubly linked lists and iterators.
ogdf::ILPClusterPlanarity::isClusterPlanarDestructive
bool isClusterPlanarDestructive(ClusterGraph &CG, Graph &G) override
Returns true, if CG is cluster-planar, false otherwise. In it is non-cluster-planar,...
Definition: ILPClusterPlanarity.h:121
ogdf::ILPClusterPlanarity::getNumVars
int getNumVars()
Returns number of global variables. Todo: Real number from ABACUS.
Definition: ILPClusterPlanarity.h:197
ogdf::ILPClusterPlanarity::m_numSubSelected
int m_numSubSelected
Definition: ILPClusterPlanarity.h:269
ogdf::ILPClusterPlanarity::getTotalWTime
double getTotalWTime()
Definition: ILPClusterPlanarity.h:179
ogdf::ILPClusterPlanarity::getNumLPs
int getNumLPs()
Returns number of optimized LPs (only LP-relaxations)
Definition: ILPClusterPlanarity.h:188
ogdf::ILPClusterPlanarity::setHeuristicLevel
void setHeuristicLevel(int i)
Definition: ILPClusterPlanarity.h:128
ogdf::ILPClusterPlanarity::m_numBCs
int m_numBCs
Definition: ILPClusterPlanarity.h:268
CP_MasterBase.h
Declaration of base class for master of Branch&Cut based algorithms for c-planarity testing via an ex...
ogdf::ILPClusterPlanarity::~ILPClusterPlanarity
~ILPClusterPlanarity()
Definition: ILPClusterPlanarity.h:112
ogdf::ClusterGraph
Representation of clustered graphs.
Definition: ClusterGraph.h:346
ogdf::ILPClusterPlanarity::m_solmeth
solmeth m_solmeth
Solution method, see description of solmeth.
Definition: ILPClusterPlanarity.h:245
ogdf::ClusterPlanarityModule
Definition: ClusterPlanarityModule.h:48
ogdf::ILPClusterPlanarity::m_strongConstraintViolation
double m_strongConstraintViolation
Definition: ILPClusterPlanarity.h:242
ogdf::ILPClusterPlanarity::setNumberOfSupportGraphs
void setNumberOfSupportGraphs(int i)
Definition: ILPClusterPlanarity.h:140
ogdf::ILPClusterPlanarity::m_totalTime
double m_totalTime
Definition: ILPClusterPlanarity.h:259