Rename Instance -> PMInstance and introduce PMatching type.
[match/match.git] / program / PMInstance.hs
diff --git a/program/PMInstance.hs b/program/PMInstance.hs
new file mode 100644 (file)
index 0000000..d039810
--- /dev/null
@@ -0,0 +1,27 @@
+module PMInstance where
+import Data.Array.IArray
+import Data.Array.Unboxed
+import ArrayStuff
+import Formatter
+
+type Wt = Double -- Can be any RealFrac.
+numAsWt x = fromInteger (toInteger x)
+
+data PMInstance = PMInstance
+       Int                 -- numReviewers
+       Int                 -- numProposals
+       (UArray Int Wt)     -- ! reviewer -> relative load
+       (UArray (Int, Int) Wt) -- ! (reviewer, proposal) -> pref
+       deriving Eq
+
+instance Show PMInstance where
+       show (PMInstance numRvrs numProps loadA prefA) =
+               let theRvrs = [0..numRvrs-1]; theProps = [0..numProps-1] in
+               "Instance with " ++ show numRvrs ++ " reviewers and " ++ show numProps ++ " proposals:\n" ++ formatTable (
+                           (       ""              : map (\i -> "R#" ++ show i       ) theRvrs) :
+                           (       "RLoad"         : map (\i -> show (loadA ! i)     ) theRvrs) :
+                       map (\j -> ("P#" ++ show j) : map (\i -> show (prefA ! (i, j))) theRvrs) theProps
+               )
+
+type PMatching = [(Int, Int)]
+               
\ No newline at end of file