public void TestScoreFunction() { var gp = new Gp(); var input1ParamExp = Expression.Parameter(typeof(int), "input1"); var input2ParamExp = Expression.Parameter(typeof(int), "input2"); var paramArr = new[] { input1ParamExp, input2ParamExp }; var random1 = Gp.MakeRandomTree(paramArr); var func = Expression.Lambda <Func <int, int, int> >(random1, paramArr).Compile(); var hiddenset = gp.BuildHiddenSet(); var diff = gp.ScoreFunction(func, hiddenset); TestOutput(diff); var random2 = Gp.MakeRandomTree(paramArr); var func2 = Expression.Lambda <Func <int, int, int> >(random2, paramArr).Compile(); diff = gp.ScoreFunction(func2, hiddenset); TestOutput(diff); }
public void TestMutateResult() { var gp = new Gp(); var input1ParamExp = Expression.Parameter(typeof(int), "input1"); var input2ParamExp = Expression.Parameter(typeof(int), "input2"); var paramArr = new[] { input1ParamExp, input2ParamExp }; var random1 = Gp.MakeRandomTree(paramArr); var hiddenset = gp.BuildHiddenSet(); var func1 = random1.Compile <Func <int, int, int> >(paramArr); TestOutput(gp.ScoreFunction(func1, hiddenset)); TestOutput("-----------我是分隔线-------------"); var newExp = gp.Mutate(random1, paramArr); var funcMutate = newExp.Compile <Func <int, int, int> >(paramArr); TestOutput(gp.ScoreFunction(funcMutate, hiddenset)); }