00001
00002
00003
00004
00005
00006
00007
00008
00044 #ifdef _MSC_VER
00045 #pragma once
00046 #endif
00047
00048 #ifndef OGDF_MAXIMUM_CPLANAR_SUBGRAPH_H
00049 #define OGDF_MAXIMUM_CPLANAR_SUBGRAPH_H
00050
00051 #include <ogdf/basic/Module.h>
00052 #include <ogdf/basic/Timeouter.h>
00053
00054 #include <ogdf/module/CPlanarSubgraphModule.h>
00055 #include <ogdf/cluster/ClusterGraph.h>
00056 #include <ogdf/internal/cluster/MaxCPlanar_Master.h>
00057
00058 #include <ogdf/external/abacus.h>
00059
00060 namespace ogdf {
00061
00066 class OGDF_EXPORT MaximumCPlanarSubgraph : public CPlanarSubgraphModule
00067 {
00068
00069 #ifndef USE_ABACUS
00070 protected:
00071 ReturnType doCall(const ClusterGraph &G,
00072 List<edge> &delEdges,
00073 List<edge> &addedEdges)
00074 { THROW_NO_ABACUS_EXCEPTION; return retError; }
00075
00076 virtual ReturnType doCall(const ClusterGraph &G,
00077 List<edge> &delEdges)
00078 { THROW_NO_ABACUS_EXCEPTION; return retError; }
00079 };
00080 #else // USE_ABACUS
00081
00082 public:
00084 MaximumCPlanarSubgraph() : m_heuristicLevel(1),
00085 m_heuristicRuns(1),
00086 m_heuristicOEdgeBound(0.4),
00087 m_heuristicNPermLists(5),
00088 m_kuratowskiIterations(10),
00089 m_subdivisions(10),
00090 m_kSupportGraphs(10),
00091 m_kuratowskiHigh(0.8),
00092 m_kuratowskiLow(0.8),
00093 m_perturbation(false),
00094 m_branchingGap(0.4),
00095 m_time("00:30:00"),
00096 m_pricing(true),
00097 m_checkCPlanar(false),
00098 m_numAddVariables(15),
00099 m_strongConstraintViolation(0.3),
00100 m_strongVariableViolation(0.3),
00101 m_ol(ABA_MASTER::Silent),
00102 m_totalTime(-1.0),
00103 m_heurTime(-1.0),
00104 m_lpTime(-1.0),
00105 m_lpSolverTime(-1.0),
00106 m_sepTime(-1.0),
00107 m_totalWTime(-1.0),
00108 m_numCCons(-1),
00109 m_numKCons(-1),
00110 m_numLPs(-1),
00111 m_numBCs(-1),
00112 m_numSubSelected(-1),
00113 m_portaOutput(false) {}
00114
00115 ~MaximumCPlanarSubgraph() {}
00116
00125 ReturnType call(const ClusterGraph &G, List<edge> &delEdges,
00126 List<nodePair> &addedEdges) {
00127 return doCall(G, delEdges, addedEdges);
00128 }
00129
00130 void setHeuristicLevel(int i) {m_heuristicLevel = i;}
00131 void setHeuristicRuns(int i) {m_heuristicRuns = i;}
00132 void setHeuristicBound(double d) {m_heuristicOEdgeBound = d;}
00133 void setNumberOfPermutations(int i) {m_heuristicNPermLists = i;}
00134 void setNumberOfKuraIterations(int i) {m_kuratowskiIterations = i;}
00135 void setNumberOfSubDivisions(int i) {m_subdivisions = i;}
00136 void setNumberOfSupportGraphs(int i) {m_kSupportGraphs = i;}
00137 void setUpperRounding(double d) {m_kuratowskiHigh = d;}
00138 void setLowerRounding(double d) {m_kuratowskiLow = d;}
00139 void setPerturbation(bool b) {m_perturbation = b;}
00140 void setBranchingGap(double d) {m_branchingGap = d;}
00141 void setTimeLimit(String s) {m_time = s.cstr();}
00142 void setOutputLevel(ABA_MASTER::OUTLEVEL o) {m_ol = o;}
00143 void setPortaOutput(bool b) {m_portaOutput = b;}
00144 void setPricing(bool b) { m_pricing = b;}
00145 void setCheckCPlanar(bool b) {m_checkCPlanar = b;}
00146 void setNumAddVariables(int n) { m_numAddVariables = n;}
00147 void setStrongConstraintViolation(double d) { m_strongConstraintViolation=d;}
00148 void setStrongVariableViolation(double d) { m_strongVariableViolation=d;}
00151 bool & useDefaultCutPool() {return m_defaultCutPool;}
00152
00153
00154 double getTotalTime() {return m_totalTime;}
00155 double getHeurTime() {return m_heurTime;}
00156 double getLPTime() {return m_lpTime;}
00157 double getLPSolverTime() {return m_lpSolverTime;}
00158 double getSeparationTime() {return m_sepTime;}
00159 double getTotalWTime() {return m_totalWTime;}
00161 int getNumCCons() {return m_numCCons;}
00163 int getNumKCons() {return m_numKCons;}
00165 int getNumLPs() {return m_numLPs;}
00167 int getNumBCs() {return m_numBCs;}
00169 int getNumSubSelected() {return m_numSubSelected;}
00171 int getNumVars() {return m_numVars;}
00172
00174 void writeFeasible(const String &filename, Master &master,
00175 ABA_MASTER::STATUS &status);
00176 #ifdef OGDF_DEBUG
00177 bool getSolByHeuristic(){return m_solByHeuristic;}
00178 #endif
00179
00180
00181 protected:
00186 virtual ReturnType doCall(const ClusterGraph &G,
00187 List<edge> &delEdges)
00188 {
00189 List<nodePair> addEdges;
00190 return doCall(G, delEdges, addEdges);
00191 }
00192
00193
00194
00195
00196 virtual ReturnType doCall(const ClusterGraph &G,
00197 List<edge> &delEdges,
00198 List<nodePair> &addedEdges);
00199
00200 double getDoubleTime(const ABA_TIMER &act)
00201 {
00202 long tempo = act.centiSeconds()+100*act.seconds()+6000*act.minutes()+360000*act.hours();
00203 return ((double) tempo)/ 100.0;
00204 }
00205
00207 void getBottomUpClusterList(const cluster c, List< cluster > & theList);
00208
00209 private:
00210
00211 int m_heuristicLevel, m_heuristicRuns;
00212 double m_heuristicOEdgeBound;
00213 int m_heuristicNPermLists, m_kuratowskiIterations;
00214 int m_subdivisions, m_kSupportGraphs;
00215 double m_kuratowskiHigh, m_kuratowskiLow;
00216 bool m_perturbation;
00217 double m_branchingGap;
00218 const char *m_time;
00219 bool m_pricing;
00220 bool m_checkCPlanar;
00221 int m_numAddVariables;
00222 double m_strongConstraintViolation;
00223 double m_strongVariableViolation;
00224
00225 ABA_MASTER::OUTLEVEL m_ol;
00226
00227 const char* getPortaFileName()
00228 {
00229 return "porta.poi";
00230 }
00231 const char* getIeqFileName()
00232 {
00233 return "porta.ieq";
00234 }
00235 const int maxConLength()
00236 {
00237 return 1024;
00238 }
00239 void outputCons(ofstream &os,
00240 ABA_STANDARDPOOL<ABA_CONSTRAINT, ABA_VARIABLE> *connCon,
00241 ABA_STANDARDPOOL<ABA_VARIABLE, ABA_CONSTRAINT> *stdVar);
00242
00243
00244 double m_totalTime;
00245 double m_heurTime;
00246 double m_lpTime;
00247 double m_lpSolverTime;
00248 double m_sepTime;
00249 double m_totalWTime;
00250 int m_numCCons;
00251 int m_numKCons;
00252 int m_numLPs;
00253 int m_numBCs;
00254 int m_numSubSelected;
00255 int m_numVars;
00256 bool m_portaOutput;
00257 bool m_defaultCutPool;
00258 #ifdef OGDF_DEBUG
00259 bool m_solByHeuristic;
00260 #endif
00261
00262 };
00263
00264 #endif // USE_ABACUS
00265
00266 }
00267
00268
00269 #endif // OGDF_MAXIMUM_CPLANAR_SUBGRAPH_H