Example #1
0
        private bool Add(SymbolicConstant <T> lower, SymbolicConstant <T> upper)
        {
            if (LessThan(upper, lower) == true)
            {
                // Cycle!
                return(false);
            }

            if (lower.Equals(upper))
            {
                return(true);
            }

            if (!_Orders.TryGetValue(lower, out var lowerNode))
            {
                lowerNode = new OrderNode(lower);
                _Orders.Add(lower, lowerNode);
            }

            if (!_Orders.TryGetValue(upper, out var upperNode))
            {
                upperNode = new OrderNode(upper);
                _Orders.Add(upper, upperNode);
            }

            upperNode.Previous.Add(lowerNode);
            lowerNode.Next.Add(upperNode);
            return(true);
        }
Example #2
0
        public bool?LessThan(SymbolicConstant <T> a, SymbolicConstant <T> b)
        {
            if (!a.Symbolic && !b.Symbolic)
            {
                return(a.Constant.CompareTo(b.Constant) < 0);
            }
            if (a.Equals(_Min) || b.Equals(_Max))
            {
                return(true);
            }
            if (a.Equals(_Max) || b.Equals(_Min))
            {
                return(false);
            }

            // Need to find a path from a to b
            if (!_Orders.TryGetValue(a, out var nodeA))
            {
                // ?!? Unable to compare
                return(null);
            }
            var result = nodeA.HasNext(b);

            if (result)
            {
                return(true);
            }

            result = nodeA.HasPrevious(b);
            if (result)
            {
                return(false);
            }

            return(null);
        }
Example #3
0
 public bool?LessOrEqual(SymbolicConstant <T> a, SymbolicConstant <T> b) => a.Equals(b) ? true : LessThan(a, b);