Dear Mark, Your two threads simply implement different semantics! See below:
On Sun, Jul 19, 2009 at 10:05 PM, mark richardson <[email protected]>wrote: > Hi, > > I have a constraint based problem that implements constraints as explicitly > defined threads. An if statement guards whether the constraint is imposed or > not. For example one of the constraints could be something like: > > thread > if B==2 then > <post some constraint> > end > end This threads tries to enforce the logic statement (B==2 and <constraint>) or (B\=2). If B is different from 2, the logic statement is equivalent to 'true'. > My program isn't as simple as this and there IS a good reason why I'm doing > things this way :+), but it demonstrates the basic idea. > > My question is this (although I can't think of a simplified example to test > it with); would the above code block prove more efficient like this: > > thread > (B==2)=true > <post some constraint> > end This second threads enforces the logic statement (B==2 and <constraint>). In this case, if B is different from 2, the logic statement is equivalent to 'false'. Therefore both threads are not equivalent from a logic point of view. > Here I'm assuming this thread would signal failure whenever B was not 2 and > subsequently fail the space it was in. > In other words, are there any efficiency gains to be made by using failure > as a guard for the constraint rather than a logic conditional statement? > (Obviously I'm talking about a very large number of calls to this thread.) The first question is: which of the two logic statements correspond to the problem? For the first semantics, it is possible to use an 'or' statement, and let the posted constraint be evaluated in a subspace. or B=2 <post some constraint> [] B\=:2 end If the posted constraint fails, the 'or' statement will automatically enforce the remaining clause, i.e., B\=2. Note that this technique should be used with care, because it creates more computation spaces, but it can pay off if the posted constraint is likely to fail... Cheers, raph
_________________________________________________________________________________ mozart-users mailing list [email protected] http://www.mozart-oz.org/mailman/listinfo/mozart-users
