CLP(FD): what is necessary?



Hi,
I am transferring a private discussion with Markus Triska
about clpfd library that is a part of SWI Prolog.
Markus asked me (after tracking my discussion on
polish newsgroup with AL) what is wrong with his clp library.
I will be talking only about ECLiPSe and SWI because
this two prologs are only that could be considered
as free.

From my point of view, clp(fd) library must be
extensible. By extensible I mean not only technical
possibilities to write their own global constraints
but also good manual (SWI lacks such manual). ECLiPSe
provides its users with quite good manual on creating
global constraints. Moreover good clp library should
have a wide range of global constraints. Good reference
is SICStus. Both ECLiPSe and SWI seems poor comparing to
SICStus.

In our discussion Markus suggested that
incorporating propia or CHR could be an answer for
the need of customized global contraints.
Propia is really interesting but for now it
is completely useless for me as my software should
run quickly. To achieve this I have to write special
global constraints from scratch. Any black-box approach
is not acceptable. This differs CLP from MIP by the way.

Regarding CHR I cannot say much as I have never
used this methodology. Nevertheless it looks quite
interesting.

Good environment for developing software that
is based on clp should provide its users with clean
and robust interface. By clean I mean mainly
clear syntax. Delay clauses
(http://eclipse.crosscoreop.com/doc/userman/umsroot111.html)
are good approach. In ECLiPSe there is also another
mechanism based on suspensions (Internally both
approaches are equivalent). The problem with
ECLiPSe is that it each suspension can have a
priority. This makes implementing constraints
really painful and makes ECLiPSe not robust.
I had not enough time to track in depth Markus' library.
My impression is that it is less cleaner that ECLiPSe's
suspension mechanism but it seems to be more robust
(no priorities!).

Very nice mechanism has B-Prolog. Also SICStus is
a good solution.

So going back to Markus' basic question: "How can
I improve clpfd library?". My answer is to:
1) write a documentation with examples :)
2) Create more clean syntax for defining constraints.
It is really important to have a clear syntax
from which a user could easily deduce conditions
that wakes the constraint. The conditions are:
- a variable has been instantiated
- a variable has been bounded (min or max)
- a variable's domain has been changed

In ECLiPSe you can use the following syntax
(such syntax is clean to me):

suspend(
propagator(X),
Priority,
[
X->inst, %instantiated variable
X->ic:min, %lower bound has been changed
X->constrained %a domain has been altered
]
)

In SICStus you would use:
fd_global(
propagator(X),
state(Y),
[
val(X),
min(X),
dom(X)
]
)

Developer having such code can very quickly
deduce the logic behind global constraint.
In this example propagator(X) is woken
if one of the following conditions occur:
- X has been instantiated
- lower bound of X has been changed
- X's domain has been changed

Mark, could you show us how you can do this in
SWI now?

2) develop global constraints that users could
use out-of-the-box.

3) do not try to pursuit ECLiPSe's propia or CHR.
Try to make as much as possible functionality
that SICStus' clp(fd) library offers.
It would have been MUCH better for ECLiPSe if developers
had implemented more global constraints
and not add new functionality (like propia).

4) Speed of execution is not always a matter. It is nice
to have fast prolog implementation but from my experience
the biggest speedup comes from specialised propagators
and not from specific implementation.

My opinion is that free prologs could be used for
proprietary software but their creators should
pay more attention to what is important to business
and business needs "just-enough" solutions and
not "do-everything" solutions.

Markus, I hope I have answered your questions.
I suppose that AL would drop his views on the
issue ;).

Best regards
--
[ Wit Jakuczun <W.Jakuczun [at] wlogsolutions.com> ]
[ WLOG Solutions http://www.wlogsolutions.com ]

.