Merge branch 'master' into popl2012
[match/match.git] / program / Evaluation.hs
CommitLineData
eb6c3c9f
MM
1module Evaluation where
2import PMInstance
bc14b3b3 3import PMConfig
eb6c3c9f
MM
4import ProposalMatcher
5
6import Data.Array.IArray
7import Data.List
8import ArrayStuff
9
10type MatchingEvaluation = Array Int Wt
11
56b565b1
MM
12-- FIXME this is not really ported to separate preference and expertise
13
eb6c3c9f 14evaluateMatching :: PMConfig -> PMInstance -> PMatching -> MatchingEvaluation
578d7d98 15evaluateMatching cfg inst@(PMInstance numRvrs numProps rloadA prefA _ _ _) (PMatching matching) =
eb6c3c9f
MM
16 let reviewersByProposal = accumArray (flip (:)) []
17 (0, numProps-1) $ map (\(i,j) -> (j,i)) matching
18 :: Array Int [Int] in
19 aixmap (\j rl ->
20 -- Sort this proposal's reviews, best first.
21 let jPrefsInc = sort $ map (\i -> prefA ! (i,j)) rl in
22 -- Charge each review's assignmentCost.
35ce78e3
MM
23 sum $ zipWith (\wt prf -> wt * assignmentCost cfg prf)
24 (reviewEvalWeights cfg)
eb6c3c9f
MM
25 -- A missing review counts as a preference of 50 (really bad).
26 (jPrefsInc ++ repeat 50)
35ce78e3 27 )
eb6c3c9f
MM
28 reviewersByProposal
29
30doEvaluateMatching :: PMConfig -> PMInstance -> MatchingEvaluation
31doEvaluateMatching cfg inst =
32 let matching = doMatching cfg inst in
33 evaluateMatching cfg inst matching
34
35-- Sorted from negative cost changes (better in e2)
36-- to positive cost changes (worse in e2).
37sortedDiffEvaluations :: MatchingEvaluation -> MatchingEvaluation -> [Wt]
38sortedDiffEvaluations e1 e2 =
39 sort $ zipWith (-) (elems e1) (elems e2)