/*------------------------------------------------------------------------------ SMS3reflect class Animal This version modified to include a compile-time option for treating 'no data' regions as reflective Exhibits the behaviour of moving to a neighbouring square on a gridded landscape depending on the animal's perceptual range (PR), its directional persistence (DP) (i.e. the tendency to continue in its recent direction of travel - formerly called directional bias - but now extended to encompass a memory of the most recent N locations (N<=14)), the cost values of the landscape within the PR, the method of evaluating (averaging) the costs and, optionally, a goal location. The actual move to one of 8 neighbouring squares is stochastic, and dependent on probabilities calculated using the attributes described above. SMS employs random number generators developed and distributed by Agner Fog (http://www.agner.org/random/) For further details of SMS, please see: Palmer, S.C.F., Coulon, A. & Travis, J.M.J. (2011) Introducing a ‘stochastic movement simulator’ for estimating habitat connectivity. Methods in Ecology and Evolution, 2, 258-268. Author: Steve Palmer, University of Aberdeen Last updated: 15 August 2012 ------------------------------------------------------------------------------*/ #ifndef AnimalH #define AnimalH #include #include #include "math.h" #include "stocc.h" using namespace std; #include "Parameters.h" #include "Landscape.h" struct movedata { double dist; double cost; }; //============================================================================== class Animal { public: Animal( // Constructor - Creates new animal not based on another int, // initial location - X co-ordinate int, // initial location - Y co-ordinate int, // year double // probability that animal is female ); Animal( // Copy constructor - Essentially reproduce function int, // year double, // probability that animal is female const Animal* // pointer to parent animal ); int get_id(void); int get_age(void); int get_natalyear(void); int get_sex(void); int get_status(void); int get_success(void); int get_pr(void); int get_prmethod(void); double get_dp(void); double get_gb(void); int get_memsize(void); locn get_location(void); locn get_natalloc(void); locn get_goal(void); int get_goaltype(void); void set_status(int); void set_success(int); void set_location(int,int); // X and Y co-ordinates of new location void set_goal( int, // goal type - see below int,int // X and Y co-ordinates of goal ); void update_memory(int,int); void age_incr(void); void set_movement( // set all movement parameters int, // PR int, // PR method (1,2,3) double, // DP double, // GB int, // MS int // no-data cost ); void set_dp(double); // set dp only void relmove(int,int); // relative displacement (cells) in X and Y directions movedata nbrmove( // Move to a neighbouring cell according to the SMS algorithm Landscape*, // pointer to landscape int // step number ); private: static int AnimalCounter; // Used to create ID, held by class not members of class array3x3d get_sim_dir(void); array3x3d get_goal_bias(void); array3x3d get_hab_matrix(Landscape*,int,int); array3x3d calc_weightings(double,double); int id; int age; int natal_year; int sex; // 0 = male, 1 = female int natal_x,natal_y; // birth location int status; // 0 = juv, 1 = immature, 2 = adult int x,y; // current location of individual int goaltype; // 0 = no goal, 1 = attracting goal, 2 = repelling goal int goalx,goaly; // location towards which or away from which animal is aiming int success; // was succesful breeder year before int pr; // perceptual range (PR) (in units of landscape cells) int prmethod; // method used to calculate effective cost within PR // 1 = arithmetic mean, 2 = harmonic mean, 3 = weighted arithmetic mean double dp; // directional persistence (DP) tendency (1.0 = none --> ~10 very high) // NB called 'directional bias' (wrongly) in MEE paper double gb; // goal bias (GB) tendency (1.0 = none --> ~5 very high) int memorysize; // no. of steps held in memory (MS) std::queue memory; // memory of last N squares visited int nodatacost; // cost used if a 'nodata' cell is encountered }; //============================================================================== #endif