コード例 #1
0
        /// <summary>
        /// Performs a crossover operation with this program and the sibling program.
        /// Crossover is performed on like branches, i.e. RCBs only crossover with sibling
        /// RCBs.
        /// </summary>
        /// <param name="sibling">Which sibling to crossover with</param>
        public override void Crossover(GPProgramBranch sibling)
        {
            GPProgramBranchADR rightADR = (GPProgramBranchADR)sibling;

            //
            // Select a branch
            byte WhichBranch = (byte)GPUtilities.rngNextInt(4);

            switch (WhichBranch)
            {
            case 0:
                Crossover(ref m_BranchADR.m_RCB, m_BranchADR.NodeCountRCB, ref rightADR.m_RCB, rightADR.NodeCountRCB);
                break;

            case 1:
                Crossover(ref m_BranchADR.m_RBB, m_BranchADR.NodeCountRBB, ref rightADR.m_RBB, rightADR.NodeCountRBB);
                break;

            case 2:
                Crossover(ref m_BranchADR.m_RUB, m_BranchADR.NodeCountRUB, ref rightADR.m_RUB, rightADR.NodeCountRUB);
                break;

            case 3:
                Crossover(ref m_BranchADR.m_RGB, m_BranchADR.NodeCountRGB, ref rightADR.m_RGB, rightADR.NodeCountRGB);
                break;
            }

            //
            // Make sure the program stats get updated for both programs
            m_Branch.UpdateStats();
            sibling.UpdateStats();
        }
コード例 #2
0
        /// <summary>
        /// This method directs the construction of an RPB
        /// </summary>
        /// <param name="Branch"></param>
        /// <param name="TreeBuild"></param>
        /// <returns></returns>
        public override bool Build(GPProgramBranch Branch, GPEnums.TreeBuild TreeBuild)
        {
            m_Branch = Branch;
            //
            // Call the recursive method to create the tree
            m_Branch.Root = BuildInternal(TreeBuild, m_Branch.DepthInitial, 0, false);

            //
            // Update the tree stats
            m_Branch.UpdateStats();

            //
            // Convert the program into array representation
            m_Branch.ConvertToArray(m_Config.FunctionSet);

            return(true);
        }