2 -- Export everything we need to have fun in GHCi:
8 module PMInstanceGenerator,
11 module ProposalMatcher,
14 -- Run randomized things.
16 module RandomizedMonad
20 import PMInstanceGenerator
21 import ProposalMatcher
24 import RandomizedMonad
26 -- Other imports we need
28 import Data.Array.IArray
29 import Data.Array.Unboxed
30 import Data.Graph.Inductive.Graph
31 import Data.Graph.Inductive.Tree
34 -- TESTING GRAPH ALGORITHMS
35 myGraph = mkGraph [(0, ()), (1, ()), (2, ())]
36 [(0, 1, (0, 2)), (0, 2, (1, 3)), (2, 1, (2, -2))] :: Gr () (Int, Int)
38 bfResult = bellmanFord snd 0 myGraph
40 flowArray = minCostFlow pmDefaults (0, 2) fst (const 1) snd myGraph (0, 1)
42 myNCGraph = mkGraph [(0, ())] [(0, 0, -1)] :: Gr () Int
43 bfNCResult = bellmanFord id 0 myNCGraph
45 -- PROPOSAL-MATCHING EXAMPLES
46 -- Example from idea book p. 425
48 (myNumRvrs, myNumProps) = (4, 3)
50 myPrefsArray = array ((0,0), (myNumRvrs-1,myNumProps-1)) [
51 ((0, 0), 15), ((1, 0), 10), ((2, 0), 15), ((3, 0), 40),
52 ((0, 1), 30), ((1, 1), 7), ((2, 1), 10), ((3, 1), 15),
53 ((0, 2), 15), ((1, 2), 25), ((2, 2), 20), ((3, 2), 20)
57 (myNumRvrs, myNumProps) = (5, 3)
59 myPrefs = transposeArray $ listArray ((0,0), (myNumProps-1,myNumRvrs-1)) [
63 ] :: UArray (Int, Int) Wt
65 myInst = PMInstance myNumRvrs myNumProps (constArray (0, myNumRvrs-1) 1) myPrefs
67 rdnResult = doReduction pmDefaults myInst
68 ReductionResult rrg rrso rrsi rreib rredi = rdnResult
69 rdnFlowArray = minCostFlow pmDefaults rreib reIdx reCap reCost rrg (rrso, rrsi)
70 rrg2 = flowAnnotate rrg rdnFlowArray
71 myMatching = doMatching pmDefaults myInst
73 iGraph = showInstanceAsGraph myInst myMatching -- Visualize me!