Prolog CLP(FD)

Question 4 (3 marks)

As a conference program chair, you are to assign papers to reviewers, given facts of the form
paper(ID, Co-author1, Co-author2, Subject)
reviewer(Name, Subject1, Subject2)

where each paper is identified by its id number, co-authors (for simplicity assume no more than two; for single-authored papers, Co-author2 is filled with xxx), and subject area, and each reviewer is identified by name and two subject areas of expertise. For example, the input data may look like
paper(2, john, lily, ai).
paper(3, ken, xxx, database).
reviewer(audrey, ai, logic).

What we want is a paper review assignment satisfying

(1) No one reviews his/her own paper;
(2) For a reviewer to review an assigned paper, one of his/her areas of expertise must match the paper’s subject.
(3) Each paper is assigned to 2 reviewers; and
(4) No reviewer is assigned more than k papers, where k will be given as a fact: workLoadAtMost(k).
You should write a program so that a paper assignment is generated by
?- assign(W1,W2).
where W1 and W2 denote a list of papers assigned to reviewers. Positions in a list represent a paper ID. E.g.
W1 = [lily,john,…]
W2 =[peter, ann,…]
means that paper #1 is assigned to lily and peter, and paper #2 to john and ann, etc. Papers will be numbered consecutively starting from 1. See this instance for an example.