47#include "chomp/system/config.h"
48#include "chomp/system/textfile.h"
49#include "chomp/system/timeused.h"
50#include "chomp/system/arg.h"
72This is a program which computes a single Conley-Morse graph.\n\
73Ver. 0.06, August 22, 2014. Copyright (C) 2005-2014 by Pawel Pilarczyk.\n\
74This is free software. No warranty. Consult 'license.txt' for details.";
80This is the front-end program for the computation of a Conley-Morse graph\n\
81for a single parameter box. It is a supplementary program to 'cmgraphs',\n\
82and is capable of saving the results of all its computations to files.\n\
83The parameter box is identified by the integer coordinates of its minimal\n\
84vertex and corresponds to a box in the subdivision of the parameter area,\n\
85for example, if the entire parameter range [-1,1]x[-1,1] is divided into\n\
8620x20 boxes then '-b 0,19' corresponds to [-1.0,-0.9]x[0.9,1.0].\n\
87Command line arguments (the argument '-b' is mandatory):\n\
88-b x1,x2,...,xN - the integer coordinates of a parameter box to process,\n\
89-g file.txt - file name to save the text code for the Conley-Morse graph,\n\
90-s file.ind - file name to save/load cached Conley index information,\n\
91-p file.png - file name to save a PNG picture of the Morse decomposition,\n\
92-q prefix - prefix for file names to save Morse sets to as lists of cubes,\n\
93-o prefix - file name prefix for post-processing Morse sets information,\n\
94-t filename - file name with optimization information (read & append),\n\
95-u prefix - file name prefix for ODE integration optimization information,\n\
96-z file.bz2 - name of a temporary file with Morse decomposition cache,\n\
97--conn - compute connecting orbits between Morse sets (memory-consuming),\n\
98--full - use the full range of the phase space to plot Morse sets,\n\
99--log filename - file name to save all the text output of the program to,\n\
100--quiet - suppress any output written to the terminal,\n\
101--debug - display additional information useful for debugging,\n\
102--help - make the program show this brief help information and exit.\n\
103For more information ask the author at http://www.pawelpilarczyk.com/.";
111 const char *mapOptFileName,
const char *mapOptFileLocal,
112 const char *graphName,
const char *shareName,
113 const char *phaseSpaceName,
bool fullPhaseSpace,
114 const char *cubesFilePrefix,
const char *morseDecName,
115 const char *procFilePrefix,
116 bool connOrbits,
int skipIndices)
118 using chomp::homology::sout;
119 using chomp::homology::sbug;
122 std::ostringstream info;
124 sout <<
"\n" << info. str () <<
"\n";
132 std::string boxCoordStr (
"(" + std::string (boxCoordinates) +
")");
133 std::istringstream boxCoordStream (boxCoordStr);
134 boxCoordStream >> paramBox;
135 sout <<
"Computing Morse decomposition for " << paramBox <<
".\n";
147 paramBox. coord (curCoord);
153 sout <<
"Parameter values:";
156 sout <<
" [" << leftMapParam [i] <<
"," <<
157 rightMapParam [i] <<
"]";
163 theMap. setParam (leftMapParam, rightMapParam,
paramCount);
167 size_t prevSize (mapOptimization. size ());
168 if (mapOptFileName && *mapOptFileName)
170 std::ifstream in (mapOptFileName);
173 sout <<
"Reading map optimization data... ";
174 mapOptimization. loadData (in);
175 sout << (mapOptimization. size () - prevSize) <<
178 sout <<
"Optimizing the map... ";
179 std::vector<std::string> data;
180 mapOptimization. prepareData (data,
182 sout << data. size () <<
" hints... ";
183 for (std::vector<std::string>::const_iterator it =
184 data. begin (); it != data. end (); ++ it)
186 theMap. useOptInfo (*it);
197 theCubMap0. cache =
false;
200 theCubMap1. cache =
false;
205 bool morseDecComputed (
false);
208 std::vector<int> wrongIndices;
211 std::vector<int> skippedIndices;
214 std::vector<int> attractors;
218 (theMap, theCubMap0, theCubMap1, offset, width, skipIndices,
219 shareName ? shareName :
"",
220 phaseSpaceName ? phaseSpaceName :
"",
221 cubesFilePrefix ? cubesFilePrefix :
"",
222 morseDecName ? morseDecName :
"",
223 graphName ? graphName :
"",
224 procFilePrefix ? procFilePrefix :
"",
225 mapOptFileLocal ? mapOptFileLocal :
"",
226 morseDecComputed, wrongIndices,
227 skippedIndices, attractors, connOrbits,
234 int_t nMorseSets = morseDec -> count ();
235 for (int_t nSet = 0; nSet < nMorseSets; ++ nSet)
236 coordMinMax ((*morseDec) [nSet]);
237 if (coordMinMax. defined ())
239 sout <<
"The computed Morse sets are in " <<
240 coordMinMax <<
".\n";
241 sout <<
"Real coordinates: ";
255 phaseSpaceName && *phaseSpaceName)
257 sout <<
"Saving a picture of Morse sets to '" <<
258 phaseSpaceName <<
"'...\n";
262 const int xCoord (0);
267 const int yCoord (1);
276 if (
false && (graphName && *graphName))
279 chomp::homology::diGraph<> connGraph;
280 morseDec -> makegraph (connGraph);
281 chomp::homology::diGraph<> morseGraph;
282 transitiveReduction (connGraph, morseGraph);
285 int nSets = morseGraph. countVertices ();
286 std::vector<int_t> sizes (nSets);
287 for (
int n = 0; n < nSets; ++ n)
288 sizes [n] = (*morseDec) [n]. size ();
291 std::vector<theConleyIndexType> indices (nSets);
292 std::vector<IndexEigenValues> eigenValues (nSets);
293 for (
int n = 0; n < nSets; ++ n)
295 indices [n] = morseDec -> index (n);
299 sout <<
"Saving the Conley-Morse graph to '" <<
300 graphName <<
"'...\n";
301 std::ofstream graphFile (graphName);
303 indices, eigenValues,
304 wrongIndices, skippedIndices, attractors);
322 if (mapOptFileName && *mapOptFileName)
324 std::string line = theMap. getOptInfo ();
327 mapOptimization. addData (line,
true);
328 std::ofstream mapOptFile;
329 mapOptFile. open (mapOptFileName,
330 std::ios::out | std::ios::app);
331 mapOptimization. saveData (mapOptFile,
true);
336 sbug <<
"(Releasing the pointset data.)\n";
337 parCube::PointBase::reset ();
338 spcCube::PointBase::reset ();
339 chomp::homology::Cube::PointBase::reset ();
351int main (
int argc,
char *argv [])
353 using namespace chomp::homology;
357 char *boxCoordinates = 0;
358 char *mapOptFileName = 0;
359 char *mapOptFileLocal = 0;
362 char *phaseSpaceName = 0;
363 char *cubesFilePrefix = 0;
364 char *morseDecName = 0;
365 char *procFilePrefix = 0;
366 bool fullPhaseSpace =
false;
367 bool connOrbits =
false;
368 const int maxComments = 16;
370 char *comments [maxComments];
374 arg (a,
"b", boxCoordinates);
375 arg (a,
"t", mapOptFileName);
376 arg (a,
"u", mapOptFileLocal);
377 arg (a,
"g", graphName);
378 arg (a,
"s", shareName);
379 arg (a,
"p", phaseSpaceName);
380 arg (a,
"z", morseDecName);
381 arg (a,
"c", cubesFilePrefix);
382 arg (a,
"q", cubesFilePrefix);
383 arg (a,
"o", procFilePrefix);
384 arg (a,
"-comment", comments, nComments, maxComments);
385 arg (a,
"-skip-indices", skipIndices, 1);
386 argswitch (a,
"-full", fullPhaseSpace,
true);
387 argswitch (a,
"-conn", connOrbits,
true);
390 argstreamprepare (a);
391 int argresult = a. analyze (argc, argv);
400 sout <<
title <<
'\n';
405 sout <<
"Call with '--help' for help.\n";
420 program_time =
"Aborted after:";
425 mapOptFileName, mapOptFileLocal,
426 graphName, shareName,
427 phaseSpaceName, fullPhaseSpace, cubesFilePrefix,
428 morseDecName, procFilePrefix,
429 connOrbits, skipIndices);
432 program_time =
"Total time used:";
437 catch (
const char *msg)
439 sout <<
"ERROR: " << msg <<
'\n';
442 catch (
const std::exception &e)
444 sout <<
"ERROR: " << e. what () <<
'\n';
449 sout <<
"ABORT: An unknown error occurred.\n";
A class whose objects store, update and show coordinate ranges.
Eigenvalues of the Conley index map gathered by levels.
A generic map computation routine that computes a rigorous cubical multivalued map based on a functio...
static int maxImgDiam
The maximal image diameter encountered so far.
static int maxImgVol
The maximal image volume encountered so far.
This class defines a map derived from a sample difference equation.
A class whose objects are responsible for adjusting the integration parameters such as step size and ...
The Morse decoposition class.
int main(int argc, char *argv[])
The main procedure of the program.
const char * helpinfo
The help information about the program which is displayed if the program is launched without command-...
const char * title
The title of the program which is displayed every time the program is launcued.
int runSingleComp(const char *boxCoordinates, const char *mapOptFileName, const char *mapOptFileLocal, const char *graphName, const char *shareName, const char *phaseSpaceName, bool fullPhaseSpace, const char *cubesFilePrefix, const char *morseDecName, const char *procFilePrefix, bool connOrbits, int skipIndices)
Computation of Morse decompositions.
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.
Choice of configuration settings.
Writing configuration settings to an output stream.
void showConfigInfo(std::ostream &f, const char *prefix, const parCoord *maxIter)
Writes the configuration information to the given output stream.
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.
Map optimization data saving, retrieving, and sending.
const SpaceOffsetType spaceOffset
An imitation of an array which returns the offset of the rectangular area in the phase space which co...
const int paramDim
The dimension of the parameter space to iterate.
const int spaceDim
The dimension of the phase space.
const int paramCount
The number of all the parameters, both varying and fixed.
const SpaceWidthType spaceWidth
An imitation of an array which returns the width of the rectangular area in the phase space which con...
const int finalDepth
The final depth of subdivisions in the phase space.
Plotting a Morse decomposition in a PNG picture.
void plotMorseDecompositionPNG(const MorseDecType &m, const char *filename, int xCoord, int yCoord, int size=0, bool colorBar=true)
Saves all the Morse sets in the provided Morse decomposition to a PNG file.
Customizable data types for the Conley-Morse graphs computation program.
Data types for the dynamical systems data structures.
chomp::homology::tCubeFix< paramDim, parCoord > parCube
The type of a cube in the set of parameters.
short int parCoord
The type of coordinates of cubes in the set of parameters.
Utilites and helper functions.
OutStream & showRealCoords(OutStream &out, const CoordMinMax &range)
Shows the real coordinates of the coordinate range.
void computeParam(const intType *curCoord, double *leftMapParam, double *rightMapParam)
Computes the real coordinates of the parameter cube which corresponds to the given box.