2 -- Export everything we need to have fun in GHCi:
6 -- Manipulate configurations.
10 -- Generate instances.
12 module PMInstanceGenerator,
15 module ProposalMatcher,
17 -- Run randomized things.
19 module RandomizedMonad,
28 import PMInstanceGenerator
29 import ProposalMatcher
31 import RandomizedMonad
34 -- Other imports we need
36 import Data.Array.IArray
37 import Data.Array.Unboxed
38 import Data.Graph.Inductive.Graph
39 import Data.Graph.Inductive.Tree
42 -- TESTING GRAPH ALGORITHMS
43 myGraph = mkGraph [(0, ()), (1, ()), (2, ())]
44 [(0, 1, (0, 2)), (0, 2, (1, 3)), (2, 1, (2, -2))] :: Gr () (Int, Int)
46 bfResult = bellmanFord snd 0 myGraph
48 flowArray = minCostFlow pmDefaults (0, 2) fst (const 1) snd myGraph (0, 1)
50 myNCGraph = mkGraph [(0, ())] [(0, 0, -1)] :: Gr () Int
51 bfNCResult = bellmanFord id 0 myNCGraph
53 -- PROPOSAL-MATCHING EXAMPLES
54 -- Example from idea book p. 425
56 (myNumRvrs, myNumProps) = (4, 3)
58 myPrefsArray = array ((0,0), (myNumRvrs-1,myNumProps-1)) [
59 ((0, 0), 15), ((1, 0), 10), ((2, 0), 15), ((3, 0), 40),
60 ((0, 1), 30), ((1, 1), 7), ((2, 1), 10), ((3, 1), 15),
61 ((0, 2), 15), ((1, 2), 25), ((2, 2), 20), ((3, 2), 20)
65 (myNumRvrs, myNumProps) = (5, 3)
67 myPrefs = transposeArray $ listArray ((0,0), (myNumProps-1,myNumRvrs-1)) [
71 ] :: UArray (Int, Int) Wt
73 myInst = PMInstance myNumRvrs myNumProps (constArray (0, myNumRvrs-1) 1) myPrefs
75 rdnResult = doReduction pmDefaults myInst
76 ReductionResult rrg rrso rrsi rreib rredi = rdnResult
77 rdnFlowArray = minCostFlow pmDefaults rreib reIdx reCap reCost rrg (rrso, rrsi)
78 rrg2 = flowAnnotate rrg rdnFlowArray
79 myMatching = doMatching pmDefaults myInst
81 iGraph = showInstanceAsGraph myInst myMatching -- Visualize me!