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