1 /* 2 * cPopulation.h 3 * Avida 4 * 5 * Called "population.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 #ifndef cPopulation_h 24 #define cPopulation_h 25 26 #include "cBirthChamber.h" 27 #include "cDeme.h" 28 #include "cOrgInterface.h" 29 #include "cPopulationInterface.h" 30 #include "cResourceCount.h" 31 #include "cString.h" 32 #include "cWorld.h" 33 #include "tArray.h" 34 #include "tList.h" 35 #include "tVector.h" 36 37 #include <fstream> 38 #include <map> 39 40 41 namespace Avida { 42 class Sequence; 43 }; 44 45 class cAvidaContext; 46 class cBioUnit; 47 class cCodeLabel; 48 class cEnvironment; 49 class cLineage; 50 class cOrganism; 51 class cPopulationCell; 52 class cSchedule; 53 class cSaleItem; 54 55 using namespace Avida; 56 57 58 class cPopulation 59 { 60 private: 61 // Components... 62 cWorld* m_world; 63 cSchedule* schedule; // Handles allocation of CPU cycles 64 tArray<cPopulationCell> cell_array; // Local cells composing the population 65 tArray<int> empty_cell_id_array; // Used for PREFER_EMPTY birth methods 66 cResourceCount resource_count; // Global resources available 67 cBirthChamber birth_chamber; // Global birth chamber. 68 tArray<tList<cSaleItem> > market; // list of lists of items for sale, each list goes with 1 label 69 //Keeps track of which organisms are in which group. 70 tArrayMap<int, tSmartArray<cOrganism*> > group_list; 71 tArrayMap<int, tArray<pair<int,int> > > m_group_intolerances; 72 tArrayMap<int, tArray<pair<int,int> > > m_group_intolerances_females; 73 tArrayMap<int, tArray<pair<int,int> > > m_group_intolerances_males; 74 tArrayMap<int, tArray<pair<int,int> > > m_group_intolerances_juvs; 75 76 // Keep list of live organisms 77 tSmartArray<cOrganism* > live_org_list; 78 79 tVector<pair<int,int> > *sleep_log; 80 81 // Data Tracking... 82 tList<cPopulationCell> reaper_queue; // Death order in some mass-action runs 83 tSmartArray<int> minitrace_queue; 84 bool print_mini_trace_genomes; 85 bool print_mini_trace_reacs; 86 bool use_micro_traces; 87 int m_next_prey_q; 88 int m_next_pred_q; 89 90 tSmartArray<cOrganism*> repro_q; 91 tSmartArray<cOrganism*> topnav_q; 92 93 // Default organism setups... 94 cEnvironment& environment; // Physics & Chemistry description 95 96 // Other data... 97 int world_x; // Structured population width. 98 int world_y; // Structured population height. 99 int world_z; //!< Population depth. 100 int num_organisms; // Cell count with living organisms 101 int num_prey_organisms; 102 int num_pred_organisms; 103 int pop_enforce; 104 tArray<int> min_prey_failures; 105 bool m_has_predatory_res; 106 107 tArray<cDeme> deme_array; // Deme structure of the population. 108 109 // Outside interactions... 110 bool sync_events; // Do we need to sync up the event list with population? 111 112 // Group formation information 113 std::map<int, int> m_groups; //<! Maps the group id to the number of orgs in the group 114 std::map<int, int> m_group_females; //<! Maps the group id to the number of females in the group 115 std::map<int, int> m_group_males; //<! Maps the group id to the number of males in the group 116 117 int m_hgt_resid; //!< HGT resource ID. 118 119 120 cPopulation(); // @not_implemented 121 cPopulation(const cPopulation&); // @not_implemented 122 cPopulation& operator=(const cPopulation&); // @not_implemented 123 124 125 public: 126 cPopulation(cWorld* world); 127 ~cPopulation(); 128 129 bool InitiatePop(cUserFeedback* errors = NULL); 130 131 void InjectGenome(int cell_id, eBioUnitSource src, const Genome& genome, cAvidaContext& ctx, int lineage_label = 0, bool assign_group = true); 132 133 // Activate the offspring of an organism in the population 134 bool ActivateOffspring(cAvidaContext& ctx, const Genome& offspring_genome, cOrganism* parent_organism); 135 bool ActivateParasite(cOrganism* host, cBioUnit* parent, const cString& label, const Sequence& injected_code); 136 137 // Helper function for ActivateParasite - returns if the parasite from the infected host should infect the target host 138 bool TestForParasiteInteraction(cOrganism* infected_host, cOrganism* target_host); 139 140 void UpdateQs(cOrganism* parent, bool reproduced = false); 141 142 // Inject an organism from the outside world. 143 void Inject(const Genome& genome, eBioUnitSource src, cAvidaContext& ctx, int cell_id = -1, double merit = -1, int lineage_label = 0, double neutral_metric = 0, bool inject_with_group = false, int group_id = -1, int forager_type = -1, int trace = 0); 144 void InjectGroup(const Genome& genome, eBioUnitSource src, cAvidaContext& ctx, int cell_id = -1, double merit = -1, int lineage_label = 0, double neutral_metric = 0, int group_id = -1, int forager_type = -1, int trace = 0); 145 void InjectParasite(const cString& label, const Sequence& injected_code, int cell_id); 146 147 // Deactivate an organism in the population (required for deactivations) 148 void KillOrganism(cPopulationCell& in_cell, cAvidaContext& ctx); 149 SetPopCapEnforcement(int rate)150 void SetPopCapEnforcement(int rate) { pop_enforce = rate; } 151 152 // @WRE 2007/07/05 Helper function to take care of side effects of Avidian 153 // movement that cannot be directly handled in cHardwareCPU.cc 154 bool MoveOrganisms(cAvidaContext& ctx, int src_cell_id, int dest_cell_id, int avatar_cell); 155 156 // Specialized functionality 157 void Kaboom(cPopulationCell& in_cell, cAvidaContext& ctx, int distance=0); 158 void AddSellValue(const int data, const int label, const int sell_price, const int org_id, const int cell_id); 159 int BuyValue(const int label, const int buy_price, const int cell_id); 160 void SwapCells(int cell_id1, int cell_id2, cAvidaContext& ctx); 161 162 // Deme-related methods 163 //! Compete all demes with each other based on the given competition type. 164 void CompeteDemes(cAvidaContext& ctx, int competition_type); 165 166 //! Compete all demes with each other based on the given vector of fitness values. 167 void CompeteDemes(const std::vector<double>& calculated_fitness, cAvidaContext& ctx); 168 169 //! Replicate all demes based on the given replication trigger. 170 void ReplicateDemes(int rep_trigger, cAvidaContext& ctx); 171 172 //! Helper method to replicate deme 173 void ReplicateDeme(cDeme & source_deme, cAvidaContext& ctx); 174 175 //! Helper method that replaces a target deme with the given source deme. 176 void ReplaceDeme(cDeme& source_deme, cDeme& target_deme, cAvidaContext& ctx); 177 178 //! Helper method that replaces a target deme with a given source deme using 179 // the germ line flagged by the organisms. 180 void ReplaceDemeFlaggedGermline(cDeme& source_deme, cDeme& target_deme, cAvidaContext& ctx); 181 182 //! Helper method that seeds a deme from the given genome. 183 void SeedDeme(cDeme& deme, Genome& genome, eBioUnitSource src, cAvidaContext& ctx); 184 185 //! Helper method that seeds a deme from the given genotype. 186 void SeedDeme(cDeme& _deme, cBioGroup* bg, eBioUnitSource src, cAvidaContext& ctx); 187 188 //! Helper method that seeds a target deme from the organisms in the source deme. 189 bool SeedDeme(cDeme& source_deme, cDeme& target_deme, cAvidaContext& ctx); 190 191 //! Helper method that determines the cell into which an organism will be placed during deme replication. 192 int DemeSelectInjectionCell(cDeme& deme, int sequence=0); 193 194 //! Helper method that performs any post-injection fixups on the cell in the given deme. 195 void DemePostInjection(cDeme& deme, cPopulationCell& cell); 196 197 void DivideDemes(cAvidaContext& ctx); 198 void ResetDemes(); 199 void CopyDeme(int deme1_id, int deme2_id, cAvidaContext& ctx); 200 void SpawnDeme(int deme1_id, cAvidaContext& ctx, int deme2_id=-1); 201 void AddDemePred(cString type, int times); 202 203 void CheckImplicitDemeRepro(cDeme& deme, cAvidaContext& ctx); 204 205 // Deme-related stats methods 206 void PrintDemeAllStats(cAvidaContext& ctx); 207 void PrintDemeTestamentStats(const cString& filename); 208 void PrintCurrentMeanDemeDensity(const cString& filename); 209 void PrintDemeEnergySharingStats(); 210 void PrintDemeEnergyDistributionStats(cAvidaContext& ctx); 211 void PrintDemeOrganismEnergyDistributionStats(); 212 void PrintDemeDonor(); 213 void PrintDemeFitness(); 214 void PrintDemeGestationTime(); 215 void PrintDemeInstructions(); 216 void PrintDemeLifeFitness(); 217 void PrintDemeMerit(); 218 void PrintDemeMutationRate(); 219 void PrintDemeReceiver(); 220 void PrintDemeResource(cAvidaContext& ctx); 221 void PrintDemeGlobalResources(cAvidaContext& ctx); 222 void PrintDemeSpatialResData(const cResourceCount& res, const int i, const int deme_id, cAvidaContext& ctx) const; 223 void PrintDemeSpatialEnergyData() const; 224 void PrintDemeSpatialSleepData() const; 225 void PrintDemeTasks(); 226 void PrintDemeTotalAvgEnergy(cAvidaContext& ctx); 227 void PrintDemesMeritsData(); //@JJB** 228 229 // Print deme founders 230 void DumpDemeFounders(ofstream& fp); 231 232 // Print donation stats 233 void PrintDonationStats(); 234 235 // Process a single organism one instruction... 236 int ScheduleOrganism(); // Determine next organism to be processed. 237 void ProcessStep(cAvidaContext& ctx, double step_size, int cell_id); 238 void ProcessStepSpeculative(cAvidaContext& ctx, double step_size, int cell_id); 239 240 // Calculate the statistics from the most recent update. 241 void ProcessPostUpdate(cAvidaContext& ctx); 242 void ProcessPreUpdate(); 243 void UpdateResStats(cAvidaContext& ctx); 244 void ProcessUpdateCellActions(cAvidaContext& ctx); 245 246 // Clear all but a subset of cells... 247 void SerialTransfer(int transfer_size, bool ignore_deads, cAvidaContext& ctx); 248 249 // Saving and loading... 250 bool SavePopulation(const cString& filename, bool save_historic, bool save_group_info = false, bool save_avatars = false, 251 bool save_rebirth = false); 252 bool LoadPopulation(const cString& filename, cAvidaContext& ctx, int cellid_offset=0, int lineage_offset=0, 253 bool load_groups = false, bool load_birth_cells = false, bool load_avatars = false, bool load_rebirth = false); 254 bool DumpMemorySummary(std::ofstream& fp); 255 bool SaveFlameData(const cString& filename); 256 257 void SetMiniTraceQueue(tSmartArray<int> new_queue, bool print_genomes, bool print_reacs, bool use_micro = false); 258 void AppendMiniTraces(tSmartArray<int> new_queue, bool print_genomes, bool print_reacs, bool use_micro = false); 259 void LoadMiniTraceQ(cString& filename, int orgs_per, bool print_genomes, bool print_reacs); 260 tSmartArray<int> SetRandomTraceQ(int max_samples); 261 tSmartArray<int> SetRandomPreyTraceQ(int max_samples); 262 tSmartArray<int> SetRandomPredTraceQ(int max_samples); 263 void SetNextPreyQ(int num_prey, bool print_genomes, bool print_reacs, bool use_micro); 264 void SetNextPredQ(int num_pred, bool print_genomes, bool print_reacs, bool use_micro); 265 tSmartArray<int> SetTraceQ(int save_dominants, int save_groups, int save_foragers, int orgs_per, int max_samples); GetMiniTraceQueue()266 tSmartArray<int> GetMiniTraceQueue() const { return minitrace_queue; } 267 void AppendRecordReproQ(cOrganism* new_org); 268 void SetTopNavQ(); GetTopNavQ()269 tSmartArray<cOrganism*> GetTopNavQ() { return topnav_q; } 270 GetSize()271 int GetSize() const { return cell_array.GetSize(); } GetWorldX()272 int GetWorldX() const { return world_x; } GetWorldY()273 int GetWorldY() const { return world_y; } GetNumDemes()274 int GetNumDemes() const { return deme_array.GetSize(); } GetDeme(int i)275 cDeme& GetDeme(int i) { return deme_array[i]; } 276 GetCell(int in_num)277 cPopulationCell& GetCell(int in_num) { return cell_array[in_num]; } GetResources(cAvidaContext & ctx)278 const tArray<double>& GetResources(cAvidaContext& ctx) const { return resource_count.GetResources(ctx); } GetCellResources(int cell_id,cAvidaContext & ctx)279 const tArray<double>& GetCellResources(int cell_id, cAvidaContext& ctx) const { return resource_count.GetCellResources(cell_id, ctx); } GetFrozenResources(cAvidaContext & ctx,int cell_id)280 const tArray<double>& GetFrozenResources(cAvidaContext& ctx, int cell_id) const { return resource_count.GetFrozenResources(ctx, cell_id); } GetDemeResources(int deme_id,cAvidaContext & ctx)281 const tArray<double>& GetDemeResources(int deme_id, cAvidaContext& ctx) { return GetDeme(deme_id).GetDemeResourceCount().GetResources(ctx); } GetDemeCellResources(int deme_id,int cell_id,cAvidaContext & ctx)282 const tArray<double>& GetDemeCellResources(int deme_id, int cell_id, cAvidaContext& ctx) { return GetDeme(deme_id).GetDemeResourceCount().GetCellResources( GetDeme(deme_id).GetRelativeCellID(cell_id), ctx ); } TriggerDoUpdates(cAvidaContext & ctx)283 void TriggerDoUpdates(cAvidaContext& ctx) { resource_count.UpdateResources(ctx); } GetCellIdLists()284 const tArray< tArray<int> >& GetCellIdLists() const { return resource_count.GetCellIdLists(); } 285 GetCurrPeakX(cAvidaContext & ctx,int res_id)286 int GetCurrPeakX(cAvidaContext& ctx, int res_id) const { return resource_count.GetCurrPeakX(ctx, res_id); } GetCurrPeakY(cAvidaContext & ctx,int res_id)287 int GetCurrPeakY(cAvidaContext& ctx, int res_id) const { return resource_count.GetCurrPeakY(ctx, res_id); } GetFrozenPeakX(cAvidaContext & ctx,int res_id)288 int GetFrozenPeakX(cAvidaContext& ctx, int res_id) const { return resource_count.GetFrozenPeakX(ctx, res_id); } GetFrozenPeakY(cAvidaContext & ctx,int res_id)289 int GetFrozenPeakY(cAvidaContext& ctx, int res_id) const { return resource_count.GetFrozenPeakY(ctx, res_id); } GetWallCells(int res_id)290 tArray<int>* GetWallCells(int res_id) { return resource_count.GetWallCells(res_id); } 291 GetBirthChamber(int id)292 cBirthChamber& GetBirthChamber(int id) { (void) id; return birth_chamber; } 293 294 void UpdateResources(cAvidaContext& ctx, const tArray<double>& res_change); 295 void UpdateResource(cAvidaContext& ctx, int id, double change); 296 void UpdateCellResources(cAvidaContext& ctx, const tArray<double>& res_change, const int cell_id); 297 void UpdateDemeCellResources(cAvidaContext& ctx, const tArray<double>& res_change, const int cell_id); 298 299 void SetResource(cAvidaContext& ctx, int id, double new_level); 300 void SetResource(cAvidaContext& ctx, const cString res_name, double new_level); GetResource(cAvidaContext & ctx,int id)301 double GetResource(cAvidaContext& ctx, int id) const { return resource_count.Get(ctx, id); } GetResourceCount()302 cResourceCount& GetResourceCount() { return resource_count; } 303 void SetResourceInflow(const cString res_name, double new_level); 304 void SetResourceOutflow(const cString res_name, double new_level); 305 306 void SetDemeResource(cAvidaContext& ctx, const cString res_name, double new_level); 307 void SetSingleDemeResourceInflow(int deme_id, const cString res_name, double new_level); 308 void SetDemeResourceInflow(const cString res_name, double new_level); 309 void SetSingleDemeResourceOutflow(int deme_id, const cString res_name, double new_level); 310 void SetDemeResourceOutflow(const cString res_name, double new_level); 311 312 void ResetInputs(cAvidaContext& ctx); 313 GetEnvironment()314 cEnvironment& GetEnvironment() { return environment; } GetNumOrganisms()315 int GetNumOrganisms() { return num_organisms; } 316 GetNumPreyOrganisms()317 int GetNumPreyOrganisms() { return num_prey_organisms; } GetNumPredOrganisms()318 int GetNumPredOrganisms() { return num_pred_organisms; } DecNumPreyOrganisms()319 void DecNumPreyOrganisms() { num_prey_organisms--; } DecNumPredOrganisms()320 void DecNumPredOrganisms() { num_pred_organisms--; } IncNumPreyOrganisms()321 void IncNumPreyOrganisms() { num_prey_organisms++; } IncNumPredOrganisms()322 void IncNumPredOrganisms() { num_pred_organisms++; } RecordMinPreyFailedAttack()323 void RecordMinPreyFailedAttack() { min_prey_failures.Push(m_world->GetStats().GetUpdate()); } ClearMinPreyFailedAttacks()324 void ClearMinPreyFailedAttacks() { min_prey_failures.Resize(0); } GetMinPreyFailedAttacks()325 tArray<int> GetMinPreyFailedAttacks() { return min_prey_failures; } 326 327 void RemovePredators(cAvidaContext& ctx); 328 GetSyncEvents()329 bool GetSyncEvents() { return sync_events; } SetSyncEvents(bool _in)330 void SetSyncEvents(bool _in) { sync_events = _in; } 331 void PrintPhenotypeData(const cString& filename); 332 void PrintHostPhenotypeData(const cString& filename); 333 void PrintParasitePhenotypeData(const cString& filename); 334 void PrintPhenotypeStatus(const cString& filename); 335 336 bool UpdateMerit(int cell_id, double new_merit); 337 338 void AddBeginSleep(int cellID, int start_time); 339 void AddEndSleep(int cellID, int end_time); 340 getCellSleepLog(int i)341 tVector<pair<int,int> > getCellSleepLog(int i) { return sleep_log[i]; } 342 343 // Trials and genetic algorithm @JEB 344 void NewTrial(cAvidaContext& ctx); 345 void CompeteOrganisms(cAvidaContext& ctx, int competition_type, int parents_survive); 346 347 // Let users change environmental variables durning the run @BDB 22-Feb-2008 348 void UpdateResourceCount(const int Verbosity, cWorld* world); 349 350 // Let users change Gradient Resource variables during the run JW 351 void UpdateGradientCount(cAvidaContext& ctx, const int Verbosity, cWorld* world, const cString res_name); 352 void UpdateGradientPlatInflow(const cString res_name, const double inflow); 353 void UpdateGradientPlatOutflow(const cString res_name, const double outflow); 354 void UpdateGradientConeInflow(const cString res_name, const double inflow); 355 void UpdateGradientConeOutflow(const cString res_name, const double outflow); 356 void UpdateGradientInflow(const cString res_name, const double inflow); 357 void SetGradPlatVarInflow(const cString res_name, const double mean, const double variance, const int type); 358 void SetPredatoryResource(const cString res_name, const double odds, const int juvsper, const double detection_prob); 359 void SetProbabilisticResource(cAvidaContext& ctx, const cString res_name, const double initial, const double inflow, 360 const double outflow, const double lambda, const double theta, const int x, const int y, const int count); 361 void ExecutePredatoryResource(cAvidaContext& ctx, const int cell_id, const double pred_odds, const int juvs_per); HasPredatoryRes()362 bool HasPredatoryRes() { return m_has_predatory_res; } 363 364 // Add an org to live org list 365 void AddLiveOrg(cOrganism* org); 366 // Remove an org from live org list 367 void RemoveLiveOrg(cOrganism* org); GetLiveOrgList()368 const tSmartArray<cOrganism*> GetLiveOrgList() const { return live_org_list; } 369 370 // Adds an organism to a group 371 void JoinGroup(cOrganism* org, int group_id); 372 void MakeGroup(cOrganism* org); 373 // Removes an organism from a group 374 void LeaveGroup(cOrganism* org, int group_id); 375 376 //Kill random member of the group (but not self!!!) 377 void KillGroupMember(cAvidaContext& ctx, int group_id, cOrganism* org); 378 //Attack organism faced by this one, if there is an organism in front. 379 void AttackFacedOrg(cAvidaContext& ctx, int loser); 380 // Identifies the number of organisms in a group 381 int NumberOfOrganismsInGroup(int group_id); 382 int NumberGroupFemales(int group_id); 383 int NumberGroupMales(int group_id); 384 int NumberGroupJuvs(int group_id); 385 void ChangeGroupMatingTypes(cOrganism* org, int group_id, int old_type, int new_type); 386 // Get the group information GetFormedGroups()387 map<int, int> GetFormedGroups() { return m_groups; } 388 389 // -------- Tolerance support -------- 390 int CalcGroupToleranceImmigrants(int group_id, int mating_type = -1); 391 int CalcGroupToleranceOffspring(cOrganism* parent_organism); 392 double CalcGroupOddsImmigrants(int group_id, int mating_type = -1); 393 bool AttemptImmigrateGroup(int group_id, cOrganism* org); 394 double CalcGroupOddsOffspring(int group_id); 395 double CalcGroupOddsOffspring(cOrganism* parent); 396 bool AttemptOffspringParentGroup(cAvidaContext& ctx, cOrganism* parent, cOrganism* offspring); 397 double CalcGroupAveImmigrants(int group_id, int mating_type = -1); 398 double CalcGroupSDevImmigrants(int group_id, int mating_type = -1); 399 double CalcGroupAveOwn(int group_id); 400 double CalcGroupSDevOwn(int group_id); 401 double CalcGroupAveOthers(int group_id); 402 double CalcGroupSDevOthers(int group_id); 403 int& GetGroupIntolerances(int group_id, int tol_num, int mating_type); 404 405 // -------- HGT support -------- 406 //! Modify current level of the HGT resource. 407 void AdjustHGTResource(cAvidaContext& ctx, double delta); 408 409 // -------- Population mixing support -------- 410 //! Mix all organisms in the population. 411 void MixPopulation(cAvidaContext& ctx); 412 413 private: 414 void BuildTimeSlicer(); // Build the schedule object 415 416 // Methods to place offspring in the population. 417 cPopulationCell& PositionOffspring(cPopulationCell& parent_cell, cAvidaContext& ctx, bool parent_ok = true); 418 void PositionAge(cPopulationCell& parent_cell, tList<cPopulationCell>& found_list, bool parent_ok); 419 void PositionMerit(cPopulationCell & parent_cell, tList<cPopulationCell>& found_list, bool parent_ok); 420 void PositionEnergyUsed(cPopulationCell & parent_cell, tList<cPopulationCell>& found_list, bool parent_ok); 421 cPopulationCell& PositionDemeMigration(cPopulationCell& parent_cell, bool parent_ok = true); 422 cPopulationCell& PositionDemeRandom(int deme_id, cPopulationCell& parent_cell, bool parent_ok = true); 423 int UpdateEmptyCellIDArray(int deme_id = -1); GetEmptyCellIDArray()424 tArray<int>& GetEmptyCellIDArray() { return empty_cell_id_array; } 425 void FindEmptyCell(tList<cPopulationCell>& cell_list, tList<cPopulationCell>& found_list); 426 int FindRandEmptyCell(); 427 428 // Update statistics collecting... 429 void UpdateDemeStats(cAvidaContext& ctx); 430 void UpdateOrganismStats(cAvidaContext& ctx); 431 void UpdateFTOrgStats(cAvidaContext& ctx); 432 void UpdateMaleFemaleOrgStats(cAvidaContext& ctx); 433 434 void InjectClone(int cell_id, cOrganism& orig_org, eBioUnitSource src); 435 void CompeteOrganisms_ConstructOffspring(int cell_id, cOrganism& parent); 436 437 //! Helper method that adds a founder organism to a deme, and sets up its phenotype 438 void SeedDeme_InjectDemeFounder(int _cell_id, cBioGroup* bg, cAvidaContext& ctx, cPhenotype* _phenotype = NULL, int lineage_label=0, bool reset = false); 439 440 void CCladeSetupOrganism(cOrganism* organism); 441 442 // Must be called to activate *any* organism in the population. 443 bool ActivateOrganism(cAvidaContext& ctx, cOrganism* in_organism, cPopulationCell& target_cell, bool assign_group = true, bool is_inject = false); 444 445 void TestForMiniTrace(cOrganism* in_organism); 446 void SetupMiniTrace(cOrganism* in_organism); 447 void PrintMiniTraceGenome(cOrganism* in_organism, cString& filename); 448 449 int PlaceAvatar(cOrganism* parent); 450 451 inline void AdjustSchedule(const cPopulationCell& cell, const cMerit& merit); 452 }; 453 454 #endif 455