33#ifndef _CMGRAPHS_ODETIMET_H_
34#define _CMGRAPHS_ODETIMET_H_
45#include "chomp/system/config.h"
46#include "chomp/system/textfile.h"
47#include "chomp/multiwork/mwdata.h"
58#include "capd/vectalg/lib.h"
59#include "capd/dynset/lib.h"
60#include "capd/dynsys/lib.h"
61#include "capd/dynsys/Taylor.hpp"
62#include "capd/dynsys/TaylorHOE.hpp"
66#define CAPD_USER_NAMESPACE capd
67#define CAPD_DEFAULT_DIMENSION spaceDim
68#include "capd/fdcapdlib.h"
69#undef CAPD_USER_NAMESPACE
70#undef CAPD_DEFAULT_DIMENSION
102 void setParam (
const double *left,
const double *right,
int n);
108 const spcCoord *coord,
int subdiv)
const;
117 int dim,
int stepsBetweenChecks);
121 template <
class Array1,
class Array2>
122 static void setPhaseSpace (
const Array1 &offset,
const Array2 &width,
123 int dim,
int subdivDepth,
int stepsBetweenChecks = 2);
133 bool adjust (
bool successful,
int subdiv);
179 typedef capd::dynsys::TaylorHOE<IntervalMapType>
TaylorType;
237 bool checkOutside (
double *left,
double *right,
int dim)
const;
241 TaylorType &theTaylorMethod,
int steps,
int dim)
const;
257 double *left =
new double [dim];
258 double *right =
new double [dim];
259 std::vector<double>::const_iterator boxIter =
261 for (
int d = 0; d < dim; ++ d)
263 left [d] = *(boxIter ++);
264 right [d] = *(boxIter ++);
273 int order,
double step,
int n):
274 boundingBox (0), boundingBoxDim (0),
275 mapFormula (formula), odeIntegrParam (order, step, n),
276 theMap (0), checkEvery (0), integrations (0)
286 if (
mapFormula. find (
"par:") != std::string::npos)
288 chomp::homology::sout <<
"WARNING: The phrase "
289 "\"par:\" is not supported in CAPD 2.9.\n";
293 if (
mapFormula. find (
"par:") == std::string::npos)
295 chomp::homology::sout <<
"WARNING: Couldn't find the phrase "
296 "\"par:\" in the map formula.\n";
324 paramName [2] =
'\0';
326 for (
int i = 0; i < n; ++ i)
330 paramName [1] =
static_cast<char> (
'a' + i);
331 theMap -> setParameter (paramName, paramInterval);
333 theMap -> setParameter (i, paramInterval);
344 using chomp::homology::sbug;
353 sbug <<
"OdeTimeT integrations: " <<
integrations <<
".\n";
415 TaylorType &theTaylorMethod,
int steps,
int dim)
const
418 for (
int step = 0; step < steps; ++ step)
421 lohnerSet. move (theTaylorMethod);
441 for (
int i = 0; i < dim; ++ i)
443 double middle = (x [i]. leftBound () +
444 x [i]. rightBound ()) / 2;
452 int numberOfSteps (0);
460 theTaylorMethod. setStep (
IntervalType (stepSize, stepSize));
474 catch (
const std::exception &e)
479 using chomp::homology::sbug;
480 sbug <<
"FAILURE:\n" << e. what () <<
"\n";
488 using chomp::homology::sbug;
489 sbug <<
"[Integration failure at subdiv depth " <<
493 sbug <<
"Trouble source cube: [";
494 for (
int i = 0; i < dim; ++ i)
495 sbug << (i ?
"," :
"") << coord [i];
497 sbug <<
"Real coords: " << x <<
".\n";
501 sbug <<
"Trouble source box: " << x <<
".\n";
509 throw "Unable to integrate the ODE - the set became too large.";
514 const double *right,
int dim,
int stepsBetweenChecks)
516 using chomp::homology::sbug;
522 sbug <<
"* Setting the bounding box for the ODE solver:\n";
523 for (
int i = 0; i < dim; ++ i)
525 sbug << (i ?
" x [" :
"* [") << left [i] <<
"," <<
527 *(boxPtr ++) = left [i];
528 *(boxPtr ++) = right [i];
535template <
class Array1,
class Array2>
537 const Array2 &width,
int dim,
int subdivDepth,
538 int stepsBetweenChecks)
541 if ((dim <= 0) || (subdivDepth <= 0) ||
542 (subdivDepth >=
static_cast<int> (8 *
sizeof (
int) - 1)))
549 int intWidth = 1 << subdivDepth;
552 for (
int d = 0; d < dim; ++ d)
554 double widthFraction = (width [d] / intWidth) * 1.1;
555 double left = offset [d] - widthFraction;
556 double right = offset [d] + width [d] + widthFraction;
572 bool outside =
false;
574 for (
int i = 0; i < dim; ++ i)
576 if (x [i] <= *boxPtr)
582 if (x [i] >= *boxPtr)
599 bool outside =
false;
601 for (
int i = 0; i < dim; ++ i)
603 if (right [i] <= *boxPtr)
605 left [i] = right [i] = *boxPtr;
609 if (left [i] >= *boxPtr)
611 left [i] = right [i] = *boxPtr;
625 bool outside =
false;
627 for (
int i = 0; i < dim; ++ i)
629 if (v [i]. rightBound () < *boxPtr)
635 if (v [i]. leftBound () > *boxPtr)
This class defines a map for the nonlinear density dependent overcompensatory Leslie population model...
double getTimeStep(int subdiv) const
Returns an approximation of the currently recommended integration time t for the time-t map at the gi...
~MapOdeTimeT()
The destructor.
int checkEvery
The number of steps after which the box should be checked if it is still contained in the bounding bo...
void compute(const IntervalVectorType &x, RectSetType &y, int dim, const spcCoord *coord, int subdiv) const
Computes a rectangular set that is an outer enclosure of the image of the given box.
void loadInternals(chomp::multiwork::mwData &data)
Retrieves the internal paramters and other data of the map from the mwData structure.
void iterateLohnerSet(RectSetType &lohnerSet, TaylorType &theTaylorMethod, int steps, int dim) const
Iterates the given Lohner set, using the Taylor method objects.
void setBoundingBox(const double *left, const double *right, int dim, int stepsBetweenChecks)
Sets a bounding box for the area of interest.
bool adjust(bool successful, int subdiv)
Adjusts parameters if necessary after a successful computation or after an unsuccessful computation o...
MapOdeTimeT(const std::string &formula, int order, double step, int n)
The constructor which takes the formula for the ODE in the format used in the CAPD library.
capd::IMatrix IntervalMatrixType
The interval matrix type.
int boundingBoxDim
The dimension of the bounding box.
OdeIntegrParam odeIntegrParam
An object for adjusting ODE integration parameters.
MapOdeTimeT & operator=(const MapOdeTimeT &)
The assignment operator should not be used.
static void setPhaseSpace(const Array1 &offset, const Array2 &width, int dim, int subdivDepth, int stepsBetweenChecks=2)
Sets the phase space for an automatic generation of bounding boxes.
static int defaultCheckEvery
The default number of steps to check the bounding box.
long integrations
The numbers of successful integrations.
IntervalMapType * theMap
The map object to be used in the Taylor method object.
std::string mapFormula
The formula for the map in the text format used in CAPD.
static std::vector< double > defaultBoundingBox
The default bounding box to be used if no bounding box is set.
void setParam(const double *left, const double *right, int n)
Sets the parameters to the given intervals defined by their left and right coordinates.
capd::IMap IntervalMapType
The type of a map to be used for the Taylor method.
MapOdeTimeT(const MapOdeTimeT &)
The copy constructor should not be used.
void saveInternals(chomp::multiwork::mwData &data) const
Saves the internal parameters and other data of the map to the mwData structure.
std::string getOptInfo() const
Gets a single line of information on optimization of the computation of the map, so that it can be us...
void useOptInfo(const std::string &info)
Uses a prevously saved line of information on optimization of the computation of the map for the same...
capd::dynsys::Solver< IntervalMapType > TaylorType
The type of fixed step control.
double * boundingBox
A bounding box for the area where the trajectories are computed.
bool checkOutside(double *x, int dim) const
Verifies if the given point is outside the bounding box set with the method "setBoundingBox".
void setDefaultBoundingBox()
Sets the bounding box to the default one, as defined when setting the phase space.
This is an abstract class which defines the interface to other classes that describe maps for the use...
virtual void setParam(const double *left, const double *right, int n)
Sets the parameters to the given intervals defined by their left and right coordinates.
void loadInternals(chomp::multiwork::mwData &data)
Retrieves the internal paramters and other data of the map from the mwData structure.
void saveInternals(chomp::multiwork::mwData &data) const
Saves the internal parameters and other data of the map to the mwData structure.
A class whose objects are responsible for adjusting the integration parameters such as step size and ...
Data conversion for sending/receiving: std::vectors and hashed sets of any objects.
An abstract tight map type that computes the image of a box in terms of a rectangular set from the CA...
ODE integration parameters: guessing, adjusting, saving.
Data types for interval arithmetic.
void resetRounding()
This function resets rounding switches of the processor and sets rounding to the nearest.
bool testIntervals(bool throwException=false)
Testing interval arithmetic.
capd::DInterval IntervalType
The type of an interval (from the CAPD library 2.9/3.0 beta).
Data type for the rectangular (Lohner-type) set from CAPD.
capd::C0HORect2Set RectSetType
The type of the rectangular set to use.
capd::IVector IntervalVectorType
The interval vector type for creating the rectangular set by means of its center + box.
int spcCoord
The type of coordinates of cubes in the phase space.