Untitled

 avatar
unknown
plain_text
2 years ago
442 B
5
Indexable
#const k=5.
item(1..k). % k expresses the number of items. item(1..k).
cost(1,2). % item 1 costs 2
cost(2,3). % item 2 costs 3 cost(3,2). % etc
cost(3,2).
cost(4,4).
cost(5,1).
#const budget=7.
% choose some subset of items
{ choose(I) : item(I) }.
:- choose(I1), choose(I2), I1!=I2, cost(I1,C1), cost(I2,C2), C1=C2.
:- M = #sum {1, choose(I): choose(I) }, M \ 2 = 1.
:- M = #sum {C, cost(I,C): choose(I), cost(I,C)} > budget.
#show choose/1.
Editor is loading...