Implementation of conjunction

34 views
Skip to first unread message

Miran

unread,
Mar 28, 2017, 9:06:26 AM3/28/17
to OscaR
Hi OscaR group,

We are currently preparing a paper, where we plan to use and discuss OscaR, and maybe make some translation towards its constructs.

Maybe I have not been able to find the documentation, if you have links it is also welcome.
For this I have a question with respect to the implementation for conjunction:
  • How is a conjunction implemented "behind the scenes", e.g. when finding a solution? Fx I know we can rectify it to a CPBoolVar, e.g. add(a.isLeEq(2) && a.isDiff(0)), is this the same to say that: add(a.isLeEq(2)); add(a.isDiff(0));. Is there any difference between these two way of expressing the constraints, or are they the same when searching for a solution? or is one faster?

Cheers,
Miran

Pierre Schaus

unread,
Mar 28, 2017, 10:11:56 AM3/28/17
to oscar...@googlegroups.com
Hi Miran,

On Tue, Mar 28, 2017 at 3:06 PM, Miran <mira...@gmail.com> wrote:
Hi OscaR group,

We are currently preparing a paper, where we plan to use and discuss OscaR, and maybe make some translation towards its constructs.

Maybe I have not been able to find the documentation, if you have links it is also welcome.
For this I have a question with respect to the implementation for conjunction:
  • How is a conjunction implemented "behind the scenes", e.g. when finding a solution? Fx I know we can rectify it to a CPBoolVar, e.g. add(a.isLeEq(2) && a.isDiff(0)),
You should not use reified constraints in this case as it is semantically equivalent to the decomposition into two standard constraints:
add(a <= 2)
add(a != 0)

 
  • is this the same to say that: add(a.isLeEq(2)); add(a.isDiff(0));.
the is.. versions return a boolean variable and add(booleanvar) force this var to be true.
this is why I say you don't need that in your case ;-)


 
  • Is there any difference between these two way of expressing the constraints, or are they the same when searching for a solution? or is one faster?
The faster ones is always to avoid the reified constraint when you can (I would personally consider it as a bad-smell ;-) )
 
Cheers

Pierre

Cheers,
Miran

--

---
You received this message because you are subscribed to the Google Groups "OscaR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to oscar-user+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Miran Hasanagic

unread,
Mar 28, 2017, 10:51:43 AM3/28/17
to oscar...@googlegroups.com
Hi Pierre,

Thanks! Yes, I agree they are semantically equal :-)

Aah okay, thats intersting then with the rectification, meaning they are not the same when used, with respect to speed, even semantically equal. As mentioned, I am looking at translation rules, which I need to approach in a “general way”, which means maybe sometimes making it a bit “worse” than manual implementation in some cases. Thats why i though of using this way and compare, and also argue for optimised translation rules (like the difference you described here)

Also it becomes close to when translating disjunction, where there is no way around rectification as far as i see, e.g. add(a.isLeEq(3) || a.isDiff(0)). These can of course not be added separate, and the CPBoolVar is the only one providing this support, i think, or?

You received this message because you are subscribed to a topic in the Google Groups "OscaR" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/oscar-user/Bpe4NBqeDV8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to oscar-user+...@googlegroups.com.

Pierre Schaus

unread,
Mar 28, 2017, 3:12:05 PM3/28/17
to oscar...@googlegroups.com
On Tue, Mar 28, 2017 at 4:51 PM, Miran Hasanagic <mira...@gmail.com> wrote:
Hi Pierre,

Thanks! Yes, I agree they are semantically equal :-)

Aah okay, thats intersting then with the rectification, meaning they are not the same when used, with respect to speed, even semantically equal. As mentioned, I am looking at translation rules, which I need to approach in a “general way”, which means maybe sometimes making it a bit “worse” than manual implementation in some cases. Thats why i though of using this way and compare, and also argue for optimised translation rules (like the difference you described here)

Also it becomes close to when translating disjunction, where there is no way around rectification as far as i see, e.g. add(a.isLeEq(3) || a.isDiff(0)). These can of course not be added separate, and the CPBoolVar is the only one providing this support, i think, or?

Yes that is true, but in your example this constraint (a.isLeEq(3) || a.isDiff(0)) is always satisfied so no need for posting it.
If you are making relations with respect to constants, I would rather do it by defining the domains appropriately.

ps: we say "reification" not "rectification" ;-)


 

To unsubscribe from this group and all its topics, send an email to oscar-user+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Miran Hasanagic

unread,
Mar 29, 2017, 3:07:27 AM3/29/17
to oscar...@googlegroups.com
Thanks for the feedback.

Yes, agreed it was not be best example of disjunction ;-)

Best,
Miran

To unsubscribe from this group and all its topics, send an email to oscar-user+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages