The random instance generator and other improvements.
[match/match.git] / program / Test.hs
CommitLineData
967c39ef
MM
1module Test (
2 -- Export everything we need to have fun in GHCi:
3
4 -- See the results of examples.
5 module Test,
6
7 -- Generate instances.
8 module Instance,
9 module InstanceGenerator,
10
11 -- Solve instances.
12 module ProposalMatcher,
13 module ProposalMatcherConfig,
14
15 -- Run randomized things.
16 module System.Random,
17 module RandomizedMonad,
18
19 -- Visualize graphs.
20 module Data.Graph.Inductive.Graphviz
21) where
22import Instance
23import InstanceGenerator
24import ProposalMatcher
25import ProposalMatcherConfig
26import System.Random
27import RandomizedMonad
28import Data.Graph.Inductive.Graphviz
29
30-- Other imports we need
d7d9561e
MM
31import BellmanFord
32import UnitMinCostFlow
967c39ef
MM
33import Data.Array.IArray
34import Data.Array.Unboxed
d7d9561e
MM
35import Data.Graph.Inductive.Graph
36import Data.Graph.Inductive.Tree
967c39ef 37import ArrayStuff
2e7d5426 38
d7d9561e
MM
39myGraph = mkGraph [(0, ()), (1, ()), (2, ())]
40 [(0, 1, 2), (0, 2, 3), (2, 1, -2)] :: Gr () Double
41
42spTree1 = spTree 0 myGraph
43
44(flowVal, flowResid) = umcf 0 1 myGraph
45
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
967c39ef 65myInst = Instance myNumRvrs myNumProps (funcArray (0, myNumRvrs-1) $ const 1) myPrefs
d7d9561e 66
2e7d5426
MM
67rdnGraph = doReduction myInst
68(rdnFlowVal, rdnFlowResid) = umcf 0 1 rdnGraph
69rdnFlow = flowDiff rdnGraph rdnFlowResid
d7d9561e 70myMatching = doMatching myInst