Whats wrong with this prolog optimization solution?
问题 solve(Amounts) :- Total = 1505, Prices = [215, 275, 335, 355, 420, 580], length(Prices, N), length(Amounts, N), Amounts :: 0..Total//min(Prices), Amounts * Prices #= Total, labeling(Amounts). 回答1: There is nothing wrong with it. It is the example from http://eclipseclp.org/examples/xkcd287.ecl.txt, and if you hadn't omitted the line :- lib(ic). which loads the interval constraint solver, it would work just fine in ECLiPSe Prolog. 回答2: Does also work in SWI-Prolog: ?- use_module(library(clpfd)