private static ConvexBound ToConvexBound(this LineHalfPlane @this, Func <Vector, double> monitoredFunction, ConvexBound.Type type, double threshold)
 {
     return(ConvexBoundBuilder.Create(monitoredFunction, @this.Compute, type, threshold)
            .WithDistanceNorm(1, @this.ClosestPointL1)
            .WithDistanceNorm(2, @this.ClosestPointL2)
            .ToConvexBound());
 }
        public ConvexBound UpperBound(Vector initVector, double threshold)
        {
            var constantPart  = initVector.IndexedValues.Values.Sum();
            var parameters    = initVector.Map(Dimension, pi => - Math.Log(pi + 0.000000001) - 1);
            var lineHalfPlane = LineHalfPlane.Create(parameters, constantPart, threshold, Dimension);

            return(lineHalfPlane.ToConvexUpperBound(MonitoredFunction.Function, threshold));
        }
Esempio n. 3
0
 public void DistanceOutsideTest1()
 {
     var a            = 1;
     var b            = 4;
     var constantPart = 2;
     var threshold    = 12;
     var halfPlane    = LineHalfPlane.Create(CreateVec(a, b), constantPart, threshold);
     var closestL1    = halfPlane.ClosestPointL1(CreateVec(0, 0));
     var closestL2    = halfPlane.ClosestPointL2(CreateVec(0, 0));
 }
Esempio n. 4
0
        public ConvexBound UpperBound(Vector reducedVector, double threshold)
        {
            var    exps         = reducedVector.Enumerate(Dimension).Select(Math.Exp).ToVector();
            var    sum          = exps.Sum();
            Vector paramters    = exps.Enumerate(Dimension).Select(exp => - exp / sum).ToVector();
            double constantPart = ComputeEntropySketch(reducedVector) - paramters * reducedVector;

            return(LineHalfPlane.Create(paramters, constantPart, threshold, Dimension)
                   .ToConvexUpperBound(MonitoredFunction.Function, threshold));
        }
Esempio n. 5
0
        public ConvexBound LowerBound(Vector initialVector, double threshold)
        {
            if (threshold <= 0)
            {
                ClosestPointFromPoint closestPoint = (pt, nodeId) => double.MaxValue;
                return(ConvexBoundBuilder.Create(MonitoredFunction.Function, Compute, ConvexBound.Type.LoweBound, double.NegativeInfinity)
                       .WithDistanceNorm(1, closestPoint)
                       .WithDistanceNorm(2, closestPoint)
                       .ToConvexBound());
            }

            var currentNorm  = Compute(initialVector);
            var newPointNorm = threshold;
            var mulBy        = Math.Sqrt(newPointNorm / currentNorm);
            var point        = initialVector * mulBy;

            var constantPart  = -currentNorm;
            var parameters    = initialVector * 2;
            var lineHalfPlane = LineHalfPlane.Create(parameters, constantPart, threshold, Dimension);

            return(lineHalfPlane.ToConvexLowerBound(MonitoredFunction.Function, threshold));
        }
 public static ConvexBound ToConvexLowerBound(this LineHalfPlane @this, Func <Vector, double> monitoredFunction, double threshold)
 {
     return(@this.ToConvexBound(monitoredFunction, ConvexBound.Type.LoweBound, threshold));
 }