First attempt at evaluating the quality of matchings.
[match/match.git] / program / Test.hs
index e684859..1530aa9 100644 (file)
@@ -4,24 +4,28 @@ module Test (
        module TestUtils,
        
        -- Generate instances.
-       module Instance,
-       module InstanceGenerator,
+       module PMInstance,
+       module PMInstanceGenerator,
        
        -- Solve instances.
        module ProposalMatcher,
-       module ProposalMatcherConfig,
+       module PMDefaults,
        
        -- Run randomized things.
        module System.Random,
-       module RandomizedMonad
+       module RandomizedMonad,
+       
+       -- Evaluate.
+       module Evaluation
 ) where
 import TestUtils
-import Instance
-import InstanceGenerator
+import PMInstance
+import PMInstanceGenerator
 import ProposalMatcher
-import ProposalMatcherConfig hiding (Wt)
+import PMDefaults
 import System.Random
 import RandomizedMonad
+import Evaluation
 
 -- Other imports we need
 import BellmanFord
@@ -37,7 +41,7 @@ myGraph = mkGraph [(0, ()), (1, ()), (2, ())]
 
 bfResult = bellmanFord snd 0 myGraph
 
-flowArray = minCostFlow (0, 2) fst (const 1) snd myGraph (0, 1)
+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
@@ -62,12 +66,17 @@ myPrefs = transposeArray $ listArray ((0,0), (myNumProps-1,myNumRvrs-1)) [
        15, 25, 20, 20, 15
        ] :: UArray (Int, Int) Wt
 
-myInst = Instance myNumRvrs myNumProps (constArray (0, myNumRvrs-1) 1) myPrefs
+myInst = PMInstance myNumRvrs myNumProps (constArray (0, myNumRvrs-1) 1) myPrefs
 
-rdnResult = doReduction myInst
+rdnResult = doReduction pmDefaults myInst
 ReductionResult rrg rrso rrsi rreib rredi = rdnResult
-rdnFlowArray = minCostFlow rreib reIdx reCap reCost rrg (rrso, rrsi)
+rdnFlowArray = minCostFlow pmDefaults rreib reIdx reCap reCost rrg (rrso, rrsi)
 rrg2 = flowAnnotate rrg rdnFlowArray
-myMatching = doMatching myInst
+myMatching = doMatching pmDefaults myInst
 
 iGraph = showInstanceAsGraph myInst myMatching -- Visualize me!
+
+-- Evaluation!
+eInst = runRandom myGen $ randomInstance 20 50
+eval1 = doEvaluateMatching pmDefaults eInst
+eval2 = doEvaluateMatching pmDefaults{loadTolerance = 2} eInst