30 lines
573 B
Prolog
30 lines
573 B
Prolog
schedule("BA1").
|
|
schedule("BA2").
|
|
|
|
group("G1", 5).
|
|
group("G2", 3).
|
|
group("G3", 2).
|
|
group("G4", 1).
|
|
|
|
rank("G1", "BA1", 2).
|
|
rank("G2", "BA1", 3).
|
|
rank("G3", "BA1", 1).
|
|
rank("G4", "BA1", 1).
|
|
|
|
rank("G1", "BA2", 3).
|
|
rank("G2", "BA2", 2).
|
|
rank("G3", "BA2", 4).
|
|
rank("G4", "BA2", 4).
|
|
|
|
|
|
1 = {matching(G,S) : schedule(S)} :- group(G, _).
|
|
|
|
count(Sum,S) :- Sum = #sum{ A,G : group(G,A), matching(G,S)}, schedule(S).
|
|
:- count(Sum, _), Sum > 6.
|
|
|
|
penalty(P) :- P = #sum{ R,G,S : rank(G,S,R), matching(G,S)}.
|
|
|
|
#minimize{ S : penalty(S)}.
|
|
#show matching/2.
|
|
#show count/2.
|
|
#show penalty/1. |