Пример #1
0
    def __init__(self, name, scope, required_values, lower_bound, upper_bound):

        Constraint.__init__(self, name, scope)
        self._name = "NValues_" + name
        self._required = required_values
        self._lb = lower_bound
        self._ub = upper_bound
Пример #2
0
    def __init__(self, name, scope, satisfyingAssignments):
        '''Init by specifying a name and a set variables the constraint is over.
           Along with a list of satisfying assignments.
           Each satisfying assignment is itself a list, of length equal to
           the number of variables in the constraints scope.
           If sa is a single satisfying assignment, e.g, sa=satisfyingAssignments[0]
           then sa[i] is the value that will be assigned to the variable scope[i].


           Example, say you want to specify a constraint alldiff(A,B,C,D) for
           three variables A, B, C each with domain [1,2,3,4]
           Then you would create this constraint using the call
           c = TableConstraint('example', [A,B,C,D],
                               [[1, 2, 3, 4], [1, 2, 4, 3], [1, 3, 2, 4],
                                [1, 3, 4, 2], [1, 4, 2, 3], [1, 4, 3, 2],
                                [2, 1, 3, 4], [2, 1, 4, 3], [2, 3, 1, 4],
                                [2, 3, 4, 1], [2, 4, 1, 3], [2, 4, 3, 1],
                                [3, 1, 2, 4], [3, 1, 4, 2], [3, 2, 1, 4],
                                [3, 2, 4, 1], [3, 4, 1, 2], [3, 4, 2, 1],
                                [4, 1, 2, 3], [4, 1, 3, 2], [4, 2, 1, 3],
                                [4, 2, 3, 1], [4, 3, 1, 2], [4, 3, 2, 1]])
          as these are the only assignments to A,B,C respectively that
          satisfy A+B=C.
        '''

        Constraint.__init__(self, name, scope)
        self._name = "TableCnstr_" + name
        self.satAssignments = satisfyingAssignments
Пример #3
0
 def __init__(self, name, qi, qj, i, j):
     self._name = "Queen_" + name
     # print "qi:", qi.getValue()
     # print "qj:", qj.getValue()
     scope = [qi, qj]
     Constraint.__init__(self, name, scope)
     table = []
     for x in qi.domain():
         for y in qj.domain():
             diag = abs(x - y) == abs(i - j)
             if not diag and x != y:
                 table.append([x, y])
     self.satAssignments = table
Пример #4
0
 def __init__(self, name, qi, qj, i, j):
     scope = [qi, qj]
     Constraint.__init__(self, name, scope)
     self._name = "QueenCnstr_" + name
     self.i = i
     self.j = j
Пример #5
0
 def __init__(self, name, scope):
     Constraint.__init__(self, name, scope)
     self._name = "AllDiff_" + name
Пример #6
0
 def __init__(self, name, scope):
     if len(scope) != 2:
         print "Error Neq Constraints are only between two variables"
     Constraint.__init__(self, name, scope)
     self._name = "NeqCnstr_" + name
Пример #7
0
 def __init__(self, name, scope, flights):
     Constraint.__init__(self,name, scope)
     self._name = "coverAllFlight_" + name
     self._scope = scope
     self._flights = flights
Пример #8
0
 def __init__(self, name, scope, values):
     Constraint.__init__(self, name, scope)
     self._name = "all_Once " + name
     self._scope = scope
     self._values = values
Пример #9
0
 def __init__(self, name, scope, rest_frequence):
     Constraint.__init__(self, name, scope)
     self._name = "tafterc" + name
     self.rf = rest_frequence
Пример #10
0
 def __init__(self, name, scope, close_distance_buildings):
     Constraint.__init__(self, name, scope)
     self._name = "tafterc" + name
     self.cdb = close_distance_buildings
Пример #11
0
 def __init__(self, name, scope, lec_list, tut_list):
     Constraint.__init__(self, name, scope)
     self._name = "tafterc" + name
     self.lec_list = lec_list
     self.tut_list = tut_list
Пример #12
0
 def __init__(self, name, scope, i, j):
     if len(scope) != 2:
         print("Error Neq Constraints are only between two variables")
     Constraint.__init__(self, name, scope)
     self._name = "NeqCnstr_" + name
     self._abs_diff = abs(i - j)
Пример #13
0
 def __init__(self, name, scope, sp):
     if len(scope) != 2:
         print("Error BinaryClassConstraint are only between two variables")
     Constraint.__init__(self, name, scope)
     self._name = "BinaryCnstr_" + name
     self.sp = sp
Пример #14
0
 def __init__(self, name, scope, value):
     Constraint.__init__(self, name, scope)
     self._name = "checkAllFlights" + name
     self._value = value