Changeset 3638
- Timestamp:
- 02/10/10 16:09:19 (7 months ago)
- Location:
- development/source/main
- Files:
-
- 5 modified
-
cAvidaConfig.h (modified) (1 diff)
-
cGenomeUtil.cc (modified) (2 diffs)
-
cGenomeUtil.h (modified) (1 diff)
-
cPopulationInterface.cc (modified) (7 diffs)
-
cPopulationInterface.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
development/source/main/cAvidaConfig.h
r3629 r3638 677 677 CONFIG_ADD_VAR(HGT_INSERTION_MUT_P, double, 0.5, "Probability that an HGT mutation will result in an insertion (default=0.5); replacement if false."); 678 678 CONFIG_ADD_VAR(HGT_CONJUGATION_METHOD, int, 0, "Method used to select the receiver of an HGT conjugation (0=faced [default])"); 679 CONFIG_ADD_VAR(HGT_SCRAMBLE_FRAGMENT, int, 0, "Scramble each fragment after match, prior to insertion or replacment; 0=false [default], 1=true."); 679 680 680 681 CONFIG_ADD_GROUP(INST_RES_GROUP, "Resource-Dependent Instructions Settings"); -
development/source/main/cGenomeUtil.cc
r3629 r3638 384 384 } 385 385 386 387 /*! Split a genome into a list of fragments, each with the given mean size and variance, and add them to the given fragment list. 388 */ 386 389 void cGenomeUtil::RandomSplit(cAvidaContext& ctx, double mean, double variance, const cGenome& genome, fragment_list_type& fragments) { 387 390 // rotate this genome to remove bais for the beginning and end of the genome: … … 405 408 406 409 410 /*! Randomly shuffle the instructions within genome in-place. 411 */ 412 void cGenomeUtil::RandomShuffle(cAvidaContext& ctx, cGenome& genome) { 413 std::vector<int> idx(static_cast<std::size_t>(genome.GetSize())); 414 iota(idx.begin(), idx.end(), 0); 415 cRandomStdAdaptor rng(ctx.GetRandom()); 416 std::random_shuffle(idx.begin(), idx.end(), rng); 417 cGenome shuffled(genome.GetSize()); 418 for(int i=0; i<genome.GetSize(); ++i) { 419 shuffled[i] = genome[idx[i]]; 420 } 421 genome = shuffled; 422 } 423 407 424 cGenome cGenomeUtil::Crop(const cGenome & in_genome, int start, int end) 408 425 { -
development/source/main/cGenomeUtil.h
r3629 r3638 103 103 //! Split a genome into a list of fragments, each with the given mean size and variance, and add them to the given fragment list. 104 104 static void RandomSplit(cAvidaContext& ctx, double mean, double variance, const cGenome& genome, fragment_list_type& fragments); 105 //! Randomly shuffle the instructions within genome in-place. 106 static void RandomShuffle(cAvidaContext& ctx, cGenome& genome); 105 107 106 108 // ===== Construction methods ===== -
development/source/main/cPopulationInterface.cc
r3632 r3638 703 703 fragment_list_type fragments(m_hgt_support->_pending); // these come from conjugation 704 704 705 // these come from naturalcompetence (ie, eating the dead):705 // these come from "natural" competence (ie, eating the dead): 706 706 if((m_world->GetConfig().HGT_MUTATION_P.Get() > 0.0) 707 707 && (ctx.GetRandom().P(m_world->GetConfig().HGT_MUTATION_P.Get()))) { … … 745 745 switch(m_world->GetConfig().HGT_FRAGMENT_SELECTION.Get()) { 746 746 case 0: { // random selection 747 HGT RandomFragmentSelection(ctx, offspring, i, location);747 HGTMatchPlacement(ctx, offspring, i, location); 748 748 break; 749 749 } 750 750 case 1: { // random selection with redundant instruction trimming 751 HGTTrimmed FragmentSelection(ctx, offspring, i, location);751 HGTTrimmedPlacement(ctx, offspring, i, location); 752 752 break; 753 753 } 754 754 case 2: { // random selection and random placement 755 HGTRandom FragmentPlacement(ctx, offspring, i, location);755 HGTRandomPlacement(ctx, offspring, i, location); 756 756 break; 757 757 } … … 760 760 break; 761 761 } 762 } 763 764 // as a type of control, potentially "scramble" the genome after matching 765 // and prior to insertion to see if the fragment is contributing useful code. 766 if(m_world->GetConfig().HGT_SCRAMBLE_FRAGMENT.Get()) { 767 cGenomeUtil::RandomShuffle(ctx, *i); 762 768 } 763 769 … … 779 785 780 786 781 /*! Randomly select the fragment used for HGT mutation.782 */ 783 void cPopulationInterface::HGT RandomFragmentSelection(cAvidaContext& ctx, const cGenome& offspring,784 fragment_list_type::iterator& selected,785 substring_match& location) {787 /*! Place the fragment at the location of best match. 788 */ 789 void cPopulationInterface::HGTMatchPlacement(cAvidaContext& ctx, const cGenome& offspring, 790 fragment_list_type::iterator& selected, 791 substring_match& location) { 786 792 // find the location within the offspring's genome that best matches the selected fragment: 787 793 location = cGenomeUtil::FindUnbiasedCircularMatch(ctx, offspring, *selected); … … 789 795 790 796 791 /*! Randomly select the fragment used for HGT mutation, trimming redundant instructions.792 793 In this fragment selection method, the fragment itself is selected randomly, but the797 /*! Place the fragment at the location of best match, with redundant instructions trimmed. 798 799 In this fragment selection method, the 794 800 match location within the genome is calculated on a "trimmed" fragment. Specifically, 795 801 the trimmed fragment has all duplicate instructions at its end removed prior to the match. … … 798 804 increases the insertion rate. E.g., hgt(abcde, abcccc) -> abccccde. 799 805 */ 800 void cPopulationInterface::HGTTrimmed FragmentSelection(cAvidaContext& ctx, const cGenome& offspring,806 void cPopulationInterface::HGTTrimmedPlacement(cAvidaContext& ctx, const cGenome& offspring, 801 807 fragment_list_type::iterator& selected, 802 808 substring_match& location) { … … 812 818 813 819 814 /*! Random selection of the fragment used for HGT mutation, located at a random position.820 /*! Place the fragment at a random location. 815 821 816 Here we select a random fragment and a random location for thatfragment within the offspring.822 Here we select a random location for the fragment within the offspring. 817 823 The beginning of the fragment location is selected at random, while the end is selected a 818 824 random distance (up to the length of the selected fragment * 2) instructions away. 819 825 */ 820 void cPopulationInterface::HGTRandom FragmentPlacement(cAvidaContext& ctx, const cGenome& offspring,826 void cPopulationInterface::HGTRandomPlacement(cAvidaContext& ctx, const cGenome& offspring, 821 827 fragment_list_type::iterator& selected, 822 828 substring_match& location) { -
development/source/main/cPopulationInterface.h
r3629 r3638 157 157 158 158 protected: 159 //! Random selection of the fragment used for HGT mutation, located at thebest match.160 void HGT RandomFragmentSelection(cAvidaContext& ctx, const cGenome& offspring,161 fragment_list_type::iterator& selected,162 substring_match& location);163 //! Random selection of the fragment used for HGT mutation, with redundant instructions trimmed.164 void HGTTrimmed FragmentSelection(cAvidaContext& ctx, const cGenome& offspring,165 fragment_list_type::iterator& selected,166 substring_match& location);167 //! Random selection of the fragment used for HGT mutation, located at a random position.168 void HGTRandom FragmentPlacement(cAvidaContext& ctx, const cGenome& offspring,169 fragment_list_type::iterator& selected,170 substring_match& location);159 //! Place the fragment at the location of best match. 160 void HGTMatchPlacement(cAvidaContext& ctx, const cGenome& offspring, 161 fragment_list_type::iterator& selected, 162 substring_match& location); 163 //! Place the fragment at the location of best match, with redundant instructions trimmed. 164 void HGTTrimmedPlacement(cAvidaContext& ctx, const cGenome& offspring, 165 fragment_list_type::iterator& selected, 166 substring_match& location); 167 //! Place the fragment at a random location. 168 void HGTRandomPlacement(cAvidaContext& ctx, const cGenome& offspring, 169 fragment_list_type::iterator& selected, 170 substring_match& location); 171 171 //! Support for stateful HGT mutations. 172 172 struct HGTSupport {