Esempio n. 1
0
        public ComputeNodeResult ComputeInRange(Node candidate)
        {
            double gap = 0.0d;

            for (var i = 0; i <= _xBoundary.StepCount; ++i)
            {
                double x = _xBoundary.LowerBoundary + i * _xBoundary.Step;
                for (var j = 0; j <= _yBoundary.StepCount; ++j)
                {
                    double y = _yBoundary.LowerBoundary + j * _yBoundary.Step;

                    _resolvedIdentifiers["x"] = x;
                    _resolvedIdentifiers["y"] = y;

                    var v = new ComputeVisitor(_resolvedIdentifiers);
                    v.VisitNode(candidate);
                    gap += GapBetween(_dataSet[i, j], v.Result);
                }
            }
            return(new ComputeNodeResult(candidate, gap));
        }
Esempio n. 2
0
        private double[,] ComputeDataSet(Node secretFunction)
        {
            double[,] dataSet = new double[_xBoundary.StepCount + 1, _yBoundary.StepCount + 1];

            for (var i = 0; i <= _xBoundary.StepCount; ++i)
            {
                double x = _xBoundary.LowerBoundary + i * _xBoundary.Step;
                for (var j = 0; j <= _yBoundary.StepCount; ++j)
                {
                    double y = _yBoundary.LowerBoundary + j * _yBoundary.Step;

                    _resolvedIdentifiers["x"] = x;
                    _resolvedIdentifiers["y"] = y;

                    var v = new ComputeVisitor(_resolvedIdentifiers);
                    v.VisitNode(secretFunction);
                    dataSet[i, j] = v.Result;
                }
            }
            return(dataSet);
        }