New features from Tuesday call:
[match/match.git] / program / PMInstance.hs
CommitLineData
05a6f0ed 1module PMInstance where
967c39ef
MM
2import Data.Array.IArray
3import Data.Array.Unboxed
4import ArrayStuff
5import Formatter
6
8c5ee850 7type Wt = Double -- Can be any RealFrac.
96fe6497 8widenInteger x = fromInteger (toInteger x)
8c5ee850 9
56b565b1
MM
10data PMInstance = PMInstance {
11 -- I feel like I am in C, having to namespace these! I guess one
12 -- solution would be to have a typeclass for every field name. A
13 -- specialized solution might desugar to that.
14 pmiNumReviewers :: Int,
15 pmiNumProposals :: Int,
16 pmiRLoad :: UArray Int Wt,
17 pmiRPPref :: UArray (Int, Int) Wt, -- preference: -100 (COI), -99 to 100
578d7d98
MM
18 pmiRPExp :: UArray (Int, Int) Wt, -- expertise: 0 to 3
19 -- New 2011-07-19
20 -- Should we "jam" all three values that are functions of (i, j)/
21 pmiRPFix :: UArray (Int, Int) Bool,
22 pmiPNumReviews :: UArray Int Int
56b565b1
MM
23}
24
25-- Let us shoehorn in the new pref scale.
26prefOldToNew p' = 100 - 5 * p'
27prefNewToOld p = 20 - 0.2 * p
967c39ef 28
05a6f0ed 29instance Show PMInstance where
56b565b1
MM
30 show pmi =
31 let theRvrs = [0..pmiNumReviewers pmi - 1]; theProps = [0..pmiNumProposals pmi - 1] in
32 "Instance with " ++ show (pmiNumReviewers pmi) ++ " reviewers and " ++ show (pmiNumProposals pmi) ++ " proposals:\n" ++ formatTable (
5a07db44 33 ( "" : map (\i -> "R#" ++ show i ) theRvrs) :
56b565b1
MM
34 ( "RLoad" : map (\i -> show (pmiRLoad pmi ! i) ) theRvrs) :
35 map (\j -> ("P#" ++ show j) : map (\i -> show (pmiRPPref pmi ! (i, j)) ++ ":" ++ show (pmiRPExp pmi ! (i, j))) theRvrs) theProps
5a07db44 36 )
05a6f0ed 37
56b565b1
MM
38newtype PMatching = PMatching [(Int, Int)]
39 deriving Show