Changeset 3632
- Timestamp:
- 02/08/10 11:03:19 (7 months ago)
- Location:
- development/source
- Files:
-
- 4 modified
-
actions/PopulationActions.cc (modified) (2 diffs)
-
main/cPopulationCell.cc (modified) (1 diff)
-
main/cPopulationCell.h (modified) (1 diff)
-
main/cPopulationInterface.cc (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
development/source/actions/PopulationActions.cc
r3631 r3632 4460 4460 would be... complications... to runtime changes to an organism's genome... 4461 4461 */ 4462 class cAction Conjugate: public cAction {4462 class cActionAvidianConjugation : public cAction { 4463 4463 public: 4464 4464 static const cString GetDescription() { return "Arguments: (prob. of donation)"; } 4465 4465 4466 4466 //! Constructor. 4467 cAction Conjugate(cWorld* world, const cString& args) : cAction(world, args), m_donation_p(-1.0) {4467 cActionAvidianConjugation(cWorld* world, const cString& args) : cAction(world, args), m_donation_p(-1.0) { 4468 4468 cString largs(args); 4469 4469 if(largs.GetSize()) { … … 4688 4688 4689 4689 action_lib->Register<cActionDiffuseHGTGenomeFragments>("DiffuseHGTGenomeFragments"); 4690 action_lib->Register<cActionAvidianConjugation>("AvidianConjugation"); 4690 4691 4691 4692 // @DMB - The following actions are DEPRECATED aliases - These will be removed in 2.7. -
development/source/main/cPopulationCell.cc
r3629 r3632 159 159 } 160 160 161 /*! Recursively build a set of occupied cells that neighbor this one, out to the given depth. 162 */ 163 void cPopulationCell::GetOccupiedNeighboringCells(std::set<cPopulationCell*>& occupied_cell_set, int depth) const { 164 // we'll do this the easy way, and just filter the neighbor set. 165 std::set<cPopulationCell*> cell_set; 166 GetNeighboringCells(cell_set, depth); 167 for(std::set<cPopulationCell*>::iterator i=cell_set.begin(); i!=cell_set.end(); ++i) { 168 if((*i)->IsOccupied()) { 169 occupied_cell_set.insert(*i); 170 } 171 } 172 } 173 161 174 /*! These values are chosen so as to make loops on the facing 'easy'. 162 175 111 = NE -
development/source/main/cPopulationCell.h
r3629 r3632 104 104 //! Recursively build a set of cells that neighbor this one, out to the given depth. 105 105 void GetNeighboringCells(std::set<cPopulationCell*>& cell_set, int depth) const; 106 //! Recursively build a set of occupied cells that neighbor this one, out to the given depth. 107 void GetOccupiedNeighboringCells(std::set<cPopulationCell*>& occupied_cell_set, int depth) const; 106 108 inline cPopulationCell& GetCellFaced() { return *(m_connections.GetFirst()); } 107 109 int GetFacing(); // Returns the facing of this cell. -
development/source/main/cPopulationInterface.cc
r3629 r3632 222 222 switch(m_world->GetConfig().NET_STYLE.Get()) 223 223 { 224 case 1: // Receiver Facing224 case 1: // Receiver Facing 225 225 { 226 226 cOrganism* cur_neighbor = cell.ConnectionList().GetFirst()->GetOrganism(); … … 228 228 if (cur_neighbor != NULL && (msg = cur_neighbor->NetPop()) != NULL) return msg; 229 229 } 230 break;231 232 case 0: // Random Next - First Available233 default:230 break; 231 232 case 0: // Random Next - First Available 233 default: 234 234 { 235 235 const int num_neighbors = cell.ConnectionList().GetSize(); … … 242 242 } 243 243 } 244 break;244 break; 245 245 } 246 246 … … 648 648 */ 649 649 void cPopulationInterface::DoHGTDonation(cAvidaContext& ctx) { 650 cPopulationCell* target=0; 651 650 652 switch(m_world->GetConfig().HGT_CONJUGATION_METHOD.Get()) { 651 case 0: { // faced individual 652 cPopulationCell* faced = GetCellFaced(); 653 if(faced->IsOccupied()) { 654 fragment_list_type fragments; 655 cGenomeUtil::RandomSplit(ctx, 656 m_world->GetConfig().HGT_FRAGMENT_SIZE_MEAN.Get(), 657 m_world->GetConfig().HGT_FRAGMENT_SIZE_VARIANCE.Get(), 658 GetOrganism()->GetGenome(), 659 fragments); 660 faced->GetOrganism()->GetOrgInterface().ReceiveHGTDonation(fragments[ctx.GetRandom().GetInt(fragments.size())]); 661 } 662 break; 663 } 664 default: { 665 m_world->GetDriver().RaiseFatalException(1, "HGT_CONJUGATION_RECV_METHOD is set to an invalid value."); 666 break; 667 } 668 } 653 case 0: { // faced individual 654 target = GetCellFaced(); 655 if(!target->IsOccupied()) { 656 // nothing to do, we're facing an empty cell. 657 return; 658 } 659 break; 660 } 661 case 1: { // selected at random from neighborhood 662 std::set<cPopulationCell*> occupied_cell_set; 663 GetCell()->GetOccupiedNeighboringCells(occupied_cell_set, 1); 664 if(occupied_cell_set.size()==0) { 665 // nothing to do here, there are no neighbors 666 return; 667 } 668 std::set<cPopulationCell*>::iterator selected=occupied_cell_set.begin(); 669 std::advance(selected, ctx.GetRandom().GetInt(occupied_cell_set.size())); 670 target = *selected; 671 break; 672 } 673 default: { 674 m_world->GetDriver().RaiseFatalException(1, "HGT_CONJUGATION_METHOD is set to an invalid value."); 675 break; 676 } 677 } 678 assert(target != 0); 679 fragment_list_type fragments; 680 cGenomeUtil::RandomSplit(ctx, 681 m_world->GetConfig().HGT_FRAGMENT_SIZE_MEAN.Get(), 682 m_world->GetConfig().HGT_FRAGMENT_SIZE_VARIANCE.Get(), 683 GetOrganism()->GetGenome(), 684 fragments); 685 target->GetOrganism()->GetOrgInterface().ReceiveHGTDonation(fragments[ctx.GetRandom().GetInt(fragments.size())]); 669 686 } 670 687 … … 695 712 // the hgt source controls where the genetic material for HGT comes from. 696 713 switch(m_world->GetConfig().HGT_SOURCE.Get()) { 697 case 0: { // source is other genomes, nothing to do here (default)698 break;699 }700 case 1: { // source is the parent (a control)701 // this is a little hackish, but this is the cleanest way to make sure702 // that all downstream stuff works right.703 cell.ClearFragments();704 cell.AddGenomeFragments(cell.GetOrganism()->GetGenome());705 break;706 }707 default: { // error708 m_world->GetDriver().RaiseFatalException(1, "HGT_SOURCE is set to an invalid value.");709 break;710 }714 case 0: { // source is other genomes, nothing to do here (default) 715 break; 716 } 717 case 1: { // source is the parent (a control) 718 // this is a little hackish, but this is the cleanest way to make sure 719 // that all downstream stuff works right. 720 cell.ClearFragments(); 721 cell.AddGenomeFragments(cell.GetOrganism()->GetGenome()); 722 break; 723 } 724 default: { // error 725 m_world->GetDriver().RaiseFatalException(1, "HGT_SOURCE is set to an invalid value."); 726 break; 727 } 711 728 } 712 729 … … 727 744 cGenomeUtil::substring_match location; 728 745 switch(m_world->GetConfig().HGT_FRAGMENT_SELECTION.Get()) { 729 case 0: { // random selection730 HGTRandomFragmentSelection(ctx, offspring, i, location);731 break;732 }733 case 1: { // random selection with redundant instruction trimming734 HGTTrimmedFragmentSelection(ctx, offspring, i, location);735 break;736 }737 case 2: { // random selection and random placement738 HGTRandomFragmentPlacement(ctx, offspring, i, location);739 break;740 }741 default: { // error742 m_world->GetDriver().RaiseFatalException(1, "HGT_FRAGMENT_SELECTION is set to an invalid value.");743 break;744 }746 case 0: { // random selection 747 HGTRandomFragmentSelection(ctx, offspring, i, location); 748 break; 749 } 750 case 1: { // random selection with redundant instruction trimming 751 HGTTrimmedFragmentSelection(ctx, offspring, i, location); 752 break; 753 } 754 case 2: { // random selection and random placement 755 HGTRandomFragmentPlacement(ctx, offspring, i, location); 756 break; 757 } 758 default: { // error 759 m_world->GetDriver().RaiseFatalException(1, "HGT_FRAGMENT_SELECTION is set to an invalid value."); 760 break; 761 } 745 762 } 746 763