PMConfig isn't just for ProposalMatcher anymore; it's about to gain settings for
[match/match.git] / program / Test.hs
index f8cb4ef..d0bd6e2 100644 (file)
@@ -1,48 +1,56 @@
 module Test (
        -- Export everything we need to have fun in GHCi:
-       
-       -- See the results of examples.
        module Test,
+       module TestUtils,
+       
+       -- Manipulate configurations.
+       module PMConfig,
+       module PMDefaults,
        
        -- Generate instances.
-       module Instance,
-       module InstanceGenerator,
+       module PMInstance,
+       module PMInstanceGenerator,
        
        -- Solve instances.
        module ProposalMatcher,
-       module ProposalMatcherConfig,
        
        -- Run randomized things.
        module System.Random,
        module RandomizedMonad,
        
-       -- Visualize graphs.
-       module Data.Graph.Inductive.Graphviz
+       -- Evaluate.
+       module Evaluation
 ) where
-import Instance
-import InstanceGenerator
+import TestUtils
+import PMConfig
+import PMDefaults
+import PMInstance
+import PMInstanceGenerator
 import ProposalMatcher
-import ProposalMatcherConfig
 import System.Random
 import RandomizedMonad
-import Data.Graph.Inductive.Graphviz
+import Evaluation
 
 -- Other imports we need
 import BellmanFord
-import UnitMinCostFlow
 import Data.Array.IArray
 import Data.Array.Unboxed
 import Data.Graph.Inductive.Graph
 import Data.Graph.Inductive.Tree
 import ArrayStuff
 
+-- TESTING GRAPH ALGORITHMS
 myGraph = mkGraph [(0, ()), (1, ()), (2, ())]
-       [(0, 1, 2), (0, 2, 3), (2, 1, -2)] :: Gr () Double 
+       [(0, 1, (0, 2)), (0, 2, (1, 3)), (2, 1, (2, -2))] :: Gr () (Int, Int)
 
-spTree1 = spTree 0 myGraph
+bfResult = bellmanFord snd 0 myGraph
 
-(flowVal, flowResid) = umcf 0 1 myGraph
+flowArray = minCostFlow pmDefaults (0, 2) fst (const 1) snd myGraph (0, 1)
 
+myNCGraph = mkGraph [(0, ())] [(0, 0, -1)] :: Gr () Int
+bfNCResult = bellmanFord id 0 myNCGraph
+
+-- PROPOSAL-MATCHING EXAMPLES
 -- Example from idea book p. 425
 {- 
 (myNumRvrs, myNumProps) = (4, 3)
@@ -62,9 +70,12 @@ myPrefs = transposeArray $ listArray ((0,0), (myNumProps-1,myNumRvrs-1)) [
        15, 25, 20, 20, 15
        ] :: UArray (Int, Int) Wt
 
-myInst = Instance myNumRvrs myNumProps (funcArray (0, myNumRvrs-1) $ const 1) myPrefs
+myInst = PMInstance myNumRvrs myNumProps (constArray (0, myNumRvrs-1) 1) myPrefs
+
+rdnResult = doReduction pmDefaults myInst
+ReductionResult rrg rrso rrsi rreib rredi = rdnResult
+rdnFlowArray = minCostFlow pmDefaults rreib reIdx reCap reCost rrg (rrso, rrsi)
+rrg2 = flowAnnotate rrg rdnFlowArray
+myMatching = doMatching pmDefaults myInst
 
-rdnGraph = doReduction myInst
-(rdnFlowVal, rdnFlowResid) = umcf 0 1 rdnGraph
-rdnFlow = flowDiff rdnGraph rdnFlowResid
-myMatching = doMatching myInst
+iGraph = showInstanceAsGraph myInst myMatching -- Visualize me!