I have a couple of questions concerning specification of constraints. I want to know if there is a shorthand way to specify the relationship between the solutions in the variables. In the first case, I want to specify a greater than or equal relation. In the second case, I want to specify a distinct relationship. I can do this painstakingly by drawing out the complete relationships. I'd just like to know if there is a shorter way to do it.

1). If I have a list of constraint variables, is there a shorter way to define that the variables involve a decreasing value? In project euler problem #240, there are five 6-sided dice (sides numbered 1 to 6) that can be rolled so that the top three sum to 15. (I've already solved problem #240, it just gets to be long when we have twenty 12-sided dice).

   proc {TopDiceFiveSix ?Sol}
      D01|D02|D03|D04|D05|nil = Sol
   in
      D01::1#6 D02::1#6 D03::1#6 D04::1#6 D05::1#6

      D01 + D02 + D03 =: 15

      % This is the relations what I want to describe in shorthand???
      D01>=:D02
      D01>=:D03  D02>=:D03
      D01>=:D04  D02>=:D04  D03>=:D04
      D01>=:D05  D02>=:D05  D03>=:D05  D04>=:D05

     {FD.distribute split Sol}
   end

2). If I have a list of constraint variables, is it possible to define that not of the values can be equal? In project euler problem #68, we have the following "magic" 3-gon ring, filled with the numbers 1 to 6, and each line adding to nine. (I've also already solved problem #68, but it too gets to be long when dealing with a five-gon).

   proc {ThreeGonRing ?Sol}
      XA#RA#RB # XB#RB#RC # XC#RC#RA = Sol
   in
      RA::1#6 RB::1#6 RC::1#6
      XA::1#6 XB::1#6 XC::1#6

      % none of the nodes is equal (should be a shorthand for this???)
      RA\=:RB  RB\=:RC  RC\=:XA  XA\=:XB  XB\=:XC
      RA\=:RC  RB\=:XA  RC\=:XB  XA\=:XC
      RA\=:XA  RB\=:XB  RC\=:XC
      RA\=:XB  RB\=:XC
      RA\=:XC

      % each line adds to n
      XA + RA + RB =: XB + RB + RC
      XB + RB + RC =: XC + RC + RA

      % Working clockwise, starting from the group of three with the
   numerically lowest external node
      XA <: XB
      XA <: XC

     {FD.distribute split Sol}
   end


Thanks,
Chris Rathman

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

Reply via email to