This commit is contained in:
hellerve
2015-07-08 16:19:40 +02:00
parent 1c73752695
commit 2141291c4b
2 changed files with 23 additions and 1 deletions

20
knapsack.ecl Normal file
View File

@@ -0,0 +1,20 @@
:-lib(fd).
:-lib(fd_global).
:-lib(branch_and_bound).
knapsack(P, W, C, T, V) :-
length(P, N),
length(V, N),
minlist(W, Min),
D is C // Min,
V::0..D,
C #>= W*V,
T #= P*V,
sumlist(V, S),
O #= (-1)*T,
Negs #= (-1)*T,
bb_min(labeling(V), O, V, _, _, _),
bb_min(labeling(V), Negs, _).
test(P, V):-
knapsack([60, 100, 120], [15, 20, 30], 325, P, V).