def isEQ(self, x): assert (Logprint.logPrint(4, "==>{} is {}".format(self, x)) == None) if self.inf > x or self.sup < x: raise FAIL("*** FAIL on {} is {} ***".format(self, x)) elif self.inf != self.sup: store.assign(self, 'inf', x) store.assign(self, 'sup', x) for c in self.constraints: c[0].setVal(c[1])
def isLE(self, x): assert (Logprint.logPrint(4, "==>{} isLE than {}".format(self, x)) == None) if x < self.sup: if x < self.inf: raise FAIL("*** FAIL on {} is less than {} ***".format( self, x)) else: store.assign(self, 'sup', x) if self.inf == self.sup: for c in self.constraints: c[0].setVal(c[1]) else: for c in self.constraints: c[0].decMax(c[1])
def isGE(self, x): assert (Logprint.logPrint(4, "==>{} isGE than {}".format(self, x)) == None) if x > self.inf: if x > self.sup: raise FAIL("*** FAIL on {} is more than {} ***".format( self, x)) else: store.assign(self, 'inf', x) if self.inf == self.sup: for c in self.constraints: c[0].setVal(c[1]) else: for c in self.constraints: c[0].incMin(c[1])
def checkRight(self): assert(Logprint.logPrint(4, "==>checkRight on {!s}".format(self))==None) if self.right == filter.UNKNOWN: b = self.const[1].ask() if b != filter.UNKNOWN: store.assign(self, 'right', b) if b == filter.FALSE: if self.left == filter.FALSE: raise FAIL("*** FAIL on {0} ***".format(self)) else: store.assign(self, 'left', filter.TRUE) self.const[0].tell() # Constructive disjunction store.assign(self, 'active', filter.FALSE) else: store.assign(self, 'left', filter.FALSE) store.assign(self, 'active', filter.FALSE)
def tell(self): assert(Logprint.logPrint(4, "==>tell on {!s}".format(self))==None) store.assign(self, 'active', filter.TRUE) self.checkLeft() self.checkRight()
def settled(self, b): assert(Logprint.logPrint(4, "settled: {!s} {!s}".format(self, b))==None) if b: store.assign(self, 'left', filter.TRUE) # try const1 store.assign(self, 'right', filter.FALSE) store.assign(self, 'active', filter.FALSE) self.const[0].tell() else: store.assign(self, 'left', filter.FALSE) # try const2 store.assign(self, 'right', filter.TRUE) store.assign(self, 'active', filter.FALSE) self.const[1].tell()