Matt McCutchen's Web Site
/
match
/
match.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add conflicts of interest to the InstanceGenerator and make some other cleanups.
[match/match.git]
/
program
/
Test.hs
diff --git
a/program/Test.hs
b/program/Test.hs
index
260ce0b
..
e684859
100644
(file)
--- a/
program/Test.hs
+++ b/
program/Test.hs
@@
-1,8
+1,7
@@
module Test (
-- Export everything we need to have fun in GHCi:
module Test (
-- Export everything we need to have fun in GHCi:
-
- -- See the results of examples.
module Test,
module Test,
+ module TestUtils,
-- Generate instances.
module Instance,
-- Generate instances.
module Instance,
@@
-14,28
+13,25
@@
module Test (
-- Run randomized things.
module System.Random,
-- Run randomized things.
module System.Random,
- module RandomizedMonad,
-
- -- Visualize graphs.
- module Data.Graph.Inductive.Graphviz
+ module RandomizedMonad
) where
) where
+import TestUtils
import Instance
import InstanceGenerator
import ProposalMatcher
import Instance
import InstanceGenerator
import ProposalMatcher
-import ProposalMatcherConfig
+import ProposalMatcherConfig
hiding (Wt)
import System.Random
import RandomizedMonad
import System.Random
import RandomizedMonad
-import Data.Graph.Inductive.Graphviz
-- Other imports we need
import BellmanFord
-- Other imports we need
import BellmanFord
-import NaiveMinCostFlow
import Data.Array.IArray
import Data.Array.Unboxed
import Data.Graph.Inductive.Graph
import Data.Graph.Inductive.Tree
import ArrayStuff
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, (0, 2)), (0, 2, (1, 3)), (2, 1, (2, -2))] :: Gr () (Int, Int)
myGraph = mkGraph [(0, ()), (1, ()), (2, ())]
[(0, 1, (0, 2)), (0, 2, (1, 3)), (2, 1, (2, -2))] :: Gr () (Int, Int)
@@
-46,14
+42,7
@@
flowArray = minCostFlow (0, 2) fst (const 1) snd myGraph (0, 1)
myNCGraph = mkGraph [(0, ())] [(0, 0, -1)] :: Gr () Int
bfNCResult = bellmanFord id 0 myNCGraph
myNCGraph = mkGraph [(0, ())] [(0, 0, -1)] :: Gr () Int
bfNCResult = bellmanFord id 0 myNCGraph
-data REdgeF = REdgeF Int Int Int Wt
-instance Show REdgeF where
- show (REdgeF idx cap flow cost) = "#" ++ (show idx) ++ ": "
- ++ (show flow) ++ " of " ++ (show cap) ++ " @ " ++ (show cost)
-flowAnnotate g fa =
- mkGraph (labNodes g) (map (\(n1, n2, REdge i ca co) ->
- (n1, n2, REdgeF i ca (fa ! i) co)) $ labEdges g) :: Gr () REdgeF
-
+-- PROPOSAL-MATCHING EXAMPLES
-- Example from idea book p. 425
{-
(myNumRvrs, myNumProps) = (4, 3)
-- Example from idea book p. 425
{-
(myNumRvrs, myNumProps) = (4, 3)
@@
-73,10
+62,12
@@
myPrefs = transposeArray $ listArray ((0,0), (myNumProps-1,myNumRvrs-1)) [
15, 25, 20, 20, 15
] :: UArray (Int, Int) Wt
15, 25, 20, 20, 15
] :: UArray (Int, Int) Wt
-myInst = Instance myNumRvrs myNumProps (
funcArray (0, myNumRvrs-1) $ const
1) myPrefs
+myInst = Instance myNumRvrs myNumProps (
constArray (0, myNumRvrs-1)
1) myPrefs
rdnResult = doReduction myInst
ReductionResult rrg rrso rrsi rreib rredi = rdnResult
rdnFlowArray = minCostFlow rreib reIdx reCap reCost rrg (rrso, rrsi)
rrg2 = flowAnnotate rrg rdnFlowArray
myMatching = doMatching myInst
rdnResult = doReduction myInst
ReductionResult rrg rrso rrsi rreib rredi = rdnResult
rdnFlowArray = minCostFlow rreib reIdx reCap reCost rrg (rrso, rrsi)
rrg2 = flowAnnotate rrg rdnFlowArray
myMatching = doMatching myInst
+
+iGraph = showInstanceAsGraph myInst myMatching -- Visualize me!