Make proposal-matcher configuration non-global to make it more practical to
[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
MM
5
6 -- Generate instances.
7 module Instance,
8 module InstanceGenerator,
9
10 -- Solve instances.
11 module ProposalMatcher,
8c5ee850 12 module PMDefaults,
967c39ef
MM
13
14 -- Run randomized things.
15 module System.Random,
fd0d2377 16 module RandomizedMonad
967c39ef 17) where
fd0d2377 18import TestUtils
967c39ef
MM
19import Instance
20import InstanceGenerator
21import ProposalMatcher
8c5ee850 22import PMDefaults
967c39ef
MM
23import System.Random
24import RandomizedMonad
967c39ef
MM
25
26-- Other imports we need
d7d9561e 27import BellmanFord
967c39ef
MM
28import Data.Array.IArray
29import Data.Array.Unboxed
d7d9561e
MM
30import Data.Graph.Inductive.Graph
31import Data.Graph.Inductive.Tree
967c39ef 32import ArrayStuff
2e7d5426 33
2ed0056e 34-- TESTING GRAPH ALGORITHMS
d7d9561e 35myGraph = mkGraph [(0, ()), (1, ()), (2, ())]
5a07db44 36 [(0, 1, (0, 2)), (0, 2, (1, 3)), (2, 1, (2, -2))] :: Gr () (Int, Int)
d7d9561e 37
5a07db44 38bfResult = bellmanFord snd 0 myGraph
d7d9561e 39
8c5ee850 40flowArray = minCostFlow pmDefaults (0, 2) fst (const 1) snd myGraph (0, 1)
5a07db44
MM
41
42myNCGraph = mkGraph [(0, ())] [(0, 0, -1)] :: Gr () Int
43bfNCResult = bellmanFord id 0 myNCGraph
44
2ed0056e 45-- PROPOSAL-MATCHING EXAMPLES
d7d9561e
MM
46-- Example from idea book p. 425
47{-
48(myNumRvrs, myNumProps) = (4, 3)
49
50myPrefsArray = 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)
54 ]
55-}
56
57(myNumRvrs, myNumProps) = (5, 3)
58
967c39ef
MM
59myPrefs = transposeArray $ listArray ((0,0), (myNumProps-1,myNumRvrs-1)) [
60 15, 10, 15, 40, 20,
61 30, 7, 10, 15, 15,
62 15, 25, 20, 20, 15
63 ] :: UArray (Int, Int) Wt
d7d9561e 64
fd0d2377 65myInst = Instance myNumRvrs myNumProps (constArray (0, myNumRvrs-1) 1) myPrefs
d7d9561e 66
8c5ee850 67rdnResult = doReduction pmDefaults myInst
5a07db44 68ReductionResult rrg rrso rrsi rreib rredi = rdnResult
8c5ee850 69rdnFlowArray = minCostFlow pmDefaults rreib reIdx reCap reCost rrg (rrso, rrsi)
5a07db44 70rrg2 = flowAnnotate rrg rdnFlowArray
8c5ee850 71myMatching = doMatching pmDefaults myInst
2ed0056e
MM
72
73iGraph = showInstanceAsGraph myInst myMatching -- Visualize me!