Exemple #1
0
 public VariableInteger(string name, int lowerBound, int upperBound)
     : this()
 {
     this.Name        = name;
     this.domainStack = new Stack <DomInt>();
     this.domainStack.Push(new DomInt(DomainBinaryInteger.CreateDomain(lowerBound, upperBound), -1));
 }
Exemple #2
0
 public VariableInteger(string name, IList <int> elements)
     : this()
 {
     this.Name        = name;
     this.domainStack = new Stack <DomInt>();
     this.domainStack.Push(new DomInt(DomainBinaryInteger.CreateDomain(elements), -1));
 }
        public static IDomain <int> CreateDomain(int lowerBound, int upperBound)
        {
            if (lowerBound > upperBound)
            {
                throw new ArgumentException("Invalid Domain Bounds");
            }

            var domainImpl = new DomainBinaryInteger(lowerBound, upperBound);

            return(domainImpl);
        }
Exemple #4
0
        object ICloneable.Clone()
        {
            var clone = new DomainBinaryInteger {
                domain = new uint[this.domain.Length]
            };

            Array.Copy(this.domain, clone.domain, this.domain.Length);
            clone.lowerBound = this.lowerBound;
            clone.upperBound = this.upperBound;
            clone.size       = this.size;

            return(clone);
        }
        public IDomain <int> Clone()
        {
            var clone = new DomainBinaryInteger {
                domain = new uint[this.domain.Length]
            };

            Array.Copy(this.domain, clone.domain, this.domain.Length);
            clone.lowerBound = this.lowerBound;
            clone.upperBound = this.upperBound;
            clone.size       = this.size;
            clone.offset     = this.offset;

            return(clone);
        }
        public static IDomain <int> CreateDomain(IList <int> elements)
        {
            var lowerBound = elements.Min();
            var upperBound = elements.Max();

            var domainImpl = new DomainBinaryInteger(lowerBound, upperBound);

            for (var i = lowerBound; i <= upperBound; ++i)
            {
                if (!elements.Contains(i))
                {
                    domainImpl.RemoveFromDomain(i);
                }
            }

            return(domainImpl);
        }