- Implement CS2 min-cost-flow adaptor and generalize common min-cost-flow stuff
[match/match.git] / program / Instance.hs
1 module Instance (module Instance, Wt) where
2 import ProposalMatcherConfig (Wt)
3 import Data.Array.IArray
4 import Data.Array.Unboxed
5 import ArrayStuff
6 import Formatter
7
8 data Instance = Instance
9         Int                 -- numReviewers
10         Int                 -- numProposals
11         (UArray Int Wt)     -- ! reviewer -> relative load
12         (UArray (Int, Int) Wt) -- ! (reviewer, proposal) -> pref
13         deriving Eq
14
15 instance Show Instance where
16         show (Instance numRvrs numProps loadA prefA) =
17                 let theRvrs = [0..numRvrs-1]; theProps = [0..numProps-1] in
18                 "Instance with " ++ show numRvrs ++ " reviewers and " ++ show numProps ++ " proposals:\n" ++ formatTable (
19                             (       ""              : map (\i -> "R#" ++ show i       ) theRvrs) :
20                             (       "RLoad"         : map (\i -> show (loadA ! i)     ) theRvrs) :
21                         map (\j -> ("P#" ++ show j) : map (\i -> show (prefA ! (i, j))) theRvrs) theProps
22                 )