Gadget
migration.h
Go to the documentation of this file.
1 #ifndef migration_h
2 #define migration_h
3 
4 #include "livesonareas.h"
5 #include "actionattimes.h"
6 #include "keeper.h"
7 #include "intmatrix.h"
8 #include "modelvariable.h"
9 #include "rectangle.h"
10 #include "doublematrixptrvector.h"
11 #include "formulamatrixptrvector.h"
12 #include "migrationareaptrvector.h"
13 
22 class Migration : public HasName, protected LivesOnAreas {
23 public:
29  Migration(const IntVector& areas, const char* givenname);
33  virtual ~Migration() {};
37  virtual void Reset() = 0;
42  virtual void Print(ofstream& outfile) = 0;
48  virtual const DoubleMatrix& getMigrationMatrix(const TimeClass* const TimeInfo) = 0;
53  const DoubleVector& getPenalty() const { return penalty; };
59  virtual int isMigrationStep(const TimeClass* const TimeInfo) = 0;
60 protected:
65 };
66 
71 class MigrationNumbers : public Migration {
72 public:
83  const AreaClass* const Area, const TimeClass* const TimeInfo,
84  const char* givenname, Keeper* const keeper);
92  void Reset();
97  void Print(ofstream& outfile);
103  const DoubleMatrix& getMigrationMatrix(const TimeClass* const TimeInfo);
109  virtual int isMigrationStep(const TimeClass* const TimeInfo);
110 private:
116  void readTimeStepData(CommentStream& infile, const TimeClass* const TimeInfo);
123  void readGivenRatios(CommentStream& infile, Keeper* const keeper, const AreaClass* const Area);
129  void readGivenMatrices(CommentStream& infile, Keeper* const keeper);
134  void setMatrixName(char* name);
140  int useMatrix(char* name);
144  void checkMatrixIndex();
148  CharPtrVector allmatrixnames;
152  CharPtrVector usedmatrixnames;
156  IntVector timeindex;
160  IntMatrix checkvalues;
164  DoubleMatrixPtrVector calcMigration;
168  FormulaMatrixPtrVector readMigration;
169 };
170 
175 class MigrationFunction : public Migration {
176 public:
187  const AreaClass* const Area, const TimeClass* const TimeInfo,
188  const char* givenname, Keeper* const keeper);
196  void Reset();
201  void Print(ofstream& outfile);
207  const DoubleMatrix& getMigrationMatrix(const TimeClass* const TimeInfo);
213  virtual int isMigrationStep(const TimeClass* const TimeInfo);
214 private:
222  void readAreaData(CommentStream& infile, const AreaClass* const Area,
223  const TimeClass* const TimeInfo, Keeper* const keeper);
224  int updateVariables(const TimeClass* const TimeInfo);
225  void recalcMatrix();
226  double getMigrationFunction(Rectangle* fromRec, Rectangle* toRec);
227  double f1x(double w, double u, double D, double beta);
228  double f2x(double w, double u, double D, double beta);
229  DoubleMatrix calcMigration;
233  ModelVariable diffusion;
237  ModelVariable driftx;
241  ModelVariable drifty;
242  double lambda;
243  double delta;
247  MigrationAreaPtrVector oceanareas;
248 };
249 
250 #endif
This is the class used to store information about the areas used for the current model.
Definition: areatime.h:18
This class implements a dynamic vector of char values.
Definition: charptrvector.h:8
This is the class used to strip comments (and whitespace) from any input stream.
Definition: commentstream.h:40
This class implements a dynamic vector of DoubleMatrix values.
Definition: doublematrixptrvector.h:10
This class implements a dynamic vector of DoubleVector values.
Definition: doublematrix.h:11
This class implements a dynamic vector of double values.
Definition: doublevector.h:11
This class implements a dynamic vector of FormulaMatrix values.
Definition: formulamatrixptrvector.h:10
This is the base class for any object that has a name.
Definition: hasname.h:10
This class implements a dynamic vector of IntVector values.
Definition: intmatrix.h:10
This class implements a dynamic vector of int values.
Definition: intvector.h:11
This is the class used to store information about the variables that are used in model simulation.
Definition: keeper.h:17
This is the class used to store information about the areas an object is defined on for the current m...
Definition: livesonareas.h:10
IntVector areas
This is the IntVector of internal areas that the object is defined on.
Definition: livesonareas.h:51
This class implements a dynamic vector of MigrationArea values.
Definition: migrationareaptrvector.h:10
This is the class used to calculate the migration of a stock within the model based on a migration fu...
Definition: migration.h:175
virtual int isMigrationStep(const TimeClass *const TimeInfo)
This will check if the migration process will take place on the current timestep.
Definition: migration.cc:581
~MigrationFunction()
This is the default MigrationFunction destructor.
Definition: migration.cc:508
MigrationFunction(CommentStream &infile, const IntVector &areas, const AreaClass *const Area, const TimeClass *const TimeInfo, const char *givenname, Keeper *const keeper)
This is the MigrationFunction constructor.
Definition: migration.cc:424
const DoubleMatrix & getMigrationMatrix(const TimeClass *const TimeInfo)
This will return the migration matrix that has been calculated.
Definition: migration.cc:525
void Print(ofstream &outfile)
This function will print the migration data.
Definition: migration.cc:514
void Reset()
This function will reset the migration data.
Definition: migration.cc:574
This is the class used to calculate the migration of a stock within the model based on migration rati...
Definition: migration.h:71
virtual int isMigrationStep(const TimeClass *const TimeInfo)
This will check if the migration process will take place on the current timestep.
Definition: migration.cc:415
void Reset()
This function will reset the migration data.
Definition: migration.cc:354
const DoubleMatrix & getMigrationMatrix(const TimeClass *const TimeInfo)
This will return the migration matrix that has been calculated.
Definition: migration.cc:337
MigrationNumbers(CommentStream &infile, const IntVector &areas, const AreaClass *const Area, const TimeClass *const TimeInfo, const char *givenname, Keeper *const keeper)
This is the MigrationNumbers constructor.
Definition: migration.cc:23
~MigrationNumbers()
This is the default MigrationNumbers destructor.
Definition: migration.cc:68
void Print(ofstream &outfile)
This function will print the migration data.
Definition: migration.cc:319
This is the base class used to calculate the migration of a stock within the model.
Definition: migration.h:22
const DoubleVector & getPenalty() const
This will return the penalty that has been calculated due to invalid migration.
Definition: migration.h:53
virtual int isMigrationStep(const TimeClass *const TimeInfo)=0
This will check if the migration process will take place on the current timestep.
virtual void Reset()=0
This function will reset the migration data.
DoubleVector penalty
This is the DoubleVector used to store the migration penalty information.
Definition: migration.h:64
virtual ~Migration()
This is the default Migration destructor.
Definition: migration.h:33
Migration(const IntVector &areas, const char *givenname)
This is the default Migration constructor.
Definition: migration.cc:13
virtual const DoubleMatrix & getMigrationMatrix(const TimeClass *const TimeInfo)=0
This will return the migration matrix that has been calculated.
virtual void Print(ofstream &outfile)=0
This function will print the migration data.
This is the base class used to calculate the value of variables used in the model simulation that are...
Definition: modelvariable.h:19
This is the class used to store the co-ordinates and size of an area, used when calculating the migra...
Definition: rectangle.h:11
This is the class used to store information about the timesteps used for the current model.
Definition: areatime.h:87