Make the evaluator's review weights configurable.
[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
12evaluateMatching :: PMConfig -> PMInstance -> PMatching -> MatchingEvaluation
13evaluateMatching cfg inst@(PMInstance numRvrs numProps rloadA prefA) matching =
14 let reviewersByProposal = accumArray (flip (:)) []
15 (0, numProps-1) $ map (\(i,j) -> (j,i)) matching
16 :: Array Int [Int] in
17 aixmap (\j rl ->
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.
35ce78e3
MM
21 sum $ zipWith (\wt prf -> wt * assignmentCost cfg prf)
22 (reviewEvalWeights cfg)
eb6c3c9f
MM
23 -- A missing review counts as a preference of 50 (really bad).
24 (jPrefsInc ++ repeat 50)
35ce78e3 25 )
eb6c3c9f
MM
26 reviewersByProposal
27
28doEvaluateMatching :: PMConfig -> PMInstance -> MatchingEvaluation
29doEvaluateMatching cfg inst =
30 let matching = doMatching cfg inst in
31 evaluateMatching cfg inst matching
32
33-- Sorted from negative cost changes (better in e2)
34-- to positive cost changes (worse in e2).
35sortedDiffEvaluations :: MatchingEvaluation -> MatchingEvaluation -> [Wt]
36sortedDiffEvaluations e1 e2 =
37 sort $ zipWith (-) (elems e1) (elems e2)