1 module Evaluation where
6 import Data.Array.IArray
10 type MatchingEvaluation = Array Int Wt
12 evaluateMatching :: PMConfig -> PMInstance -> PMatching -> MatchingEvaluation
13 evaluateMatching cfg inst@(PMInstance numRvrs numProps rloadA prefA) (PMatching matching) =
14 let reviewersByProposal = accumArray (flip (:)) []
15 (0, numProps-1) $ map (\(i,j) -> (j,i)) matching
18 -- Sort this proposal's reviews, best first.
19 let jPrefsInc = sort $ map (\i -> prefA ! (i,j)) rl in
20 -- Charge each review's assignmentCost.
21 sum $ zipWith (\wt prf -> wt * assignmentCost cfg prf)
22 (reviewEvalWeights cfg)
23 -- A missing review counts as a preference of 50 (really bad).
24 (jPrefsInc ++ repeat 50)
28 doEvaluateMatching :: PMConfig -> PMInstance -> MatchingEvaluation
29 doEvaluateMatching cfg inst =
30 let matching = doMatching cfg inst in
31 evaluateMatching cfg inst matching
33 -- Sorted from negative cost changes (better in e2)
34 -- to positive cost changes (worse in e2).
35 sortedDiffEvaluations :: MatchingEvaluation -> MatchingEvaluation -> [Wt]
36 sortedDiffEvaluations e1 e2 =
37 sort $ zipWith (-) (elems e1) (elems e2)