MCPcopy Create free account
hub / github.com/devosoft/avida / Divide_Main2RS

Method Divide_Main2RS

avida-core/source/cpu/cHardwareCPU.cc:2045–2131  ·  view source on GitHub ↗

Almost the same as Divide_Main, but only allows for one mutation on divde and resamples reverted offspring. RESAMPLING ONLY WORKS CORRECTLY WHEN ALL MUTIONS OCCUR ON DIVIDE!! AWC - 07/28/06 */

Source from the content-addressed store, hash-verified

2043 AWC - 07/28/06
2044 */
2045bool cHardwareCPU::Divide_Main2RS(cAvidaContext& ctx, const int div_point,
2046 const int extra_lines, double mut_multiplier)
2047{
2048
2049 //cStats stats = m_world->GetStats();
2050 const int child_size = m_memory.GetSize() - div_point - extra_lines;
2051
2052 // Make sure this divide will produce a viable offspring.
2053 const bool viable = Divide_CheckViable(ctx, div_point, child_size);
2054 if (viable == false) return false;
2055
2056 // Since the divide will now succeed, set up the information to be sent
2057 // to the new organism
2058 InstructionSequencePtr offspring_seq(new InstructionSequence(m_memory.Crop(div_point, div_point + child_size)));
2059 HashPropertyMap props;
2060 cHardwareManager::SetupPropertyMap(props, (const char*)m_inst_set->GetInstSetName());
2061 Genome offspring(GetType(), props, offspring_seq);
2062
2063 m_organism->OffspringGenome() = offspring;
2064
2065 // Cut off everything in this memory past the divide point.
2066 m_memory.Resize(div_point);
2067
2068 int totalMutations = 0;
2069 int mutations = 0;
2070 // RScount = 0;
2071
2072 bool fitTest = false;
2073
2074
2075 // Handle Divide Mutations...
2076 /*
2077 Do mutations until one of these conditions are satisified:
2078 we have resampled X times
2079 we have an offspring with the same number of muations as the first offspring
2080 that is not reverted
2081 the parent is steralized (usually means an implicit mutation)
2082 */
2083 for (int i = 0; i < 100; i++){
2084 if (i == 0){
2085 mutations = totalMutations = Divide_DoMutations(ctx, mut_multiplier,2);
2086 }
2087 else{
2088 Divide_DoExactMutations(ctx, mut_multiplier,mutations);
2089 m_world->GetStats().IncResamplings();
2090 }
2091
2092 fitTest = Divide_TestFitnessMeasures(ctx);
2093 //if (mutations > 1 ) cerr << "Too Many mutations!!!!!!!!!!!!!!!" << endl;
2094 if (!fitTest && mutations >= totalMutations) break;
2095
2096 }
2097 // think about making this mutations == totalMuations - though this may be too hard...
2098 /*
2099 if (RScount > 2)
2100 cerr << "Resampled " << RScount << endl;
2101 */
2102 //org could not be resampled beneath the hard cap -- it is then steraalized

Callers

nothing calls this directly

Calls 14

CropMethod · 0.80
OffspringGenomeMethod · 0.80
IncResamplingsMethod · 0.80
ChildFertileMethod · 0.80
IncFailedResamplingsMethod · 0.80
GetConfigMethod · 0.80
GetFTCostMethod · 0.80
ActivateDivideMethod · 0.80
ClearFlagsMethod · 0.80
InstructionClass · 0.50
GetSizeMethod · 0.45
ResizeMethod · 0.45

Tested by

no test coverage detected