Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

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_totalTime(-1.0),
81  m_heurTime(-1.0),
82  m_lpTime(-1.0),
83  m_lpSolverTime(-1.0),
84  m_sepTime(-1.0),
85  m_totalWTime(-1.0),
86  m_numCCons(-1),
87  m_numKCons(-1),
88  m_numLPs(-1),
89  m_numBCs(-1),
90  m_numSubSelected(-1),
91  m_portaOutput(false) { }
92 
93  //destruction
95 
98  bool isClusterPlanar(const ClusterGraph &CG, NodePairs &addedEdges);
99 
101  virtual bool isClusterPlanar(const ClusterGraph &CG) override;
102 
103  //setter methods for the module parameters
104  void setHeuristicLevel(int i) {m_heuristicLevel = i;}
105  void setHeuristicRuns(int i) {m_heuristicRuns = i;}
106  void setHeuristicBound(double d) {m_heuristicOEdgeBound = d;}
107  void setNumberOfPermutations(int i) {m_heuristicNPermLists = i;}
108  void setNumberOfKuraIterations(int i) {m_kuratowskiIterations = i;}
109  void setNumberOfSubDivisions(int i) {m_subdivisions = i;}
110  void setNumberOfSupportGraphs(int i) {m_kSupportGraphs = i;}
111  void setUpperRounding(double d) {m_kuratowskiHigh = d;}
112  void setLowerRounding(double d) {m_kuratowskiLow = d;}
113  void setPerturbation(bool b) {m_perturbation = b;}
114  void setBranchingGap(double d) {m_branchingGap = d;}
115  void setTimeLimit(string s) {m_time = s.c_str();}
116  void setPortaOutput(bool b) {m_portaOutput = b;}
117  void setPricing(bool b) { m_pricing = b;}
118  void setNumAddVariables(int n) { m_numAddVariables = n;}
119  void setStrongConstraintViolation(double d) { m_strongConstraintViolation=d;}
120  void setStrongVariableViolation(double d) { m_strongVariableViolation=d;}
123  bool & useDefaultCutPool() { return m_defaultCutPool; }
124 
125  //getter methods for results
126  abacus::Master::STATUS getOptStatus() { return m_optStatus; }
127  double getTotalTime() {return m_totalTime;}
128  double getHeurTime() {return m_heurTime;}
129  double getLPTime() {return m_lpTime;}
130  double getLPSolverTime() {return m_lpSolverTime;}
131  double getSeparationTime() {return m_sepTime;}
132  double getTotalWTime() {return m_totalWTime;}
134  int getNumCCons() {return m_numCCons;}
136  int getNumKCons() {return m_numKCons;}
138  int getNumLPs() {return m_numLPs;}
140  int getNumBCs() {return m_numBCs;}
142  int getNumSubSelected() {return m_numSubSelected;}
144  int getNumVars() {return m_numVars;}
145 
147  void writeFeasible(const char *filename, CP_MasterBase &master,
148  abacus::Master::STATUS &status);
149 #ifdef OGDF_DEBUG
150  bool getSolByHeuristic(){return m_solByHeuristic;}
151 #endif
152 
153  solmeth& solutionMethod() { return m_solmeth; }
154 
155 protected:
156 
157  // Performs a c-planarity test on CG.
158  virtual bool doTest(const ClusterGraph &CG) override;
159 
160  //as above, on success also returns the set of edges that were
161  //added to construct a completely connected planar graph.
162  virtual bool doTest(const ClusterGraph &G, NodePairs &addedEdges);
163 
164  // Performs a c-planarity test using only a reduced set
165  // of allowed extension edges, returns c-planarity status
166 #if 0
167  virtual bool doFastTest(const ClusterGraph &G);
168 #endif
169 
170  double getDoubleTime(const Stopwatch &act)
171  {
172  int64_t tempo = act.centiSeconds()+100*act.seconds()+6000*act.minutes()+360000*act.hours();
173  return ((double) tempo)/ 100.0;
174  }//getdoubletime
175 
177  void getBottomUpClusterList(const cluster c, List< cluster > & theList);
178 
179 private:
180  //Abacus Master class settings in order of appearance
181  int m_heuristicLevel, m_heuristicRuns;
183  int m_heuristicNPermLists, m_kuratowskiIterations;
184  int m_subdivisions, m_kSupportGraphs;
185  double m_kuratowskiHigh, m_kuratowskiLow;
188  string m_time;
189  bool m_pricing;//<! Decides if pricing is used
193 
195 
196  const char* getPortaFileName()
197  {
198  return "porta.poi";
199  }
200  const char* getIeqFileName()
201  {
202  return "porta.ieq";
203  }
205  {
206  return 1024;
207  }
208  void outputCons(ofstream &os,
211 
212  //results
213  abacus::Master::STATUS m_optStatus; //<! Status of optimization, returned from abacus
214  double m_totalTime; //<! Total computation time, returned from abacus
215  double m_heurTime; //<! Time spent in heuristic, returned from abacus
216  double m_lpTime; //<! Cpu time spent in members of the LP-interface, returned from abacus
217  double m_lpSolverTime; //<! Cpu time required by the LP solver, returned from abacus
218  double m_sepTime; //<! Cpu time spent in the separation of cutting planes, returned from abacus
219  double m_totalWTime; //<! Total wall clock time, returned from abacus
220  int m_numCCons; //<! Number of added connectivity constraints
221  int m_numKCons; //<! Number of added kuratowski constraints
222  int m_numLPs; //<! The number of optimized linear programs (LP-relax.).
223  int m_numBCs; //<! The number of generated subproblems.
224  int m_numSubSelected; //<! The number of subproblems selected by ABACUS.
225  int m_numVars; //<! The number of global variables.
226  bool m_portaOutput; //<! If set to true, output for PORTA in ieq format is generated.
227  bool m_defaultCutPool; //<! Passed through to master
228 #ifdef OGDF_DEBUG
229  bool m_solByHeuristic;
230 #endif
231 
232 };
233 
234 }
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:39
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)