Almost the same as Divide_Main, but resamples reverted offspring. RESAMPLING ONLY WORKS CORRECTLY WHEN ALL MUTATIONS OCCUR ON DIVIDE!! AWC - 06/29/06 */
| 1850 | AWC - 06/29/06 |
| 1851 | */ |
| 1852 | bool cHardwareCPU::Divide_MainRS(cAvidaContext& ctx, const int div_point, |
| 1853 | const int extra_lines, double mut_multiplier) |
| 1854 | { |
| 1855 | |
| 1856 | //cStats stats = m_world->GetStats(); |
| 1857 | const int child_size = m_memory.GetSize() - div_point - extra_lines; |
| 1858 | |
| 1859 | // Make sure this divide will produce a viable offspring. |
| 1860 | const bool viable = Divide_CheckViable(ctx, div_point, child_size); |
| 1861 | if (viable == false) return false; |
| 1862 | |
| 1863 | // Since the divide will now succeed, set up the information to be sent |
| 1864 | // to the new organism |
| 1865 | InstructionSequencePtr offspring_seq(new InstructionSequence(m_memory.Crop(div_point, div_point + child_size))); |
| 1866 | HashPropertyMap props; |
| 1867 | cHardwareManager::SetupPropertyMap(props, (const char*)m_inst_set->GetInstSetName()); |
| 1868 | Genome offspring(GetType(), props, offspring_seq); |
| 1869 | |
| 1870 | m_organism->OffspringGenome() = offspring; |
| 1871 | |
| 1872 | // Cut off everything in this memory past the divide point. |
| 1873 | m_memory.Resize(div_point); |
| 1874 | |
| 1875 | unsigned |
| 1876 | totalMutations = 0, |
| 1877 | mutations = 0; |
| 1878 | //RScount = 0; |
| 1879 | |
| 1880 | |
| 1881 | bool |
| 1882 | fitTest = false; |
| 1883 | |
| 1884 | // Handle Divide Mutations... |
| 1885 | /* |
| 1886 | Do mutations until one of these conditions are satisified: |
| 1887 | we have resampled X times |
| 1888 | we have an offspring with the same number of muations as the first offspring |
| 1889 | that is not reverted |
| 1890 | the parent is steralized (usually means an implicit mutation) |
| 1891 | */ |
| 1892 | for (unsigned i = 0; i <= 100; i++) { |
| 1893 | if (i == 0) { |
| 1894 | mutations = totalMutations = Divide_DoMutations(ctx, mut_multiplier); |
| 1895 | } |
| 1896 | else{ |
| 1897 | mutations = Divide_DoMutations(ctx, mut_multiplier); |
| 1898 | m_world->GetStats().IncResamplings(); |
| 1899 | } |
| 1900 | |
| 1901 | fitTest = Divide_TestFitnessMeasures1(ctx); |
| 1902 | |
| 1903 | if (!fitTest && mutations >= totalMutations) break; |
| 1904 | |
| 1905 | } |
| 1906 | // think about making this mutations == totalMuations - though this may be too hard... |
| 1907 | /* |
| 1908 | if (RScount > 2) |
| 1909 | cerr << "Resampled " << RScount << endl; |
nothing calls this directly
no test coverage detected