Changeset 1631

Show
Ignore:
Timestamp:
07/12/07 18:11:21 (1 year ago)
Author:
wrobe..@pld-linux.org
Message:

- recursive approach does not work in case of Constraint.solve_for (there

is no reccursion), try to detect juggling by counting constraint in
solver

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gaphas/branches/hw/gaphas/constraint.py

    r1624 r1631  
    3030 
    3131import operator 
    32 from decorators import recursive 
    3332 
    3433 
     
    121120        self.b = b 
    122121 
    123     @recursive(limit=5) 
    124122    def solve_for(self, var): 
    125123        assert var in (self.a, self.b) 
     
    160158        self.center = center 
    161159 
    162     @recursive(limit=5) 
    163160    def solve_for(self, var): 
    164161        assert var in (self.a, self.b, self.center) 
     
    198195        self.delta = delta 
    199196 
    200     @recursive(limit=5) 
    201197    def solve_for(self, var): 
    202198        if self.smaller.value > self.bigger.value - self.delta: 
     
    284280 
    285281 
    286     @recursive(limit=5) 
    287282    def solve_for(self, var): 
    288283        """ 
     
    386381        print 'b', self.balance 
    387382 
    388     @recursive(limit=5) 
    389383    def solve_for(self, var): 
    390384        b1, b2 = self.band 
     
    433427 
    434428 
    435     @recursive(limit=5) 
    436429    def solve_for(self, var): 
    437430        b1, b2 = self.band 
  • gaphas/branches/hw/gaphas/solver.py

    r1618 r1631  
    345345                else: 
    346346                    self._marked_cons.append(c) 
     347                    if __debug__: 
     348                        if self._marked_cons.count(c) > 100: 
     349                            raise JuggleError, 'Variable juggling detected, constraint %s' % c 
     350 
    347351 
    348352    def request_resolve(self, variable): 
     
    536540 
    537541 
     542 
     543 
     544class JuggleError(AssertionError): 
     545    """ 
     546    Variable juggling exception. Raised when constraint's variables are 
     547    marking each other dirty forever. 
     548    """ 
     549 
     550 
    538551__test__ = { 
    539552    'Solver.add_constraint': Solver.add_constraint,