Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

ClusterPlanarity.h
Go to the documentation of this file.
1 
33 #pragma once
34 
35 #include <ogdf/basic/Module.h>
36 #include <ogdf/basic/Timeouter.h>
37 
41 
42 #include <ogdf/external/abacus.h>
43 
44 namespace ogdf {
45 
47 
51 {
52 public:
55 
59  enum class solmeth { Fallback, New };
60 
63  : m_heuristicLevel(1)
64  , m_heuristicRuns(1)
65  , m_heuristicOEdgeBound(0.4)
66  , m_heuristicNPermLists(5)
67  , m_kuratowskiIterations(10)
68  , m_subdivisions(10)
69  , m_kSupportGraphs(10)
70  , m_kuratowskiHigh(0.8)
71  , m_kuratowskiLow(0.8)
72  , m_perturbation(false)
73  , m_branchingGap(0.4)
74  , m_time("00:20:00")
75  , m_pricing(false)
76  , m_numAddVariables(15)
77  , m_strongConstraintViolation(0.3)
78  , m_strongVariableViolation(0.3)
79  , m_solmeth(solmeth::New)
80  , m_optStatus(abacus::Master::STATUS::Unprocessed)
81  , m_totalTime(-1.0)
82  , m_heurTime(-1.0)
83  , m_lpTime(-1.0)
84  , m_lpSolverTime(-1.0)
85  , m_sepTime(-1.0)
86  , m_totalWTime(-1.0)
87  , m_numCCons(-1)
88  , m_numKCons(-1)
89  , m_numLPs(-1)
90  , m_numBCs(-1)
91  , m_numSubSelected(-1)
92  , m_numVars(-1)
93  , m_portaOutput(false)
94  , m_defaultCutPool(true)
95 #ifdef OGDF_DEBUG
96  , m_solByHeuristic(false)
97 #endif
98  { }
99 
100  //destruction
102 
105  bool isClusterPlanar(const ClusterGraph &CG, NodePairs &addedEdges);
106 
108  virtual bool isClusterPlanar(const ClusterGraph &CG) override;
109 
110  //setter methods for the module parameters
111  void setHeuristicLevel(int i) {m_heuristicLevel = i;}
112  void setHeuristicRuns(int i) {m_heuristicRuns = i;}
113  void setHeuristicBound(double d) {m_heuristicOEdgeBound = d;}
114  void setNumberOfPermutations(int i) {m_heuristicNPermLists = i;}
115  void setNumberOfKuraIterations(int i) {m_kuratowskiIterations = i;}
116  void setNumberOfSubDivisions(int i) {m_subdivisions = i;}
117  void setNumberOfSupportGraphs(int i) {m_kSupportGraphs = i;}
118  void setUpperRounding(double d) {m_kuratowskiHigh = d;}
119  void setLowerRounding(double d) {m_kuratowskiLow = d;}
120  void setPerturbation(bool b) {m_perturbation = b;}
121  void setBranchingGap(double d) {m_branchingGap = d;}
122  void setTimeLimit(string s) {m_time = s.c_str();}
123  void setPortaOutput(bool b) {m_portaOutput = b;}
124  void setPricing(bool b) { m_pricing = b;}
125  void setNumAddVariables(int n) { m_numAddVariables = n;}
126  void setStrongConstraintViolation(double d) { m_strongConstraintViolation=d;}
127  void setStrongVariableViolation(double d) { m_strongVariableViolation=d;}
130  bool & useDefaultCutPool() { return m_defaultCutPool; }
131 
132  //getter methods for results
133  abacus::Master::STATUS getOptStatus() { return m_optStatus; }
134  double getTotalTime() {return m_totalTime;}
135  double getHeurTime() {return m_heurTime;}
136  double getLPTime() {return m_lpTime;}
137  double getLPSolverTime() {return m_lpSolverTime;}
138  double getSeparationTime() {return m_sepTime;}
139  double getTotalWTime() {return m_totalWTime;}
141  int getNumCCons() {return m_numCCons;}
143  int getNumKCons() {return m_numKCons;}
145  int getNumLPs() {return m_numLPs;}
147  int getNumBCs() {return m_numBCs;}
149  int getNumSubSelected() {return m_numSubSelected;}
151  int getNumVars() {return m_numVars;}
152 
154  void writeFeasible(const char *filename, CP_MasterBase &master,
155  abacus::Master::STATUS &status);
156 #ifdef OGDF_DEBUG
157  bool getSolByHeuristic(){return m_solByHeuristic;}
158 #endif
159 
160  solmeth& solutionMethod() { return m_solmeth; }
161 
162 protected:
163 
164  // Performs a c-planarity test on CG.
165  virtual bool doTest(const ClusterGraph &CG) override;
166 
167  //as above, on success also returns the set of edges that were
168  //added to construct a completely connected planar graph.
169  virtual bool doTest(const ClusterGraph &G, NodePairs &addedEdges);
170 
171  // Performs a c-planarity test using only a reduced set
172  // of allowed extension edges, returns c-planarity status
173 #if 0
174  virtual bool doFastTest(const ClusterGraph &G);
175 #endif
176 
177  double getDoubleTime(const Stopwatch &act)
178  {
179  int64_t tempo = act.centiSeconds()+100*act.seconds()+6000*act.minutes()+360000*act.hours();
180  return ((double) tempo)/ 100.0;
181  }
182 
184  void getBottomUpClusterList(const cluster c, List< cluster > & theList);
185 
186 private:
187  //Abacus Master class settings in order of appearance
188  int m_heuristicLevel, m_heuristicRuns;
190  int m_heuristicNPermLists, m_kuratowskiIterations;
191  int m_subdivisions, m_kSupportGraphs;
192  double m_kuratowskiHigh, m_kuratowskiLow;
195  string m_time;
196  bool m_pricing;//<! Decides if pricing is used
200 
202 
203  const char* getPortaFileName()
204  {
205  return "porta.poi";
206  }
207  const char* getIeqFileName()
208  {
209  return "porta.ieq";
210  }
212  {
213  return 1024;
214  }
215  void outputCons(std::ofstream &os,
218 
219  //results
220  abacus::Master::STATUS m_optStatus; //<! Status of optimization, returned from abacus
221  double m_totalTime; //<! Total computation time, returned from abacus
222  double m_heurTime; //<! Time spent in heuristic, returned from abacus
223  double m_lpTime; //<! Cpu time spent in members of the LP-interface, returned from abacus
224  double m_lpSolverTime; //<! Cpu time required by the LP solver, returned from abacus
225  double m_sepTime; //<! Cpu time spent in the separation of cutting planes, returned from abacus
226  double m_totalWTime; //<! Total wall clock time, returned from abacus
227  int m_numCCons; //<! Number of added connectivity constraints
228  int m_numKCons; //<! Number of added kuratowski constraints
229  int m_numLPs; //<! The number of optimized linear programs (LP-relax.).
230  int m_numBCs; //<! The number of generated subproblems.
231  int m_numSubSelected; //<! The number of subproblems selected by ABACUS.
232  int m_numVars; //<! The number of global variables.
233  bool m_portaOutput; //<! If set to true, output for PORTA in ieq format is generated.
234  bool m_defaultCutPool; //<! Passed through to master
235 #ifdef OGDF_DEBUG
236  bool m_solByHeuristic;
237 #endif
238 
239 };
240 
241 }
Declaration of the CPlanarityMaster class for the Branch&Cut algorithm for c-planarity testing via an...
void setUpperRounding(double d)
Derived class of GraphObserver providing additional functionality to handle clustered graphs...
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:99
solmeth
Solution method, fallback to old version (allowing all extension edges, based on c-planar subgraph co...
void setTimeLimit(string s)
Declares base class for all module types.
void setNumberOfPermutations(int i)
int64_t minutes() const
Returns the currently elapsed time in minutes.
Definition: Stopwatch.h:121
int getNumBCs()
Returns number of generated LPs.
int64_t centiSeconds() const
Returns the currently elapsed time in 1/100-seconds.
Definition: Stopwatch.h:107
int getNumLPs()
Returns number of optimized LPs (only LP-relaxations)
int getNumCCons()
Returns number of connectivity constraints added during computation.
void setBranchingGap(double d)
Declaration of ClusterPlanarModule which implements a c-planarity test.
void setHeuristicBound(double d)
Representation of clustered graphs.
Definition: ClusterGraph.h:291
abacus::Master::STATUS getOptStatus()
abacus::Master::STATUS m_optStatus
const char * getPortaFileName()
void setLowerRounding(double d)
const char * getIeqFileName()
Doubly linked lists (maintaining the length of the list).
Definition: List.h:40
Includes Abacus.
double getDoubleTime(const Stopwatch &act)
ClusterPlanarity()
Construction.
bool & useDefaultCutPool()
Use default abacus master cut pool or dedicated connectivity and kuratowski cut pools.
void setNumberOfSubDivisions(int i)
int getNumVars()
Returns number of global variables. Todo: Real number from ABACUS.
Representation of clusters in a clustered graph.
Definition: ClusterGraph.h:53
void setStrongVariableViolation(double d)
int64_t seconds() const
Returns the currently elapsed time in seconds.
Definition: Stopwatch.h:114
Declares base class for modules with timeout functionality.
int64_t hours() const
Returns the currently elapsed time in hours.
Definition: Stopwatch.h:128
The namespace for all OGDF objects.
int getNumKCons()
Returns number of Kuratowski constraints added during computation.
STATUS
The various statuses of the optimization process.
Definition: master.h:77
solmeth m_solmeth
Solution method, see description of solmeth.
void setStrongConstraintViolation(double d)
Realizes a stopwatch for measuring elapsed time.
Definition: Stopwatch.h:43
int getNumSubSelected()
Returns number of subproblems selected by ABACUS.
void setNumberOfKuraIterations(int i)
C-planarity testing via completely connected graph extension.
void setNumberOfSupportGraphs(int i)