I'm currently struggling with the following problem: Let's assume this Pseudo-Code:
% Animal: ID, Type, Cost
animal (id1, dog, 300).
animal (id2, dog, 400).
animal (id3, dog, 600).
animal (id1, cat, 200).
animal (id2, cat, 400).
animal (id3, cat, 400).
animal (id1, fish, 20).
animal (id2, fish, 20).
animal (id3, fish, 20).
% Search the most expensive animals of each animal-type
most_expensive_animals(ID, Type, Cost) :- animal(ID, Type, Cost),
#max {X:animal(_, Type, X)} = Cost.
#show most_expensive_animals/3.
The Answer set would be:
most_expensive_animals(id3,dog,600)
most_expensive_animals(id2,cat,400)
most_expensive_animals(id3,cat,400)
most_expensive_animals(id1,fish,20)
most_expensive_animals(id2,fish,20)
most_expensive_animals(id3,fish,20)
What I want to achieve is a rule, which chooses just one of each animal type independent of the id (it can also happen randomly). The goal would be, that that the Answer set is the following:
most_expensive_animals(id3,dog,600)
most_expensive_animals(id2,cat,400)
most_expensive_animals(id1,fish,20)
In addition, the solutions which are kicked should be saved in an alternative Answer-Set like this:
alternative_most_expensive_animals(id3,cat,400)
alternative_most_expensive_animals(id2,fish,20)
alternative_most_expensive_animals(id3,fish,20)
I have followed some approaches with the choice rule, but without success. Can anyone help me further?
Thanks in advance!