PMConfig isn't just for ProposalMatcher anymore; it's about to gain settings for
[match/match.git] / program / Test.hs
... / ...
CommitLineData
1module 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
24import TestUtils
25import PMConfig
26import PMDefaults
27import PMInstance
28import PMInstanceGenerator
29import ProposalMatcher
30import System.Random
31import RandomizedMonad
32import Evaluation
33
34-- Other imports we need
35import BellmanFord
36import Data.Array.IArray
37import Data.Array.Unboxed
38import Data.Graph.Inductive.Graph
39import Data.Graph.Inductive.Tree
40import ArrayStuff
41
42-- TESTING GRAPH ALGORITHMS
43myGraph = mkGraph [(0, ()), (1, ()), (2, ())]
44 [(0, 1, (0, 2)), (0, 2, (1, 3)), (2, 1, (2, -2))] :: Gr () (Int, Int)
45
46bfResult = bellmanFord snd 0 myGraph
47
48flowArray = minCostFlow pmDefaults (0, 2) fst (const 1) snd myGraph (0, 1)
49
50myNCGraph = mkGraph [(0, ())] [(0, 0, -1)] :: Gr () Int
51bfNCResult = bellmanFord id 0 myNCGraph
52
53-- PROPOSAL-MATCHING EXAMPLES
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
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
72
73myInst = PMInstance myNumRvrs myNumProps (constArray (0, myNumRvrs-1) 1) myPrefs
74
75rdnResult = doReduction pmDefaults myInst
76ReductionResult rrg rrso rrsi rreib rredi = rdnResult
77rdnFlowArray = minCostFlow pmDefaults rreib reIdx reCap reCost rrg (rrso, rrsi)
78rrg2 = flowAnnotate rrg rdnFlowArray
79myMatching = doMatching pmDefaults myInst
80
81iGraph = showInstanceAsGraph myInst myMatching -- Visualize me!