Alex Peake wrote:
I found one solution. I would appreciate critic.
Well, that's good! FD.atMost is exactly what you need to "count" the
occurrences of each number in the bag.
I tried with another model, which consists in choosing a domain such
that mapping this domain modulo 100 gives the bag. The variables in the
domain must then be pairwise distinct. But that introduces a symmetry
in the problem, and largely degrades performance. For instance, the
solution 7*7+37-11+19=94 is found 6 times, because the occurrences of 7
are coded as 7, 107, and 207.
Cheers,
raph
declare Problem
fun {Problem Package}
Buttons ButtonDomain
in
Buttons = [3#7 1#11 3#13 1#16 2#19 1#21 1#23 1#27 1#37 1#41 2#56 1#61
1#73 1#77 1#97]
ButtonDomain = {List.map Buttons fun {$ _#D} D end}
proc {$ Root}
A B C D E
in
Root = solution(a:A b:B c:C d:D e:E)
Root ::: ButtonDomain
{ForAll Buttons proc {$ B} {FD.atMost B.1 Root B.2} end}
A*B+C-D+E =: Package
B =<: A
E =<: C
{FD.distribute ff Root}
end
end
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users