Re: CLP vs. plain old Prolog?
- From: andrew.verden@xxxxxxxxxxxxx (Dr Andrew R. Verden)
- Date: 29 Apr 2005 05:51:10 -0700
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
.
- Follow-Ups:
- Re: CLP vs. plain old Prolog?
- From: Robert Oschler
- Re: CLP vs. plain old Prolog?
- References:
- CLP vs. plain old Prolog?
- From: Robert Oschler
- CLP vs. plain old Prolog?
- Prev by Date: Re: Non dominating queens problem
- Next by Date: Re: Non dominating queens problem
- Previous by thread: Re: CLP vs. plain old Prolog?
- Next by thread: Re: CLP vs. plain old Prolog?
- Index(es):
Relevant Pages
|
|