コード例 #1
0
ファイル: EquationEngine.cs プロジェクト: evanbb/SEIS610
        internal static Dequation BuildEquation(Individual individual)
        {
            //create a dynamic method, specifying the name, return type, and parameter types
            DynamicMethod dMeth = new DynamicMethod(individual.EquationKey, typeof(double), new Type[] { typeof(int) });
            //then get an IL generator to build the method body
            ILGenerator ilGenerator = dMeth.GetILGenerator();

            //have the individual append the necessary IL to our generator based on its structure
            individual.AppendIL(ilGenerator);
            //lastly, instruct our method to return
            ilGenerator.Emit(OpCodes.Ret);

            return (Dequation)dMeth.CreateDelegate(typeof(Dequation));
        }
コード例 #2
0
ファイル: Individual.cs プロジェクト: evanbb/SEIS610
 /// <summary>
 /// Creates a copy of this individual as a new instance.
 /// </summary>
 /// <returns>A new instance of this individaul</returns>
 public Individual CreateCopy()
 {
     var root = _root.GetCopy();
     root.IsLeftChild = false;
     var ind = new Individual(root);
     return ind;
 }