Dear Jorge,
Actually, you do not have a space copy (Space.clone is never
called), just a plain nested space.
Ah, I did not realise that so far! Thank you for pointing that out.
Best
Torsten
On Jul 20, 2009, at 12:00 AM, Jorge Marques Pelizzoni wrote:
Strictly speaking, 'reify' is more expensive than 'if', but might
yield some propagation, and that's the whole point of constraint
programming. Actually, you do not have a space copy (Space.clone is
never called), just a plain nested space. Anyway, Torsten hit the
spot: it looks like you _really_ need to take a look at reified
constraints, if you haven't yet
Cheers,
Jorge.
2009/7/19 Torsten Anders <[email protected]>:
Dear Mark,
For applying constraints that depend on the truth value of other
constraints
you may also want to check out Oz' support for Constraint Combinators
(http://www.mozart-oz.org/documentation/system/
node44.html#chapter.combinator).
Raphael already mentioned or. If you want to make constrainable
whether some
arbitrary Oz code is executed or not then Combinator.'reify' might
be what
you are looking for. However, it is less efficient than your plain if
statement (it creates a space copy in the background). Here is a
simple
example (there is no example in the doc): B = 1 if X = Y, and B =
0 if X \=
Y.
B = {Combinator.'reify' proc {$} X = Y end}
Best
Torsten
On Jul 19, 2009, at 10:41 PM, mark richardson wrote:
Hi,
Thanks for your reply.
I really, really wasn't expecting this sort of reply. I'm now in the
uncomfortable position of trying to decide exactly what I DO
mean :+)
To put the problem into a clearer perspective, it concerns 3
variables A,B
and C.
A is a FD integer which represents a virtual actor, B is a FS which
represents one or more other virtual actors.
C is a FD integer which represents an interaction which is possible
between virtual actors depending upon characteristics of those
agents.
At the moment I'm using the format:
thread
if C==x then
<post constraints on A and B to match interaction x>
end
end
My thought was that I could possibly make speed improvements on
this by
replacing the 'if' statement with something which would cause the
thread to
fail sooner - namely the (C==x)=true idea.
Now I'm struggling to decide if saying something completely
different
semantically by doing this will fundamentally alter the function
of my
program or even whether I'm structuring my problem logic
correctly in the
first place.
I think some more thought on this might be in order :+)
Regards
Mark
Raphael Collet wrote:
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
--
Torsten Anders
Interdisciplinary Centre for Computer Music Research
University of Plymouth
Office: +44-1752-586219
Private: +44-1752-558917
http://strasheela.sourceforge.net
http://www.torsten-anders.de
_____________________________________________________________________
____________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users
______________________________________________________________________
___________
mozart-users mailing list mozart-
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users