37#ifndef _CMGRAPHS_COMPMDEC_H_
38#define _CMGRAPHS_COMPMDEC_H_
53#include "chomp/system/textfile.h"
54#include "chomp/cubes/pointset.h"
55#include "chomp/struct/digraph.h"
56#include "chomp/struct/multitab.h"
57#include "chomp/struct/hashsets.h"
58#include "chomp/system/timeused.h"
87 TConnTable (int_t _n, chomp::homology::multitable
88 <chomp::homology::multitable<int_t> > &_connections,
89 chomp::homology::multitable<int_t> &_conncount,
90 const int_t *_numTranslate);
93 void operator () (int_t source, int_t target, int_t v);
101 chomp::homology::multitable<chomp::homology::multitable<int_t> >
113 chomp::homology::multitable<chomp::homology::multitable<int_t> > &
114 _connections, chomp::homology::multitable<int_t> &_conncount,
115 const int_t *_numTranslate):
116 n (_n), connections (_connections), conncount (_conncount),
117 numTranslate (_numTranslate)
119 int_t maxcount =
n *
n;
120 for (int_t i = 0; i < maxcount; ++ i)
127 int_t pos =
n * source + target;
141 const std::vector<int> &_setNumbers,
142 const spcCubes &spcX,
const int_t *_numTranslate);
145 void operator () (int_t source, int_t target, int_t v);
164 const std::vector<int> &_setNumbers,
const spcCubes &spcX,
165 const int_t *_numTranslate): morseDec (_morseDec),
166 setNumbers (_setNumbers), X (spcX), numTranslate (_numTranslate)
190 for (
int i = 0; i <=
spaceDim; ++ i)
191 betti [i] = (i == nonzero) ? 1 : 0;
194 morseDec. setindex (n, ind);
211 const double *offset,
const double *width,
214 int &subdivNonemptyInv,
int &noIsolation,
int &attractor)
216 using chomp::homology::sbug;
221 for (
int subdivisions = 0;; ++ subdivisions)
225 1 << (subdivDepth + subdivisions),
226 subdivDepth + subdivisions, theMap);
227 if (subdivisions > 1)
229 subdivCubMap. setAllowedImgSize
232 subdivCubMap. cache =
false;
234 (subdivisions > 1) ? subdivCubMap :
235 (subdivisions ? theCubMap1 : theCubMap0);
236 bool crop = theCubMap. cropping;
246 sbug <<
"An error occurred while "
247 "computing Inv(X).\n";
248 subdivNonemptyInv = 1;
253 sbug <<
"Inv(X) turned out to be "
256 subdivNonemptyInv = 0;
260 catch (
const char *msg)
262 subdivNonemptyInv = 1;
263 sbug <<
"Failed: " << msg <<
"\n";
264 sbug <<
"Failure: Unable to compute Inv.\n";
270 const spcCubes &theSet = subdivisions ? X : morseDec [n];
278 (1 << (subdivDepth + subdivisions));
284 int size = theSet. size ();
285 for (
int i = 0; i < size; ++ i)
289 theCubMap. cropping = wrapping ? false :
true;
290 theCubMap. cropped =
false;
292 theCubMap. cropping = crop;
301 throw "Image cropped without permission!!!";
305 attractor = P. countExit () ? 0 : 1;
309 ind. setIndexPair (&P);
313 ind. setIndexPair (0);
316 morseDec. setindex (n, ind);
319 catch (
const char *msg)
321 theCubMap. cropping = crop;
322 sbug <<
"Failed: " << msg <<
"\n";
328 sbug <<
"Failure: Max refinement depth " <<
330 subdivNonemptyInv = 1;
331 if (theCubMap. cropped)
341 if (theSet. size () > maxRefineSize)
343 sbug <<
"Failure: Not subdividing" <<
344 (subdivisions ?
" anymore" :
"") <<
345 ", because the set size " <<
346 theSet. size () <<
"\nis beyond the max "
347 "allowed " << maxRefineSize <<
".\n";
350 subdivNonemptyInv = 1;
351 if (theCubMap. cropped)
357 sbug <<
"- subdiv " << (subdivDepth + subdivisions + 1) <<
358 ": " << theSet. size () <<
" -> ";
364 sbug << X. size () <<
" ";
378template <
class typeCubes>
380 const chomp::homology::diGraph<> &g)
382 using chomp::homology::diGraph;
383 using chomp::homology::multitable;
395 multitable<int_t> compVertices (8192);
396 multitable<int_t> compEnds (8192);
397 diGraph<> *sccAddr = 0;
398 diGraph<> *transpAddr = 0;
399 int_t nSets = chomp::homology::SCC (g, compVertices, compEnds,
400 sccAddr, transpAddr);
403 for (int_t n = 0; n < nSets; ++ n)
406 int_t beginVertex = n ? compEnds [n - 1] :
407 static_cast<int_t
> (0);
408 int_t endVertex = compEnds [n];
411 for (int_t i = beginVertex; i < endVertex; ++ i)
412 Y. add (X [compVertices [i]]);
439template <
class typeCubes,
class typeMorseDec>
440void invMorseDec (
const typeCubes &X,
const chomp::homology::diGraph<> &g,
441 typeMorseDec &morseDec,
442 const double *offset,
const double *width,
int subdivDepth,
446 const std::string &cacheFileName,
bool &morseDecComputed,
447 std::vector<int> &wrongIndices, std::vector<int> &skippedIndices,
448 std::vector<int> &attractors,
bool connOrbits,
449 const double *leftMapParam,
const double *rightMapParam,
450 int paramCount, chomp::homology::timeused &timeSubdiv)
452 using chomp::homology::sbug;
453 using chomp::homology::diGraph;
454 using chomp::homology::multitable;
455 using chomp::homology::hashedset;
456 using chomp::homology::timeused;
466 multitable<int_t> compVertices (8192);
467 multitable<int_t> compEnds (8192);
468 diGraph<> *sccAddr = 0;
469 diGraph<> *transpAddr = 0;
470 int_t nSets_big = chomp::homology::SCC (g, compVertices, compEnds,
471 sccAddr, transpAddr);
472 int_t nCubes = (nSets_big > 0) ? compEnds [nSets_big - 1] : 0;
473 sbug << nCubes <<
" (" << nSets_big <<
" sets).\n";
474 sbug <<
"Volume of the union of the Morse sets: " <<
476 sbug <<
"Morse decomp computed in " << timeSubdiv <<
".\n";
477 int nSets =
static_cast<int> (nSets_big);
478 if (
static_cast<int_t
> (nSets) != nSets_big)
479 throw "The number of Morse sets exceeds reasonable limits.";
487 bool cacheIndices = !cacheFileName. empty ();
488 std::string indFileNameStr = cacheFileName;
489 const char *indFileName = indFileNameStr. c_str ();
490 std::string lockFileNameStr = cacheFileName +
".lock";
491 const char *lockFileName = lockFileNameStr. c_str ();
495 timeused timeSetMorseDec;
497 sbug <<
"Initializing the MorseDec data structure... ";
498 morseDec. setnumber (nSets);
499 int_t countSCCcubes = 0;
500 for (
int n = 0; n < nSets; ++ n)
503 int_t beginVertex = n ? compEnds [n - 1] :
504 static_cast<int_t
> (0);
505 int_t endVertex = compEnds [n];
506 countSCCcubes += endVertex - beginVertex;
509 for (int_t i = beginVertex; i < endVertex; ++ i)
510 morseDec. add (n, X [compVertices [i]]);
512 sbug << timeSetMorseDec <<
".\n";
516 sbug <<
"Checking isolation of the Morse sets... ";
517 bool isolated =
true;
518 for (
int n = 0; n < nSets; ++ n)
525 sbug << (isolated ?
"[isolated]\n" :
"[no isol]\n");
528 timeused timeConleyIndices;
529 timeConleyIndices = 0;
530 bool cachedAvailable =
false;
535 sbug <<
"! Skipping cached indices (locked).\n";
536 else if (cached. read (indFileName, morseDec) != 0)
537 sbug <<
"! Error while reading cached indices.\n";
540 sbug <<
"[using cached Conley indices]\n";
541 cachedAvailable =
true;
544 morseDecComputed = !cachedAvailable;
547 std::vector<int> subdivNonemptyInv (nSets, -1);
548 if (!cachedAvailable)
550 timeused timeEmptyInv;
552 sbug <<
"Checking small Morse sets for empty inv...\n";
553 for (
int n = 0; n < nSets; ++ n)
561 offset, width, theMap,
562 theCubMap0, theCubMap1))
564 subdivNonemptyInv [n] = 0;
565 cached. emptyInv [n] =
true;
568 sbug <<
"Invariant part of small Morse sets checked in " <<
569 timeEmptyInv <<
".\n";
572#ifdef CONFIG_NOCONNECTIONS
573 sbug <<
"Note: Skippnig the computation of connecting orbits.\n";
579 bool computeconn = connOrbits || (
maxJoinSize > 0);
582 timeused timeConnOrb;
586 std::vector<int> setNumbers1;
587 for (
int n = 0; n < nSets; ++ n)
589 if (cachedAvailable && cached. emptyInv [n])
591 if (subdivNonemptyInv [n] == 0)
593 setNumbers1. push_back (n);
595 int nSets1 (setNumbers1. size ());
597 sbug <<
"Computing connecting orbits between " << nSets1 <<
601 multitable<int_t> compVertices1 (8192);
602 multitable<int_t> compEnds1 (8192);
604 for (
int i = 0; i < nSets1; ++ i)
606 int n (setNumbers1 [i]);
607 for (
int j = n ? compEnds [n - 1] : 0;
608 j < compEnds [n]; ++ j)
610 compVertices1 [cur ++] = compVertices [j];
617 int_t *newNumbers = computeconn ?
new int_t [X. size ()] : 0;
619 chomp::homology::collapseVertices (g, nSets1, compVertices1,
620 compEnds1, collapsed, newNumbers);
623 int_t *oldNumbers = computeconn ?
new int_t [X. size ()] : 0;
626 for (int_t i = 0; i < X. size (); ++ i)
627 oldNumbers [newNumbers [i]] = i;
630 delete [] newNumbers;
638 chomp::homology::inclusionGraph (collapsed, nSets1,
643 chomp::homology::inclusionGraph (collapsed, nSets1,
647 delete [] oldNumbers;
650 for (
int v = 0; v < nSets1; ++ v)
652 int_t nEdges = connGraph. countEdges (v);
653 for (int_t e = 0; e < nEdges; ++ e)
655 int_t w = connGraph. getEdge (v, e);
656 morseDec. addconn (setNumbers1 [v],
662 sbug << timeConnOrb <<
".\n";
670 for (
int n = 0; n < nSets; ++ n)
674 if (cached. wrongIndex [n])
675 wrongCubes. add (morseDec [n] [0]);
676 if (cached. attractor [n])
677 attrCubes. add (morseDec [n] [0]);
678 if (cached. skipped [n])
679 skipCubes. add (morseDec [n] [0]);
685 if (subdivNonemptyInv [n] == 0)
692 if ((skipIndices > 0) &&
693 (morseDec [n]. size () >= skipIndices))
695 sbug <<
"* Skipping ConIndex (" << n <<
").\n";
698 cached. skipped [n] =
true;
699 skipCubes. add (morseDec [n] [0]);
704 sbug <<
"* Computing Conley index of Morse Set " <<
705 n <<
" of " << nSets <<
" (" <<
706 morseDec [n]. size () <<
" cubes)...\n";
707 int noIsolation = -1;
710 offset, width, subdivDepth, theMap,
711 theCubMap0, theCubMap1,
712 subdivNonemptyInv [n], noIsolation,
716 cached. attractor [n] =
true;
717 attrCubes. add (morseDec [n] [0]);
719 if (((result < 0) || (noIsolation > 0)) &&
723 sbug <<
"* The index was set to an apriori "
728 sbug <<
"* Failed to compute the index.\n";
730 cached. wrongIndex [n] =
true;
731 cached. skipped [n] =
true;
732 skipCubes. add (morseDec [n] [0]);
734 else if (noIsolation > 0)
736 sbug <<
"* No isolation detected. The index "
737 "could not be computed reliably.\n";
738 cached. wrongIndex [n] =
true;
739 wrongCubes. add (morseDec [n] [0]);
743 sbug <<
"* The computed index is " <<
744 (morseDec. trivial (n) ?
745 "" :
"non") <<
"trivial.\n";
749 sbug <<
"Conley indices determined in " <<
750 timeConleyIndices <<
".\n";
753 timeused timePassThru;
755 hashedset<int> passThru;
756 for (
int n = 0; n < nSets; ++ n)
761 if (cached. emptyInv [n])
762 passThru. push_back (n);
767 if (subdivNonemptyInv [n] == 1)
772 if (subdivNonemptyInv [n] == 0)
774 passThru. push_back (n);
775 cached. emptyInv [n] =
true;
780 if (morseDec. computed (n) && !morseDec. trivial (n))
788 sbug <<
"Refining the set no. " << n <<
" (" <<
789 morseDec [n]. size () <<
" cubes)...\n";
791 offset, width, theMap, theCubMap0, theCubMap1))
793 sbug <<
"Empty inv. The set will be removed.\n";
794 passThru. push_back (n);
795 cached. emptyInv [n] =
true;
799 sbug <<
"Invariant part may be nonempty.\n";
802 sbug <<
"Morse sets with trivial indices analysed in " <<
803 timePassThru <<
".\n";
807 if (cacheIndices && !cachedAvailable && !
fileExists (indFileName) &&
811 std::ofstream lockFile (lockFileName);
815 cached. write (indFileName, morseDec);
818 std::remove (lockFileName);
822 if (!passThru. empty ())
824 sbug <<
"Removing " << passThru. size () <<
825 " spurious Morse sets... ";
826 timeused timeRemoving;
828#ifdef CONFIG_NOCONNECTIONS
829 if ((passThru. size () > 20) &&
830 (passThru. size () > 0.8 * morseDec. count ()))
835 int_t oldSize = morseDec. count ();
836 int_t newSize = morseDec. count () -
840 typeMorseDec newMorseDec (theCubMap0);
841 newMorseDec. setnumber (newSize);
845 for (int_t oldNumber = 0; oldNumber < oldSize;
849 if (passThru. check (oldNumber))
853 newMorseDec [newNumber]. swap
854 (morseDec [oldNumber]);
855 if (morseDec. computed (oldNumber))
857 newMorseDec. setindex (newNumber,
858 morseDec. index (oldNumber));
862 if (newNumber != newSize)
863 throw "A bug in the pass-through loop.";
866 morseDec. swap (newMorseDec);
870 for (
int i = passThru. size () - 1; i >= 0; -- i)
872 morseDec. passthru (passThru [i]);
876 for (
int i = passThru. size () - 1; i >= 0; -- i)
878 morseDec. passthru (passThru [i]);
881 sbug << timeRemoving <<
".\n";
887 sbug <<
"* " << morseDec. count () <<
" Morse sets; sizes: ";
888 for (
int i = 0; i < morseDec. count (); ++ i)
889 sbug << (i ?
" " :
"") << morseDec [i]. size ();
890 sbug <<
"\n! Joining trivial Morse sets (size: " <<
898 nSets = morseDec. count ();
902 for (int_t i = 0; i < wrongCubes. size (); ++ i)
905 while ((n < nSets) && !morseDec [n]. check (wrongCubes [i]))
908 wrongIndices. push_back (n);
911 wrongIndices. push_back (-1);
912 sbug <<
"Note: A Morse set with a wrong index "
913 "could not be identified.\n";
918 for (int_t i = 0; i < skipCubes. size (); ++ i)
921 while ((n < nSets) && !morseDec [n]. check (skipCubes [i]))
924 skippedIndices. push_back (n);
927 skippedIndices. push_back (-1);
928 sbug <<
"Note: A Morse set whose index was skipped "
929 "could not be identified.\n";
934 for (int_t i = 0; i < attrCubes. size (); ++ i)
937 while ((n < nSets) && !morseDec [n]. check (attrCubes [i]))
940 attractors. push_back (n);
943 attractors. push_back (-1);
944 sbug <<
"Note: A Morse set which is an attractor "
945 "could not be identified.\n";
951 sbug <<
"Checking isolation of the final Morse sets... ";
952 bool finalIsolated =
true;
953 for (
int n = 0; n < nSets; ++ n)
957 finalIsolated =
false;
960 sbug << (finalIsolated ?
"[isolated]\n" :
"[no isol]\n");
963 sbug <<
"* " << morseDec. count () <<
" Morse sets [" <<
964 attrCubes. size () <<
" attractor(s)]; sizes: ";
965 for (
int i = 0; i < morseDec. count (); ++ i)
966 sbug << (i ?
" " :
"") << morseDec [i]. size ();
971 int_t nMorseSets = morseDec. count ();
972 for (int_t nSet = 0; nSet < nMorseSets; ++ nSet)
973 coordMinMax (morseDec [nSet]);
974 if (coordMinMax. defined ())
976 sbug <<
"The computed Morse sets are in " <<
977 coordMinMax <<
".\n";
978 sbug <<
"Real coordinates: ";
999 const double *offset,
const double *width, int_t skipIndices,
1000 const std::string &cacheFileName,
1001 const std::string &pictureFileName,
1002 const std::string &cubesFilePrefix,
1003 const std::string &morseDecFileName,
1004 const std::string &graphFileName,
1005 const std::string &procFilePrefix,
1006 const std::string &mapOptFileName,
1007 bool &morseDecComputed,
1008 std::vector<int> &wrongIndices, std::vector<int> &skippedIndices,
1009 std::vector<int> &attractors,
bool connOrbits,
1010 const double *leftMapParam,
const double *rightMapParam,
1013 using chomp::homology::sbug;
1014 using chomp::homology::sout;
1015 using chomp::homology::diGraph;
1016 using chomp::homology::timeused;
1019 timeused timeSubdiv;
1024 bool mapOptRead =
false;
1025 if (!mapOptFileName. empty () &&
1028 std::ifstream in (mapOptFileName. c_str ());
1031 chomp::homology::ignorecomments (in);
1032 if ((str. size () > 0) && (in. peek () ==
'D'))
1034 chomp::multiwork::mwData data;
1036 theMap. loadInternals (data);
1038 sbug <<
"[using previous map optimization data]\n";
1049 if (!morseDecFileName. empty () &&
1052 sbug <<
"Loading Morse dec cache... ";
1053 using chomp::homology::program_time;
1054 double start_load_time (program_time);
1056 wrongIndices, skippedIndices, attractors);
1057 double end_load_time (program_time);
1058 sbug <<
"(" <<
static_cast<long> ((end_load_time -
1059 start_load_time) * 100) / 100 <<
" sec.)\n";
1068 for (
int i = 0; i <
spaceDim; ++ i)
1075 bool restrictionRead =
false;
1077 std::ifstream restr (
"restriction.cub");
1080 sout <<
"\n*** Restricting to a subset: ";
1081 restr >> restriction;
1082 sout << restriction. size () <<
" cubes. ***\n";
1083 restrictionRead =
true;
1088 for (
int subdivDepth = 1; subdivDepth <=
finalDepth; ++ subdivDepth)
1094 sbug <<
"Depth " << subdivDepth <<
": ";
1098 X. swap (restriction);
1107 sbug << X. size () <<
". ";
1122 1 << subdivDepth, subdivDepth, theMap);
1128 theCubMap0 : localCubMap;
1138#ifdef CONFIG_ODEVART
1151#ifdef CONFIG_ODEVART
1159 int_t maxAdd (std::max
1160 (
static_cast<int_t
> (10000),
1162 computeMapGraphIsol (X, g, theCubMap, Xadd,
1170 int_t avgImgSize = g. countVertices () ?
1172 g. countVertices ()) : 0;
1173 sbug <<
"[avg " << avgImgSize <<
"] ";
1177 (
static_cast<double> (timeMap), 1) <<
1181 if (!g. countEdges ())
1185 if (!theMap. adjust (
true, subdivDepth))
1190 catch (
const char *msg)
1194 (
static_cast<double> (timeMap), 1) <<
1195 " sec).\nFailure reason: " <<
1197 if (!theMap. adjust (
false, subdivDepth))
1200 catch (
const std::exception &e)
1204 (
static_cast<double> (timeMap), 1) <<
1205 " sec).\nFailure reason: " <<
1207 if (!theMap. adjust (
false, subdivDepth))
1213 theCubMap. cleanCache ();
1219#ifdef CONFIG_ODEVART
1229 if (!mapOptRead && !mapOptFileName. empty () &&
1232 chomp::multiwork::mwData data;
1233 theMap. saveInternals (data);
1235 std::ofstream out (mapOptFileName. c_str ());
1236 out << str <<
" D\n";
1237 sbug <<
"[map optimization data saved]\n";
1242 theCubMap0. setAllowedImgSize
1244 theCubMap1. setAllowedImgSize
1248 sbug <<
"Morse dec... ";
1250 offset, width, subdivDepth,
1251 theMap, theCubMap0, theCubMap1,
1252 skipIndices, cacheFileName, morseDecComputed,
1253 wrongIndices, skippedIndices, attractors,
1254 connOrbits, leftMapParam, rightMapParam,
1262 bool alreadyProcessed =
false;
1263 if (!procFilePrefix. empty ())
1265 std::string procMarkerName =
1266 procFilePrefix +
".mark";
1268 alreadyProcessed =
true;
1271 std::ofstream markerFile
1272 (procMarkerName. c_str ());
1273 markerFile. close ();
1276 if (!alreadyProcessed)
1279 theCubMap0, theCubMap1,
1280 cubesFilePrefix, procFilePrefix);
1286#ifdef CONFIG_NOCONNECTIONS
1287 sbug <<
"ChRec... ";
1293 sbug << X. size () <<
" ";
1294#ifdef CONFIG_ENHANCEINV
1297 sbug << X. size () <<
" ";
1300 "[isolated]\n" :
"[no isol]\n");
1305 std::ostringstream fstr;
1306 fstr <<
"_inv" << subdivDepth;
1307 std::string filename = fstr. str ();
1308 std::ofstream f (filename. c_str ());
1309 f <<
"; Inv(X) at depth " << subdivDepth <<
".\n";
1311 sbug <<
"Inv(X) saved to " << filename <<
".\n";
1319 if (!cubesFilePrefix. empty ())
1321 sout <<
"Saving the Morse decomposition to '" <<
1322 cubesFilePrefix <<
"*'...\n";
1323 morseDec. savetofiles (cubesFilePrefix. c_str ());
1327 if (!graphFileName. empty () &&
1331 chomp::homology::diGraph<> connGraph;
1332 morseDec. makegraph (connGraph);
1333 chomp::homology::diGraph<> morseGraph;
1334 transitiveReduction (connGraph, morseGraph);
1337 int nSets = morseGraph. countVertices ();
1338 std::vector<int_t> sizes (nSets);
1339 for (
int n = 0; n < nSets; ++ n)
1340 sizes [n] = morseDec [n]. size ();
1343 std::vector<theConleyIndexType> indices (nSets);
1344 std::vector<IndexEigenValues> eigenValues (nSets);
1345 for (
int n = 0; n < nSets; ++ n)
1347 indices [n] = morseDec. index (n);
1351 sout <<
"Saving the Conley-Morse graph to '" <<
1352 graphFileName <<
"'...\n";
1353 std::ofstream graphFile (graphFileName. c_str ());
1355 indices, eigenValues,
1356 wrongIndices, skippedIndices, attractors);
1358 graphFile. close ();
1363 if (!morseDecFileName. empty () &&
1366 sbug <<
"Saving Morse dec cache... ";
1367 using chomp::homology::program_time;
1368 double start_save_time (program_time);
1370 wrongIndices, skippedIndices, attractors);
1371 double end_save_time (program_time);
1372 sbug <<
"(" <<
static_cast<long> ((end_save_time -
1373 start_save_time) * 100) / 100 <<
" sec.)\n";
1379 double start_verif_time (program_time);
1380 sbug <<
"DEBUG: Verifying Morse Dec cache... ";
1382 std::vector<int> wrongIndices1;
1383 std::vector<int> skippedIndices1;
1384 std::vector<int> attractors1;
1387 wrongIndices1, skippedIndices1, attractors1);
1388 if (morseDec. count () != morseDec1. count ())
1389 throw "Wrong number of sets.";
1390 for (
int n = 0; n < morseDec. count (); ++ n)
1392 if (!(morseDec [n] == morseDec1 [n]))
1393 throw "Corrupted sets.";
1395 if (!(wrongIndices == wrongIndices1))
1396 throw "Corrupted wrongIndices.";
1397 if (!(skippedIndices == skippedIndices1))
1398 throw "Corrupted skippedIndices.";
1399 if (!(attractors == attractors1))
1400 throw "Corrupted attractors.";
1401 double end_verif_time (program_time);
1402 sbug <<
"(" <<
static_cast<long> ((end_verif_time -
1403 start_verif_time) * 100) / 100 <<
#define CONFIG_ENHANCEINV
The class that computes and returns properties of the Conley index.
A class whose objects store, update and show coordinate ranges.
Cached information on the Conley-Morse decompositions which contains information on computed Conley i...
Eigenvalues of the Conley index map gathered by levels.
A generic class that computes an index pair given the isolating neighborhood and a means to compute t...
A generic map computation routine that computes a rigorous cubical multivalued map based on a functio...
This class defines a map derived from a sample difference equation.
The Morse decoposition class.
A simple class for storing connections in an array that uses the "multitable" class.
void operator()(int_t source, int_t target, int_t v)
Adds an element v at the connection from source to target.
const int_t * numTranslate
The translation table for vertex numbers in the connections.
TConnMorse(theMorseDecompositionType &_morseDec, const std::vector< int > &_setNumbers, const spcCubes &spcX, const int_t *_numTranslate)
The constructor.
theMorseDecompositionType & morseDec
The Morse decomposition in which to record the connections.
const std::vector< int > & setNumbers
The numbers of Morse sets in the Morse decomposition that correspond to their indices given by source...
const spcCubes & X
The set which contains cubes to add.
A simple class for storing connections in an array that uses the "multitable" class.
const int_t * numTranslate
The translation table for vertex numbers in the connections.
chomp::homology::multitable< chomp::homology::multitable< int_t > > & connections
The tables of connectiong orbits; those for v -> w are stored at the index n * v + w.
int_t n
The number of vertices between the connections are recorded.
chomp::homology::multitable< int_t > & conncount
The numbers of elements in each connecting orbit.
void operator()(int_t source, int_t target, int_t v)
Adds an element v at the connection from source to target.
TConnTable(int_t _n, chomp::homology::multitable< chomp::homology::multitable< int_t > > &_connections, chomp::homology::multitable< int_t > &_conncount, const int_t *_numTranslate)
The constructor.
Sets space wrapping locally.
void setDummyIndex(theMorseDecompositionType &morseDec, int n, int nonzero=-1)
This small auxiliary procedure sets a dummy Conley index to the given Morse set.
theMorseDecompositionType * computeMorseDecomposition(theMapType &theMap, const theCubMapType theCubMap0, const theCubMapType theCubMap1, const double *offset, const double *width, int_t skipIndices, const std::string &cacheFileName, const std::string &pictureFileName, const std::string &cubesFilePrefix, const std::string &morseDecFileName, const std::string &graphFileName, const std::string &procFilePrefix, const std::string &mapOptFileName, bool &morseDecComputed, std::vector< int > &wrongIndices, std::vector< int > &skippedIndices, std::vector< int > &attractors, bool connOrbits, const double *leftMapParam, const double *rightMapParam, int paramCount)
Computes the Morse decomposition using all the pre- and postprocessing.
void chainRecurrentSet(const typeCubes &X, typeCubes &result, const chomp::homology::diGraph<> &g)
Computes the chain recurrent set of X.
void invMorseDec(const typeCubes &X, const chomp::homology::diGraph<> &g, typeMorseDec &morseDec, const double *offset, const double *width, int subdivDepth, const theMapType &theMap, const theCubMapType &theCubMap0, const theCubMapType &theCubMap1, int_t skipIndices, const std::string &cacheFileName, bool &morseDecComputed, std::vector< int > &wrongIndices, std::vector< int > &skippedIndices, std::vector< int > &attractors, bool connOrbits, const double *leftMapParam, const double *rightMapParam, int paramCount, chomp::homology::timeused &timeSubdiv)
Computes a Conley-Morse decomposition of ChainRecSet (X).
int computeConleyIndex(theMorseDecompositionType &morseDec, int n, const double *offset, const double *width, int subdivDepth, const theMapType &theMap, const theCubMapType &theCubMap0, const theCubMapType &theCubMap1, int &subdivNonemptyInv, int &noIsolation, int &attractor)
Verifies that the provided Morse set can be used as a basis for a Conley index pair and computes the ...
Choice of configuration settings.
Conley index computation routines.
Converting a binary data buffer into a printable text and vice versa.
void text2data(const std::string &str, chomp::multiwork::mwData &data)
Decodes a prevously prepared text back into binary data.
std::string data2text(const chomp::multiwork::mwData &data)
Encodes the entire binary data into a text string (single line, printable characters only).
Writing a graph in the "dot" format.
std::ostream & writeDotGraph(std::ostream &out, const chomp::homology::diGraph<> &g, const std::vector< int_t > &sizes, const std::vector< theConleyIndexType > &indices, const std::vector< IndexEigenValues > &eigenValues, const std::vector< int > &wrongIndices, const std::vector< int > &skippedIndices, const std::vector< int > &attractors)
Writes the given Conley-Morse graph to the output stream in the format for the 'dot' program.
Eigenvalues of the Conley index map.
Cached Conley indices for a Morse decomposition.
Computation of the invariant part of a set of cubes.
void invariantPart(typeCubes &X, const chomp::homology::diGraph<> &g, chomp::homology::diGraph<> *gInv=0)
Computes X := Inv (X) using the algorithm by Bill Kalies and Hyunju Ban.
bool checkEmptyInv(const spcCubes &X, int subdivDepth, const double *offset, const double *width, const theMapType &theMap, const theCubMapType &theCubMap0, const theCubMapType &theCubMap1)
Verifies whether the invariant part of the given set is empty by applying a limited number of refinem...
void computeMapGraph(const typeCubes &X, typeGraph &g, const typeCubMap &theCubMap, bool cropping=true)
Computes the cubical map on 'X' and fills out the graph 'g'.
Caching Morse decompositions using compressed binary files.
void loadMorseDecCache(const char *fileName, theMorseDecompositionType &morseDec, std::vector< int > &wrongIndices, std::vector< int > &skippedIndices, std::vector< int > &attractors)
Loads a Morse decomposition from a binary file.
void saveMorseDecCache(const char *fileName, const theMorseDecompositionType &morseDec, const std::vector< int > &wrongIndices, const std::vector< int > &skippedIndices, const std::vector< int > &attractors)
Saves a Morse decomposition to a binary file.
const int refineDepth
The number of refinements that should be done if a Morse set with the trivial index is encountered or...
const int maxRefineSize0
The maximal allowed size of a set of cubes in the phase space which can be refined at the initial sub...
const int maxJoinConnection
The maximal size of a connecting orbit between two Morse sets which can be considered for joining.
const int maxJoinSize
The maximal number of cubes in a trivial Morse set for which an attempt is made to join this set with...
const bool ignoreIsolationForConleyIndex
Ignoring the isolation problem while computing the Conley index.
const int maxJoinDistance
The maximal allowed distance between two Morse sets which can be considered for joining.
const int maxImageVolume
The maximal allowed volume of the cubical image of a single box.
const int spaceDim
The dimension of the phase space.
const int initialDepth
The initial depth of subdivisions in the phase space.
const int maxImageDiameter
The maximal allowed diameter of the cubical image of a signle box.
const int paramCount
The number of all the parameters, both varying and fixed.
const int finalDepth
The final depth of subdivisions in the phase space.
const int maxRefineSize1
The maximal allowed size of a set of cubes in the phase space which can be refined at the subsequent ...
bool setConleyIndex(theMorseDecompositionType &morseDec, int n, int subdivDepth, const double *leftMapParam, const double *rightMapParam, int paramCount)
Assigns a prescribed Conley index to the given Morse set whose index could not be computed because of...
void processMorseDec(const MorseDecType &morseDec, const CubSetType &allCubes, const GraphType &g, const CubMapType &theCubMap, const CubMapType &, const std::string &cubesFilePrefix, const std::string &procFilePrefix)
Post-processes a Morse decomposition by computing a decomposition of each Morse set into cycle sets a...
Dummy post-processing of Morse decompositions.
Helper functions and an auxiliary class for space wrapping.
Customizable data types for the Conley-Morse graphs computation program.
Data types for the dynamical systems data structures.
MorseDecomposition< theCubMapType, spcCube, spcCubes > theMorseDecompositionType
The type of the Morse decomposition.
void resetRounding()
This function resets rounding switches of the processor and sets rounding to the nearest.
chomp::homology::hashedset< spcCube > spcCubes
The type of a set of cubes in the phase space.
int spcCoord
The type of coordinates of cubes in the phase space.
chomp::homology::tCubeBase< spcCoord > spcCube
The type of a cube in the phase space.
Utilites and helper functions.
std::string double2string(const double &x, int precision)
Creates a text representation of a floating-point number at the prescribed precision.
void subdivideCubes(const typeCubes &X, typeCubes &result)
Subdivides one set of cubes to another set of cubes with respect to twice finer grid.
OutStream & showRealCoords(OutStream &out, const CoordMinMax &range)
Shows the real coordinates of the coordinate range.
double cubesVolume(int_t nCubes, int subdiv)
Returns the volume of the given number of cubes in the phase space at the provided subdivision level.
bool fileExists(const char *filename)
Returns 'true' iff the given file exists and it is allowed to read it.
void enhanceCubes(spcCubes &X, int enhanceTimes, int subdivDepth)
Enhances the given set of cubes provided number of times.
bool checkIsolation(const spcCubes &theSet, int depth)
Verifies if the given set of cubes is contained in the interior of the phase space box.
void moveSomeToFront(HashSetType &X, int_t step)
Replaces the hashed set of objects with another one that contains the same objects,...