Rewrite Bellman-Ford and min-cost flow, especially to stop the latter from crashing.
[match/match.git] / program / Instance.hs
CommitLineData
967c39ef
MM
1module Instance where
2import Data.Array.IArray
3import Data.Array.Unboxed
4import ArrayStuff
5import Formatter
6
7type Wt = Double -- must implement RealFrac
8
9data Instance = Instance
10 Int -- numReviewers
11 Int -- numProposals
12 (UArray Int Wt) -- ! reviewer -> relative load
13 (UArray (Int, Int) Wt) -- ! (reviewer, proposal) -> pref
14 deriving Eq
15
16instance Show Instance where
17 show (Instance numRvrs numProps loadA prefA) =
5a07db44
MM
18 let theRvrs = [0..numRvrs-1]; theProps = [0..numProps-1] in
19 "Instance with " ++ show numRvrs ++ " reviewers and " ++ show numProps ++ " proposals:\n" ++ formatTable (
20 ( "" : map (\i -> "R#" ++ show i ) theRvrs) :
21 ( "RLoad" : map (\i -> show (loadA ! i) ) theRvrs) :
22 map (\j -> ("P#" ++ show j) : map (\i -> show (prefA ! (i, j))) theRvrs) theProps
23 )