def __init__(self, variables, formula, type='fd.Expression'): """variables is a list of variables which appear in the formula formula is a python expression that will be evaluated as a boolean""" AbstractConstraint.__init__(self, variables) self.formula = formula self.type = type try: self.filterFunc = Expression._FILTER_CACHE[formula] except KeyError: self.filterFunc = eval('lambda %s: %s' % \ (','.join(variables), formula), {}, {}) Expression._FILTER_CACHE[formula] = self.filterFunc
def __init__(self, variables): assert len(variables)>1 AbstractConstraint.__init__(self, variables) # worst case complexity self.__cost = len(variables) * (len(variables) - 1) / 2
def __init__(self, variables): AbstractConstraint.__init__(self, variables)
def __init__(self, var1, var2): AbstractConstraint.__init__(self, (var1, var2))
def __init__(self, variable, property, list_of_vals): AbstractConstraint.__init__(self, [variable ]) self.variable = variable self.property = property self.List = list_of_vals
def __init__(self, courses): AbstractConstraint.__init__(self, courses)
def __init__(self, variable, cls_or_restriction): AbstractConstraint.__init__(self, [ cls_or_restriction]) self.object = cls_or_restriction self.variable = variable
def __init__(self, prop, variable, cls_or_restriction): AbstractConstraint.__init__(self, [variable]) self.object = cls_or_restriction self.variable = variable self.prop = prop
def __init__(self, variable): AbstractConstraint.__init__(self, [variable]) self.variable = variable
def __init__(self, prop, restr, var, comp): AbstractConstraint.__init__(self, [restr]) self.prop = prop self.formula = "lambda x,y:len(x.getValuesPrKey(y)) %s int(%s)"% (comp, var)