%%
%% A script for testing out approaches to the assignment problem
%% By Camillo J. Taylor - August 3 2006.
%%

%% Number of papers

npapers = 1500;

%% Number of reviewers

nreviewers = 500;

%% Average number of assignments per paper

nassign = 7;

%% Assignment limits
papers_per_reviewer = 10;
reviewers_per_paper = 3;

%% Construct the sparse Affinity matrix 

A = sprand(npapers,nreviewers,(nassign/nreviewers));

%% This line converts all of the entries in A to integers 
A = round (6*A);

%% Find the optimal assignment

B = FindAssignment (A, papers_per_reviewer, reviewers_per_paper);

%% You can use spy(B) to visualize the assignment results
spy (B);

%% Compute the row and column sums of B
row_sum = sum(B, 2); %% number of reviewers assigned to each paper.

col_sum = sum(B,1); %% number of papers assigned to each reviewer


['Number of incompletely assigned papers : ' num2str(nnz(row_sum < reviewers_per_paper))]
['Mean reviewer load : ' num2str(mean(col_sum))]
['Median reviewer load : ' num2str(median(col_sum))]

