Adding the following rule to my code results in an error message (info: operation undefined (Max-Min)
):
rank_difference(Room, Deck, Diff) :-
played(Room, Deck),
Min = #min {Rank: seat(Player, Room, Deck), rank(Player, Rank)},
Max = #max {Rank: seat(Player, Room, Deck), rank(Player, Rank)},
Diff = Max - Min.
played(Room, Deck)
implies that there exists at least one seat(Player, Room, Deck)
predicate (in fact that there exist exactly 3 or 4) while rank(Player, Rank)
exists for each player so this isn't supposed to be an empty set issue.
Update - Runnable example (without any of the constraints):
#const nRounds = 4.
#const nPlayers = 13.
#const nRooms = 4.
#const nDecks = 10.
player(1..nPlayers).
room(1..nRooms).
deck(1..nDecks).
writer(1,1;2,2;3,3;4,4).
rank(Player, Player) :- player(Player).
nRounds { round(Player, 1..nDecks) } nRounds :- player(Player).
{ played(Room, Deck) } :- room(Room), deck(Deck).
3 { seat(Player, Room, Deck) : round(Player, Deck) } 4 :- played(Room, Deck).
rank_difference(Room, Deck, Diff) :-
played(Room, Deck),
Min = #min {Rank: seat(Player, Room, Deck), rank(Player, Rank)},
Max = #max {Rank: seat(Player, Room, Deck), rank(Player, Rank)},
Diff = Max - Min.