module PMInstance where import Data.Array.IArray import Data.Array.Unboxed import ArrayStuff import Formatter type Wt = Double -- Can be any RealFrac. widenInteger x = fromInteger (toInteger x) data PMInstance = PMInstance { -- I feel like I am in C, having to namespace these! I guess one -- solution would be to have a typeclass for every field name. A -- specialized solution might desugar to that. pmiNumReviewers :: Int, pmiNumProposals :: Int, pmiRLoad :: UArray Int Wt, pmiRPPref :: UArray (Int, Int) Wt, -- preference: -100 (COI), -99 to 100 pmiRPExp :: UArray (Int, Int) Wt, -- expertise: 0 to 3 -- New 2011-07-19 -- Should we "jam" all three values that are functions of (i, j)/ pmiRPFix :: UArray (Int, Int) Bool, pmiPNumReviews :: UArray Int Int } -- Let us shoehorn in the new pref scale. prefOldToNew p' = 100 - 5 * p' prefNewToOld p = 20 - 0.2 * p instance Show PMInstance where show pmi = let theRvrs = [0..pmiNumReviewers pmi - 1]; theProps = [0..pmiNumProposals pmi - 1] in "Instance with " ++ show (pmiNumReviewers pmi) ++ " reviewers and " ++ show (pmiNumProposals pmi) ++ " proposals:\n" ++ formatTable ( ( "" : map (\i -> "R#" ++ show i ) theRvrs) : ( "RLoad" : map (\i -> show (pmiRLoad pmi ! i) ) theRvrs) : map (\j -> ("P#" ++ show j) : map (\i -> show (pmiRPPref pmi ! (i, j)) ++ ":" ++ show (pmiRPExp pmi ! (i, j))) theRvrs) theProps ) newtype PMatching = PMatching [(Int, Int)] deriving Show