예제 #1
0
 public override bool Propagate(FloatVariable changed, bool isUpper, Queue <Tuple <FloatVariable, bool> > q)
 {
     if (ReferenceEquals(changed, Result))
     {
         if (isUpper)
         // Upper bound of Result decreased
         {
             var inverse = inverseFunction(Result.Bounds.Upper);
             return(increasing ? input.BoundAbove(inverse) : input.BoundBelow(inverse));
         }
         else
         // Lower bound of result increased
         {
             var inverse = inverseFunction(Result.Bounds.Lower);
             return(increasing ? input.BoundBelow(inverse) : input.BoundAbove(inverse));
         }
     }
     else
     {
         Debug.Assert(ReferenceEquals(changed, input));
         if (isUpper)
         // Upper bound of input decreased
         {
             var res = function(input.Bounds.Upper);
             return(increasing ? Result.BoundAbove(res) : Result.BoundBelow(res));
         }
         else
         // Lower bound of input increased
         {
             var res = function(input.Bounds.Lower);
             return(increasing ? Result.BoundBelow(res) : Result.BoundAbove(res));
         }
     }
 }
예제 #2
0
        public override bool Propagate(FloatVariable changed, bool isUpper, Queue <Tuple <FloatVariable, bool> > q)
        {
            if (ReferenceEquals(changed, Result))
            {
                if (isUpper)
                {
                    // Upper bound of Result decreased
                    // Result = lhs+rhs, so lhs = Result-rhs, rhs = result-lhs
                    return(lhs.BoundAbove(Result.Bounds.Upper - rhs.Bounds.Lower, q) &&
                           rhs.BoundAbove(Result.Bounds.Upper - lhs.Bounds.Lower, q));
                }

                // Lower bound of Result increased
                return(lhs.BoundBelow(Result.Bounds.Lower - rhs.Bounds.Upper, q) &&
                       rhs.BoundBelow(Result.Bounds.Lower - lhs.Bounds.Upper, q));
            }
            else
            {
                Debug.Assert(ReferenceEquals(changed, lhs) || ReferenceEquals(changed, rhs));
                FloatVariable other = ReferenceEquals(changed, lhs) ? rhs : lhs;
                if (isUpper)
                {
                    // Upper bound decreased
                    return(Result.BoundAbove(lhs.Bounds.Upper + rhs.Bounds.Upper, q) &&
                           other.BoundBelow(Result.Bounds.Lower - changed.Bounds.Upper, q));
                }

                // Lower bound increased
                return(Result.BoundBelow(lhs.Bounds.Lower + rhs.Bounds.Lower, q) &&
                       other.BoundAbove(Result.Bounds.Upper - changed.Bounds.Lower, q));
            }
        }