Make PMatching a newtype for clarity.
[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
05a6f0ed 10data PMInstance = PMInstance
967c39ef
MM
11 Int -- numReviewers
12 Int -- numProposals
13 (UArray Int Wt) -- ! reviewer -> relative load
14 (UArray (Int, Int) Wt) -- ! (reviewer, proposal) -> pref
15 deriving Eq
16
05a6f0ed
MM
17instance Show PMInstance where
18 show (PMInstance numRvrs numProps loadA prefA) =
5a07db44
MM
19 let theRvrs = [0..numRvrs-1]; theProps = [0..numProps-1] in
20 "Instance with " ++ show numRvrs ++ " reviewers and " ++ show numProps ++ " proposals:\n" ++ formatTable (
21 ( "" : map (\i -> "R#" ++ show i ) theRvrs) :
22 ( "RLoad" : map (\i -> show (loadA ! i) ) theRvrs) :
23 map (\j -> ("P#" ++ show j) : map (\i -> show (prefA ! (i, j))) theRvrs) theProps
24 )
05a6f0ed 25
e95df3f5
MM
26newtype PMatching = PMatching [(Int, Int)]
27 deriving Show