Rename "desirability" to "preference" (much less awkward), with the
[match/match.git] / program / Test.hs
CommitLineData
967c39ef
MM
1module Test (
2 -- Export everything we need to have fun in GHCi:
967c39ef 3 module Test,
fd0d2377 4 module TestUtils,
967c39ef 5
bc14b3b3
MM
6 -- Manipulate configurations.
7 module PMConfig,
8 module PMDefaults,
9
967c39ef 10 -- Generate instances.
05a6f0ed
MM
11 module PMInstance,
12 module PMInstanceGenerator,
967c39ef
MM
13
14 -- Solve instances.
15 module ProposalMatcher,
967c39ef
MM
16
17 -- Run randomized things.
18 module System.Random,
eb6c3c9f
MM
19 module RandomizedMonad,
20
21 -- Evaluate.
22 module Evaluation
967c39ef 23) where
fd0d2377 24import TestUtils
bc14b3b3
MM
25import PMConfig
26import PMDefaults
05a6f0ed
MM
27import PMInstance
28import PMInstanceGenerator
967c39ef 29import ProposalMatcher
967c39ef
MM
30import System.Random
31import RandomizedMonad
eb6c3c9f 32import Evaluation
967c39ef
MM
33
34-- Other imports we need
d7d9561e 35import BellmanFord
967c39ef
MM
36import Data.Array.IArray
37import Data.Array.Unboxed
d7d9561e
MM
38import Data.Graph.Inductive.Graph
39import Data.Graph.Inductive.Tree
967c39ef 40import ArrayStuff
2e7d5426 41
2ed0056e 42-- TESTING GRAPH ALGORITHMS
d7d9561e 43myGraph = mkGraph [(0, ()), (1, ()), (2, ())]
5a07db44 44 [(0, 1, (0, 2)), (0, 2, (1, 3)), (2, 1, (2, -2))] :: Gr () (Int, Int)
d7d9561e 45
5a07db44 46bfResult = bellmanFord snd 0 myGraph
d7d9561e 47
8c5ee850 48flowArray = minCostFlow pmDefaults (0, 2) fst (const 1) snd myGraph (0, 1)
5a07db44
MM
49
50myNCGraph = mkGraph [(0, ())] [(0, 0, -1)] :: Gr () Int
51bfNCResult = bellmanFord id 0 myNCGraph
52
2ed0056e 53-- PROPOSAL-MATCHING EXAMPLES
d7d9561e
MM
54-- Example from idea book p. 425
55{-
56(myNumRvrs, myNumProps) = (4, 3)
57
58myPrefsArray = 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
967c39ef
MM
67myPrefs = 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
d7d9561e 72
05a6f0ed 73myInst = PMInstance myNumRvrs myNumProps (constArray (0, myNumRvrs-1) 1) myPrefs
d7d9561e 74
8c5ee850 75rdnResult = doReduction pmDefaults myInst
5a07db44 76ReductionResult rrg rrso rrsi rreib rredi = rdnResult
8c5ee850 77rdnFlowArray = minCostFlow pmDefaults rreib reIdx reCap reCost rrg (rrso, rrsi)
5a07db44 78rrg2 = flowAnnotate rrg rdnFlowArray
8c5ee850 79myMatching = doMatching pmDefaults myInst
2ed0056e
MM
80
81iGraph = showInstanceAsGraph myInst myMatching -- Visualize me!