1 /* 2 * cResource.h 3 * Avida 4 * 5 * Called "resource.hh" prior to 12/5/05. 6 * Copyright 1999-2011 Michigan State University. All rights reserved. 7 * Copyright 1993-2003 California Institute of Technology. 8 * 9 * 10 * This file is part of Avida. 11 * 12 * Avida is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License 13 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 14 * 15 * Avida is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public License along with Avida. 19 * If not, see <http://www.gnu.org/licenses/>. 20 * 21 */ 22 23 /*! Classes to hold global and local information about a given resource */ 24 25 #ifndef cResource_h 26 #define cResource_h 27 28 #ifndef cString_h 29 #include "cString.h" 30 #endif 31 #ifndef tArray_h 32 #include "tArray.h" 33 #endif 34 35 36 /*! class to hold resource information for individual cells (mini-chemostats) */ 37 38 class cCellResource 39 { 40 private: 41 int cell_id; 42 double initial; 43 double inflow; 44 double outflow; 45 46 public: 47 cCellResource(); 48 cCellResource(int _cell_id, double _initial, double _inflow, double _outflow); GetId()49 int GetId() const { return cell_id; } GetInitial()50 double GetInitial() const { return initial; } GetInflow()51 double GetInflow() const { return inflow; } GetOutflow()52 double GetOutflow() const { return outflow; } SetInitial(double _initial)53 void SetInitial(double _initial) { initial = _initial; } SetInflow(double _inflow)54 void SetInflow(double _inflow) { inflow = _inflow; } SetOutflow(double _outflow)55 void SetOutflow(double _outflow) { outflow = _outflow; } 56 }; 57 58 /* class to hold all information for a single resource */ 59 60 class cResource 61 { 62 private: 63 cString name; 64 int id; // 0-based, order of appearance in environment file; resource library index 65 int index; // 0-based, order of appearance of THIS TYPE of resource in environment file; resource count index 66 double initial; 67 double inflow; 68 double outflow; 69 int geometry; 70 int inflowX1; 71 int inflowX2; 72 int inflowY1; 73 int inflowY2; 74 int outflowX1; 75 int outflowX2; 76 int outflowY1; 77 int outflowY2; 78 double xdiffuse; 79 double xgravity; 80 double ydiffuse; 81 double ygravity; 82 bool deme_resource; 83 bool org_resources; 84 bool energy_resource; // only implemented for spacial resource 85 bool dynamic_resource; //JW 86 int peaks; //JW 87 double min_height; //JW 88 double height_range; //JW 89 double min_radius; //JW 90 double radius_range; //JW 91 double ah; //JW 92 double ar; //JW 93 double acx; //JW 94 double acy; //JW 95 double hstepscale; //JW 96 double rstepscale; //JW 97 double cstepscalex; //JW 98 double cstepscaley; //JW 99 double hstep; //JW 100 double rstep; //JW 101 double cstepx; //JW 102 double cstepy; //JW 103 int update_dynamic; //JW 104 int m_peakx; 105 int m_peaky; 106 int m_height; 107 int m_spread; 108 double m_plateau; 109 int m_decay; 110 int m_max_x; 111 int m_max_y; 112 int m_min_x; 113 int m_min_y; 114 double m_move_a_scaler; 115 int m_updatestep; 116 int m_halo; 117 int m_halo_inner_radius; 118 int m_halo_width; 119 int m_halo_anchor_x; 120 int m_halo_anchor_y; 121 int m_move_speed; 122 double m_plateau_inflow; 123 double m_plateau_outflow; 124 double m_cone_inflow; 125 double m_cone_outflow; 126 double m_gradient_inflow; 127 int m_is_plateau_common; 128 double m_floor; 129 int m_habitat; 130 int m_min_size; 131 int m_max_size; 132 int m_config; 133 int m_count; 134 double m_resistance; 135 double m_init_plat; 136 double m_threshold; 137 int m_refuge; 138 bool isgradient; 139 double m_predator_odds; 140 bool m_predator; 141 double m_guard_juvs_per; 142 double m_prob_detect; 143 tArray<cCellResource> cell_list; 144 tArray<int> cell_id_list; 145 bool hgt_metabolize; 146 bool collectable; 147 148 cResource(); // @not_implemented 149 150 public: 151 cResource(const cString& _name, int _id); ~cResource()152 ~cResource() { ; } 153 GetName()154 const cString & GetName() const { return name; } GetID()155 int GetID() const { return id; } GetIndex()156 int GetIndex() const { return index; } GetInitial()157 double GetInitial() const { return initial; } GetInflow()158 double GetInflow() const { return inflow; } GetOutflow()159 double GetOutflow() const { return outflow; } GetGeometry()160 int GetGeometry() const { return geometry; } GetInflowX1()161 int GetInflowX1() const { return inflowX1; } GetInflowX2()162 int GetInflowX2() const { return inflowX2; } GetInflowY1()163 int GetInflowY1() const { return inflowY1; } GetInflowY2()164 int GetInflowY2() const { return inflowY2; } GetOutflowX1()165 int GetOutflowX1() const { return outflowX1; } GetOutflowX2()166 int GetOutflowX2() const { return outflowX2; } GetOutflowY1()167 int GetOutflowY1() const { return outflowY1; } GetOutflowY2()168 int GetOutflowY2() const { return outflowY2; } GetXDiffuse()169 double GetXDiffuse() const { return xdiffuse; } GetXGravity()170 double GetXGravity() const { return xgravity; } GetYDiffuse()171 double GetYDiffuse() const { return ydiffuse; } GetYGravity()172 double GetYGravity() const { return ygravity; } GetDemeResource()173 bool GetDemeResource() const { return deme_resource; } GetEnergyResource()174 bool GetEnergyResource() const { return energy_resource; } GetDynamicResource()175 bool GetDynamicResource() const { return dynamic_resource; } GetPeaks()176 int GetPeaks() const { return peaks; } //JW GetMinHeight()177 double GetMinHeight() const { return min_height; } //JW GetHeightRange()178 double GetHeightRange() const { return height_range; } //JW GetMinRadius()179 double GetMinRadius() const { return min_radius; } //JW GetRadiusRange()180 double GetRadiusRange() const { return radius_range; } //JW GetAh()181 double GetAh() const { return ah; } //JW GetAr()182 double GetAr() const { return ar; } //JW GetAcx()183 double GetAcx() const { return acx; } //JW GetAcy()184 double GetAcy() const { return acy; } //JW GetHStepscale()185 double GetHStepscale() const { return hstepscale; } //JW GetRStepscale()186 double GetRStepscale() const { return rstepscale; } //JW GetCStepscaleX()187 double GetCStepscaleX() const { return cstepscalex; } //JW GetCStepscaleY()188 double GetCStepscaleY() const { return cstepscaley; } //JW GetHStep()189 double GetHStep() const { return hstep; } //JW GetRStep()190 double GetRStep() const { return rstep; } //JW GetCStepX()191 double GetCStepX() const { return cstepx; } //JW GetCStepY()192 double GetCStepY() const { return cstepy; } //JW GetUpdateDynamic()193 int GetUpdateDynamic() const { return update_dynamic; } //JW GetPeakX()194 int GetPeakX() { return m_peakx; } GetPeakY()195 int GetPeakY() { return m_peaky; } GetHeight()196 int GetHeight() { return m_height; } GetSpread()197 int GetSpread() { return m_spread; } GetPlateau()198 double GetPlateau() { return m_plateau; } GetDecay()199 int GetDecay() { return m_decay; } GetMaxX()200 int GetMaxX() { return m_max_x; } GetMaxY()201 int GetMaxY() { return m_max_y; } GetMinX()202 int GetMinX() { return m_min_x; } GetMinY()203 int GetMinY() { return m_min_y; } GetAscaler()204 double GetAscaler() { return m_move_a_scaler; } GetUpdateStep()205 int GetUpdateStep() const { return m_updatestep; } //JW GetHalo()206 int GetHalo() { return m_halo;} GetHaloInnerRadius()207 int GetHaloInnerRadius() { return m_halo_inner_radius; } GetHaloWidth()208 int GetHaloWidth() { return m_halo_width; } GetHaloAnchorX()209 int GetHaloAnchorX() { return m_halo_anchor_x; } GetHaloAnchorY()210 int GetHaloAnchorY() { return m_halo_anchor_y; } GetMoveSpeed()211 int GetMoveSpeed() { return m_move_speed; } GetPlateauInflow()212 double GetPlateauInflow() { return m_plateau_inflow; } GetPlateauOutflow()213 double GetPlateauOutflow() { return m_plateau_outflow; } GetConeInflow()214 double GetConeInflow() { return m_cone_inflow; } GetConeOutflow()215 double GetConeOutflow() { return m_cone_outflow; } GetGradientInflow()216 double GetGradientInflow() { return m_gradient_inflow; } GetIsPlateauCommon()217 int GetIsPlateauCommon() { return m_is_plateau_common; } GetFloor()218 double GetFloor() { return m_floor; } GetHabitat()219 int GetHabitat() { return m_habitat; } GetMinSize()220 int GetMinSize() { return m_min_size; } GetMaxSize()221 int GetMaxSize() { return m_max_size; } GetConfig()222 int GetConfig() { return m_config; } GetCount()223 int GetCount() { return m_count; } GetResistance()224 double GetResistance() { return m_resistance; } GetGradient()225 bool GetGradient() { return isgradient; } GetInitialPlatVal()226 double GetInitialPlatVal() { return m_init_plat; } GetThreshold()227 double GetThreshold() { return m_threshold; } GetRefuge()228 int GetRefuge() { return m_refuge; } IsPredatory()229 bool IsPredatory() { return m_predator; } GetPredatorResOdds()230 double GetPredatorResOdds() { return m_predator_odds; } GetJuvAdultGuardRatio()231 double GetJuvAdultGuardRatio() { return m_guard_juvs_per; } GetDetectionProb()232 double GetDetectionProb() { return m_prob_detect; } GetCellListPtr()233 tArray<cCellResource> *GetCellListPtr() { return &cell_list; } GetCellIdListPtr()234 tArray<int> *GetCellIdListPtr() { return &cell_id_list; } GetHGTMetabolize()235 bool GetHGTMetabolize() const { return hgt_metabolize; } GetCollectable()236 bool GetCollectable() { return collectable; } 237 SetIndex(int _index)238 void SetIndex(int _index) { if (index < 0) index = _index; } // can only be assigned once SetInitial(double _initial)239 void SetInitial(double _initial) { initial = _initial; } SetInflow(double _inflow)240 void SetInflow (double _inflow ) { inflow = _inflow; } SetOutflow(double _outflow)241 void SetOutflow(double _outflow) { outflow = _outflow; } 242 bool SetGeometry(cString _geometry); SetInflowX1(int _inflowX1)243 void SetInflowX1(int _inflowX1) { inflowX1 = _inflowX1; } SetInflowX2(int _inflowX2)244 void SetInflowX2(int _inflowX2) { inflowX2 = _inflowX2; } SetInflowY1(int _inflowY1)245 void SetInflowY1(int _inflowY1) { inflowY1 = _inflowY1; } SetInflowY2(int _inflowY2)246 void SetInflowY2(int _inflowY2) { inflowY2 = _inflowY2; } SetOutflowX1(int _outflowX1)247 void SetOutflowX1(int _outflowX1) { outflowX1 = _outflowX1; } SetOutflowX2(int _outflowX2)248 void SetOutflowX2(int _outflowX2) { outflowX2 = _outflowX2; } SetOutflowY1(int _outflowY1)249 void SetOutflowY1(int _outflowY1) { outflowY1 = _outflowY1; } SetOutflowY2(int _outflowY2)250 void SetOutflowY2(int _outflowY2) { outflowY2 = _outflowY2; } SetXDiffuse(double _xdiffuse)251 void SetXDiffuse(double _xdiffuse) { xdiffuse = _xdiffuse; } SetXGravity(double _xgravity)252 void SetXGravity(double _xgravity) { xgravity = _xgravity; } SetYDiffuse(double _ydiffuse)253 void SetYDiffuse(double _ydiffuse) { ydiffuse = _ydiffuse; } SetYGravity(double _ygravity)254 void SetYGravity(double _ygravity) { ygravity = _ygravity; } SetCollectable(int _collectable)255 void SetCollectable(int _collectable) { collectable = _collectable; } 256 bool SetDemeResource(cString _deme_resource); 257 bool SetOrgResource(cString _org_resource); 258 bool SetEnergyResource(cString _energy_resource); SetDynamicResource(bool _dynamic_resource)259 void SetDynamicResource(bool _dynamic_resource) { dynamic_resource = _dynamic_resource; } //JW SetPeaks(int _peaks)260 void SetPeaks(int _peaks) { peaks = _peaks; } //JW SetMinHeight(double _min_height)261 void SetMinHeight(double _min_height) { min_height = _min_height; } //JW SetHeightRange(double _height_range)262 void SetHeightRange(double _height_range) { height_range = _height_range; } //JW SetMinRadius(double _min_radius)263 void SetMinRadius(double _min_radius) { min_radius = _min_radius; } //JW SetRadiusRange(double _radius_range)264 void SetRadiusRange(double _radius_range) { radius_range = _radius_range; } //JW SetAh(double _ah)265 void SetAh(double _ah) { ah = _ah; } //JW SetAr(double _ar)266 void SetAr(double _ar) { ar = _ar; } //JW SetAcx(double _acx)267 void SetAcx(double _acx) { acx = _acx; } //JW SetAcy(double _acy)268 void SetAcy(double _acy) { acy = _acy; } //JW SetHStepscale(double _hstepscale)269 void SetHStepscale(double _hstepscale) { hstepscale = _hstepscale; } //JW SetRStepscale(double _rstepscale)270 void SetRStepscale(double _rstepscale) { rstepscale = _rstepscale; } //JW SetCStepscaleX(double _cstepscalex)271 void SetCStepscaleX(double _cstepscalex) { cstepscalex = _cstepscalex; } //JW SetCStepscaleY(double _cstepscaley)272 void SetCStepscaleY(double _cstepscaley) { cstepscaley = _cstepscaley; } //JW SetHStep(double _hstep)273 void SetHStep(double _hstep) { hstep = _hstep; } //JW SetRStep(double _rstep)274 void SetRStep(double _rstep) { rstep = _rstep; } //JW SetCStepX(double _cstepx)275 void SetCStepX(double _cstepx) { cstepx = _cstepx; } //JW SetCStepY(double _cstepy)276 void SetCStepY(double _cstepy) { cstepy = _cstepy; } //JW SetUpdateDynamic(int _update_dynamic)277 void SetUpdateDynamic(int _update_dynamic) { update_dynamic = _update_dynamic; } //JW 278 SetPeakX(int _peakx)279 void SetPeakX(int _peakx) { m_peakx = _peakx; } SetPeakY(int _peaky)280 void SetPeakY(int _peaky) { m_peaky = _peaky; } SetHeight(int _height)281 void SetHeight(int _height) { m_height = _height; } SetSpread(int _spread)282 void SetSpread(int _spread) { m_spread = _spread; } SetPlateau(double _plateau)283 void SetPlateau(double _plateau) { m_plateau = _plateau; } SetDecay(int _decay)284 void SetDecay(int _decay) { m_decay = _decay; } SetMaxX(int _max_x)285 void SetMaxX(int _max_x) { m_max_x = _max_x; } SetMaxY(int _max_y)286 void SetMaxY(int _max_y) { m_max_y = _max_y; } SetMinX(int _min_x)287 void SetMinX(int _min_x) { m_min_x = _min_x; } SetMinY(int _min_y)288 void SetMinY(int _min_y) { m_min_y = _min_y; } SetAscaler(double _move_a_scaler)289 void SetAscaler(double _move_a_scaler) { m_move_a_scaler = _move_a_scaler; } SetUpdateStep(int _updatestep)290 void SetUpdateStep(int _updatestep) { m_updatestep = _updatestep; } SetHalo(int _halo)291 void SetHalo(int _halo) { m_halo = _halo; } SetHaloInnerRadius(int _halo_inner_radius)292 void SetHaloInnerRadius(int _halo_inner_radius) { m_halo_inner_radius = _halo_inner_radius; } SetHaloWidth(int _halo_width)293 void SetHaloWidth(int _halo_width) { m_halo_width = _halo_width; } SetHaloAnchorX(int _halo_anchor_x)294 void SetHaloAnchorX(int _halo_anchor_x) { m_halo_anchor_x = _halo_anchor_x; } SetHaloAnchorY(int _halo_anchor_y)295 void SetHaloAnchorY(int _halo_anchor_y) { m_halo_anchor_y = _halo_anchor_y; } SetMoveSpeed(int _move_speed)296 void SetMoveSpeed(int _move_speed) { m_move_speed = _move_speed; } SetPlateauInflow(double _plateau_inflow)297 void SetPlateauInflow(double _plateau_inflow) { m_plateau_inflow = _plateau_inflow; } SetPlateauOutflow(double _plateau_outflow)298 void SetPlateauOutflow(double _plateau_outflow) { m_plateau_outflow = _plateau_outflow; } SetConeInflow(double _cone_inflow)299 void SetConeInflow(double _cone_inflow) { m_cone_inflow = _cone_inflow; } SetConeOutflow(double _cone_outflow)300 void SetConeOutflow(double _cone_outflow) { m_cone_outflow = _cone_outflow; } SetGradientInflow(double _gradient_inflow)301 void SetGradientInflow(double _gradient_inflow) { m_gradient_inflow = _gradient_inflow; } SetPlatInitial(double _initial_plat_val)302 void SetPlatInitial(double _initial_plat_val) { m_init_plat = _initial_plat_val; } SetIsPlateauCommon(int _is_plateau_common)303 void SetIsPlateauCommon(int _is_plateau_common) { m_is_plateau_common = _is_plateau_common; } SetFloor(double _floor)304 void SetFloor(double _floor) { m_floor = _floor; } SetHabitat(int _habitat)305 void SetHabitat(int _habitat) { m_habitat = _habitat; } SetMinSize(int _min_size)306 void SetMinSize(int _min_size) { m_min_size = _min_size; } SetMaxSize(int _max_size)307 void SetMaxSize(int _max_size) { m_max_size = _max_size; } SetConfig(int _config)308 void SetConfig(int _config) { m_config = _config; } SetCount(int _count)309 void SetCount(int _count) { m_count = _count; } SetResistance(double _resistance)310 void SetResistance(double _resistance) { m_resistance = _resistance; } SetThreshold(double _threshold)311 void SetThreshold(double _threshold) { m_threshold = _threshold; } SetRefuge(int _refuge)312 void SetRefuge(int _refuge) { m_refuge = _refuge; } SetGradient(bool _gradient)313 void SetGradient(bool _gradient) { isgradient = _gradient; } SetPredatoryResource(double _odds,int _juvsper,double _prob)314 void SetPredatoryResource(double _odds, int _juvsper, double _prob) { m_predator = true; m_predator_odds = _odds; m_guard_juvs_per = _juvsper; m_prob_detect = _prob; } 315 AddCellResource(cCellResource new_cell)316 void AddCellResource(cCellResource new_cell) { cell_list.Push(new_cell); } 317 cCellResource *GetCellResourcePtr(int _id); 318 void UpdateCellResource(cCellResource *_CellResoucePtr, double _initial, 319 double _inflow, double _outflow); 320 void SetCellIdList(tArray<int>& id_list); //SLG partial resources SetHGTMetabolize(int _in)321 void SetHGTMetabolize(int _in) { hgt_metabolize = _in; } 322 }; 323 324 #endif 325