Russ Abbott wrote:
I'm taken by your remark that Prolog is the COBOL of logic programming languages. Are you saying that logic programming in Oz is that much better than logic programming in Prolog or that FD in better than logic programming? Much of the recent discussion was a defense of Oz as a logic programming language, one that was not just a super FD system.

Here you deserve an explanation.

First, I apologize. I did not put a smiley next to the sentence, but should definitively have put one! I intended to be provocative, but only a bit. The reason is that I have been struggling with an element in the problem.

The constraint Nb.green > Nb.white is tricky to implement efficiently when you are limited to sequential programming with nondeterministic choice. The statement

   Nb.green > Nb.white = true

can only *check* that the values are ordered appropriately. Hence the need to instanciate the "color" variables before that check. I have tried to write that constraint such that it could instanciate the variables. I came up with something like

   %% X < Y in the range 1..N
   proc {LessThan N X Y}
      Alts = {Flatten
              {Map {List.number 1 N-1 1}
               fun {$ I}
                  {Map {List.number I+1 N 1}
                   fun {$ J} proc {$} X=I Y=J end end}
               end}}
   in
      {ChoiceList Alts}
   end

I thought it was pretty good, since it explicitly generates all pairs of values that satisfy X<Y. No need to instanciate the color variables anymore. But when I tried that version, suddenly the amount of search to find the solution was multiplied by 15 or so! I was out of intuition to explain the phenomenon. That explains my sad remark.

The fact is, I find FD programming simpler to reason about. You basically separate the concerns. First choose the model, constraints, and propagators that will ensure maximal pruning of the variables' domains. Then think about heuristics. Which variable, once determined, will allow much propagation on other variables?

I am probably mind-twisted myself ;-)

Cheers,
raph
_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to