The Conley-Morse Graphs Software
m_whales.h
Go to the documentation of this file.
1/////////////////////////////////////////////////////////////////////////////
2///
3/// @file m_whales.h
4///
5/// The map for the whales population model.
6///
7/// This map defines a simple 2D nonlinear map
8/// for modeling some whales population.
9///
10/// @author Pawel Pilarczyk
11///
12/////////////////////////////////////////////////////////////////////////////
13
14// Copyright (C) 1997-2014 by Pawel Pilarczyk.
15//
16// This file is part of my research software package. This is free software:
17// you can redistribute it and/or modify it under the terms of the GNU
18// General Public License as published by the Free Software Foundation,
19// either version 3 of the License, or (at your option) any later version.
20//
21// This software is distributed in the hope that it will be useful,
22// but WITHOUT ANY WARRANTY; without even the implied warranty of
23// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24// GNU General Public License for more details.
25//
26// You should have received a copy of the GNU General Public License
27// along with this software; see the file "license.txt". If not,
28// please, see <https://www.gnu.org/licenses/>.
29
30// Started on February 9, 2008. Last revision: September 11, 2011.
31
32
33#ifndef _CMGRAPHS_WHALES_H_
34#define _CMGRAPHS_WHALES_H_
35
36
37// some standard header files
38#include <cmath>
39
40// include local header files
41#include "maptype.h"
42#include "typeintv.h"
43
44// for debugging
45#include "chomp/system/textfile.h"
46
47
48// --------------------------------------------------
49// ------------- a population model map -------------
50// --------------------------------------------------
51
52/// This class defines a map for the nonlinear density dependent
53/// overcompensatory Leslie population model.
54/// The interpretation of parameters depends on the dimension.
55class MapWhales: public MapType
56{
57public:
58 /// The default constructor.
59 MapWhales ();
60
61 /// Computes the image of a box whose left and right coordinates
62 /// are given. Fills in the images with the left and right
63 /// coordinates of the image box.
64 void compute (const double *xleft, const double *xright,
65 double *yleft, double *yright, int dim,
66 const spcCoord *coord, int subdiv) const;
67
68}; /* class MapWhales */
69
70// --------------------------------------------------
71
73{
75 return;
76} /* MapWhales::MapWhales */
77
78inline void MapWhales::compute (const double *xleft, const double *xright,
79 double *yleft, double *yright, int dim, const spcCoord *, int) const
80{
81 // this formula is programmed for the phase space of dim 2 only
82 if (dim != 2)
83 throw "Whales population model: dim = 2 only!";
84
85 // determine the number of adults and juveniles
86 IntervalType adults (xleft [0], xright [0]);
87 IntervalType juveniles (xleft [1], xright [1]);
88
89 // prepare the interval version of the number one
90 IntervalType one (1.0, 1.0);
91
92 // determine the parameters
93 IntervalType survivalRateA (getLeftParam (0), getRightParam (0));
94 IntervalType survivalRateJ (getLeftParam (1), getRightParam (1));
97
98 // determine modifications of the model if any
99 int options = static_cast<int> (getLeftParam (4));
100 if (options & 0x010)
101 survivalRateJ = one - survivalRateA;
102 else if (options & 0x020)
103 survivalRateJ = survivalRateA;
104 if (options & 0x100)
105 {
106 // use the cached value of beta if possible
107 static IntervalType alphaSaved (0.0, 0.0);
108 static IntervalType betaSaved (0.0, 0.0);
109 if ((alphaSaved. leftBound () == alpha. leftBound ()) &&
110 (alphaSaved. rightBound () == alpha. rightBound ()))
111 {
112 beta = betaSaved;
113 }
114
115 // compute the approximate value of beta if alpha is a point
116 else if (alpha. leftBound () == alpha. rightBound ())
117 {
118 static double e = M_E; //std::exp (1.0);
119 double b = alpha. leftBound () / e;
120 beta = IntervalType (b, b);
121 alphaSaved = alpha;
122 betaSaved = beta;
123 }
124
125 // compute the interval vector for beta otherwise
126 else
127 {
128 static IntervalType e = exp (one);
129 beta = alpha / e;
130 alphaSaved = alpha;
131 betaSaved = beta;
132 }
133 }
134
135 // compute the intervals of the output values
136 IntervalType newAdults (survivalRateJ * juveniles +
137 survivalRateA * adults);
138 IntervalType newJuveniles (alpha * adults * exp (-beta * adults));
139
140 // copy the bounds of the intervals to the output variables
141 yleft [0] = newAdults. leftBound ();
142 yright [0] = newAdults. rightBound ();
143 yleft [1] = newJuveniles. leftBound ();
144 yright [1] = newJuveniles. rightBound ();
145
146 // make a correction of non-positive values to ensure isolation
147// for (int i = 0; i < dim; ++ i)
148// {
149// if (yleft [i] <= 0)
150// yleft [i] = 1e-10;
151// if (yright [i] < yleft [i])
152// yright [i] = yleft [i];
153// }
154
155 // swich the rounding direction to the neutral one
156 resetRounding ();
157 return;
158} /* MapWhales::compute */
159
160
161#endif // _CMGRAPHS_WHALES_H_
162
This is an abstract class which defines the interface to other classes that describe maps for the use...
Definition: maptype.h:59
const double & getLeftParam(int n) const
Returns the left value of the given parameter.
Definition: maptype.h:196
const double & getRightParam(int n) const
Returns the right value of the given parameter.
Definition: maptype.h:203
This class defines a map for the nonlinear density dependent overcompensatory Leslie population model...
Definition: m_whales.h:56
void compute(const double *xleft, const double *xright, double *yleft, double *yright, int dim, const spcCoord *coord, int subdiv) const
Computes the image of a box whose left and right coordinates are given.
Definition: m_whales.h:78
MapWhales()
The default constructor.
Definition: m_whales.h:72
An abstract map type.
Data types for interval arithmetic.
void resetRounding()
This function resets rounding switches of the processor and sets rounding to the nearest.
Definition: typeintv.h:65
bool testIntervals(bool throwException=false)
Testing interval arithmetic.
Definition: typeintv.h:82
capd::DInterval IntervalType
The type of an interval (from the CAPD library 2.9/3.0 beta).
Definition: typeintv.h:49
int spcCoord
The type of coordinates of cubes in the phase space.
Definition: typespace.h:50