Rename "desirability" to "preference" (much less awkward), with the
[match/match.git] / program / Test.hs
1 module Test (
2         -- Export everything we need to have fun in GHCi:
3         module Test,
4         module TestUtils,
5         
6         -- Manipulate configurations.
7         module PMConfig,
8         module PMDefaults,
9         
10         -- Generate instances.
11         module PMInstance,
12         module PMInstanceGenerator,
13         
14         -- Solve instances.
15         module ProposalMatcher,
16         
17         -- Run randomized things.
18         module System.Random,
19         module RandomizedMonad,
20         
21         -- Evaluate.
22         module Evaluation
23 ) where
24 import TestUtils
25 import PMConfig
26 import PMDefaults
27 import PMInstance
28 import PMInstanceGenerator
29 import ProposalMatcher
30 import System.Random
31 import RandomizedMonad
32 import Evaluation
33
34 -- Other imports we need
35 import BellmanFord
36 import Data.Array.IArray
37 import Data.Array.Unboxed
38 import Data.Graph.Inductive.Graph
39 import Data.Graph.Inductive.Tree
40 import ArrayStuff
41
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)
45
46 bfResult = bellmanFord snd 0 myGraph
47
48 flowArray = minCostFlow pmDefaults (0, 2) fst (const 1) snd myGraph (0, 1)
49
50 myNCGraph = mkGraph [(0, ())] [(0, 0, -1)] :: Gr () Int
51 bfNCResult = bellmanFord id 0 myNCGraph
52
53 -- PROPOSAL-MATCHING EXAMPLES
54 -- Example from idea book p. 425
55 {- 
56 (myNumRvrs, myNumProps) = (4, 3)
57
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)
62         ]
63 -}
64
65 (myNumRvrs, myNumProps) = (5, 3)
66
67 myPrefs = transposeArray $ listArray ((0,0), (myNumProps-1,myNumRvrs-1)) [
68         15, 10, 15, 40, 20,
69         30,  7, 10, 15, 15,
70         15, 25, 20, 20, 15
71         ] :: UArray (Int, Int) Wt
72
73 myInst = PMInstance myNumRvrs myNumProps (constArray (0, myNumRvrs-1) 1) myPrefs
74
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
80
81 iGraph = showInstanceAsGraph myInst myMatching -- Visualize me!