(n)
This is the standard DeltaBlue benchmark. A long chain of equality
    constraints is constructed with a stay constraint on one end. An
    edit constraint is then added to the opposite end and the time is
    measured for adding and removing this constraint, and extracting
    and executing a constraint satisfaction plan. There are two cases.
    In case 1, the added constraint is stronger than the stay
    constraint and values must propagate down the entire length of the
    chain. In case 2, the added constraint is weaker than the stay
    constraint so it cannot be accomodated. The cost in this case is,
    of course, very low. Typical situations lie somewhere between these
    two extremes.
This is the standard DeltaBlue benchmark. A long chain of equality
    constraints is constructed with a stay constraint on one end. An
    edit constraint is then added to the opposite end and the time is
    measured for adding and removing this constraint, and extracting
    and executing a constraint satisfaction plan. There are two cases.
    In case 1, the added constraint is stronger than the stay
    constraint and values must propagate down the entire length of the
    chain. In case 2, the added constraint is weaker than the stay
    constraint so it cannot be accomodated. The cost in this case is,
    of course, very low. Typical situations lie somewhere between these
    two extremes.
This is the standard DeltaBlue benchmark . A long chain of equality constraints is constructed with a stay constraint on one end . An edit constraint is then added to the opposite end and the time is measured for adding and removing this constraint and extracting and executing a constraint satisfaction plan . There are two cases . In case 1 the added constraint is stronger than the stay constraint and values must propagate down the entire length of the chain . In case 2 the added constraint is weaker than the stay constraint so it cannot be accomodated . The cost in this case is of course very low . Typical situations lie somewhere between these two extremes .
def chain_test(n):
    """
    This is the standard DeltaBlue benchmark. A long chain of equality
    constraints is constructed with a stay constraint on one end. An
    edit constraint is then added to the opposite end and the time is
    measured for adding and removing this constraint, and extracting
    and executing a constraint satisfaction plan. There are two cases.
    In case 1, the added constraint is stronger than the stay
    constraint and values must propagate down the entire length of the
    chain. In case 2, the added constraint is weaker than the stay
    constraint so it cannot be accomodated. The cost in this case is,
    of course, very low. Typical situations lie somewhere between these
    two extremes.
    """
    global planner
    planner = Planner()
    prev, first, last = None, None, None

    # We need to go up to n inclusively.
    for i in range(n + 1):
        name = "v%s" % i
        v = Variable(name)

        if prev is not None:
            EqualityConstraint(prev, v, Strength.REQUIRED)

        if i == 0:
            first = v

        if i == n:
            last = v

        prev = v

    StayConstraint(last, Strength.STRONG_DEFAULT)
    edit = EditConstraint(first, Strength.PREFERRED)
    edits = []
    edits.append(edit)
    plan = planner.extract_plan_from_constraints(edits)

    for i in range(100):
        first.value = i
        plan.execute()

        if last.value != i:
            print("Chain test failed.")
def chain_test ( n ) : global planner planner = Planner ( ) prev , first , last = None , None , None # We need to go up to n inclusively. for i in range ( n + 1 ) : name = "v%s" % i v = Variable ( name ) if prev is not None : EqualityConstraint ( prev , v , Strength . REQUIRED ) if i == 0 : first = v if i == n : last = v prev = v StayConstraint ( last , Strength . STRONG_DEFAULT ) edit = EditConstraint ( first , Strength . PREFERRED ) edits = [ ] edits . append ( edit ) plan = planner . extract_plan_from_constraints ( edits ) for i in range ( 100 ) : first . value = i plan . execute ( ) if last . value != i : print ( "Chain test failed." )