Re: CLP vs. plain old Prolog?



I think in general CLP is easier to engineer complex search problems
than Prolog alone. You are working more with sets (domains) and
constraints
which range from expressions to more complex rules over more variables
(global constraints, for example all_different([A,B,C]) ).

In Prolog you are generally interested in searching and pruning
solutions
in the generate-test framework. This works fine until the generate or
tests
pieces of code become very complex or the order in which the
generates/tests are applied affects the performance you require.

In CLP the generate-test is replaced by:

1. setting variables and their domains
2. applying constraints
3. finding a solution (labelling)

1. is done similar to the generate part of generate-test
2. is new but the code looks pretty much identical to the test code
you would otherwise write.
3. labelling is new, but for small problems you can simply pass all
variables into label/1 and standard propagation will give a
solution
faster (two orders of magnitude) than Prologs naive search.

For medium sized problems you can simply order the variables
"intelligently"

For large problems you might have to program some specific
propagation code.

Dont forget, with Prolog alone you have to rewrite the search or
consider
hacking parts of the code in C to get the same performance; all at
the price
of expressiveness and ultimately the maintainability of your code.

The engineering advantage CLP offers over Prolog (in my opinion) is
being able to add layers and layers of constraint code (point 2.) and
test these pieces
separately to know that your formulation of the problem and its
sub-parts
are correct.

It is not important in which order the constraints are applied so
there
test-ordering problem is not encountered.

In generate-test you often have the problem of knowing whether all
generates
are actually generated, in CLP this is from the domains of variables.

The search performance problem is shifted into the labelling part - a
separate
module and one which can be developed last, when required.

What is the disadvantage of CLP: That you have to model your value
sets as integers but this can be handled by mapping code.

I hope I have wetted your appetite for CLP.

For a ISO standard Prolog that does support CLP, COM, Java, C/C++,
Visual Studio... see www.ifcomputer.de !

Andrew
.



Relevant Pages

  • Re: CLP vs. plain old Prolog?
    ... > I think in general CLP is easier to engineer complex search problems ... > than Prolog alone. ... > in the generate-test framework. ... applying constraints ...
    (comp.lang.prolog)
  • CLP vs. plain old Prolog?
    ... Can someone point me to a "white paper" or summary that gives me the ... advantages of CLP over plain vanilla Prolog? ... what does CLP add to the party? ...
    (comp.lang.prolog)
  • Re: Solving quiz using Prolog
    ... CLP is a great extension to Logic Programming. ... never used it and thus I'm probably going for a plain Prolog solution. ... You seem quite fluent... ... > You can't instantiated X-es in the database like that. ...
    (comp.lang.prolog)
  • Re: swi-prolog or visual prolog or CLIPS
    ... As part of the MasterPiece software we solved a 2D packing problem with ... many complex alignment constraints using CLP implemented in IF/Prolog. ... I would not try to solve such a problem without CLP. ...
    (comp.lang.prolog)
  • Re: CLP(FD) Prolog: help needed with a simple problem
    ... > spanning tree. ... I can do it in Prolog, but I've no idea in CLP. ... > Any suggestion is welcome ...
    (comp.lang.prolog)