New paper-side gadget for PC + ERC
[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
18 pmiRPExp :: UArray (Int, Int) Wt -- expertise: 0 to 3
19}
20
21-- Let us shoehorn in the new pref scale.
22prefOldToNew p' = 100 - 5 * p'
23prefNewToOld p = 20 - 0.2 * p
967c39ef 24
05a6f0ed 25instance Show PMInstance where
56b565b1
MM
26 show pmi =
27 let theRvrs = [0..pmiNumReviewers pmi - 1]; theProps = [0..pmiNumProposals pmi - 1] in
28 "Instance with " ++ show (pmiNumReviewers pmi) ++ " reviewers and " ++ show (pmiNumProposals pmi) ++ " proposals:\n" ++ formatTable (
5a07db44 29 ( "" : map (\i -> "R#" ++ show i ) theRvrs) :
56b565b1
MM
30 ( "RLoad" : map (\i -> show (pmiRLoad pmi ! i) ) theRvrs) :
31 map (\j -> ("P#" ++ show j) : map (\i -> show (pmiRPPref pmi ! (i, j)) ++ ":" ++ show (pmiRPExp pmi ! (i, j))) theRvrs) theProps
5a07db44 32 )
05a6f0ed 33
56b565b1
MM
34newtype PMatching = PMatching [(Int, Int)]
35 deriving Show