Beispiel #1
0
        public List <ValueTuple <int, int, int> > BuildHiddenSet()
        {
            var rows = new List <ValueTuple <int, int, int> >();

            for (int i = 0; i < 200; i++)
            {
                var x = RndGenerator.RndInt32(0, 40);
                var y = RndGenerator.RndInt32(0, 40);
                rows.Add((x, y, HiddenFunction(x, y)));
            }
            return(rows);
        }
Beispiel #2
0
        public Expression CrossOver(Expression t1, Expression t2, double probswap = 0.7, bool top = true)
        {
            if (RndGenerator.RndDouble() < probswap && !top)
            {
                return(t2);
            }
            var result         = t1;
            var childrenExpsT1 = GetChildren(t1);
            var childrenExpsT2 = GetChildren(t2);

            if (childrenExpsT1 == null || childrenExpsT2 == null)
            {
                return(result);
            }
            var newChildren = new List <Expression>();

            foreach (var expression in childrenExpsT1)
            {
                newChildren.Add(CrossOver(expression, childrenExpsT2[RndGenerator.RndInt32(0, childrenExpsT2.Count)], probswap, false));
            }
            return(UpdateChildren(result, newChildren));
        }
Beispiel #3
0
        public static Expression MakeRandomTree(ParameterExpression[] paramExps, int maxTreeDepth = 4,
                                                double fpr = 0.5, double ppr = 0.6)
        {
            if (RndGenerator.RndDouble() < fpr && maxTreeDepth > 0)
            {
                (var funcExp, var pc) = ExpFactory.Choice();
                var children = new Expression[pc];
                for (int i = 0; i < pc; i++)
                {
                    children[i] = MakeRandomTree(paramExps, maxTreeDepth - 1, fpr, ppr);
                }
                return(funcExp(children));
            }

            else if (RndGenerator.RndDouble() < ppr)
            {
                return(paramExps[RndGenerator.RndInt32(0, paramExps.Length)]);
            }
            else
            {
                return(Expression.Constant(RndGenerator.RndInt32(0, 10)));
            }
        }