From 89b7fd0dac0bef62999e7448fce184c19fe5bc6b Mon Sep 17 00:00:00 2001 From: Matt McCutchen Date: Mon, 28 Jul 2008 13:36:12 -0400 Subject: [PATCH] - More evaluation. - Introduce reviewer age into the instance generator. --- program/PMInstanceGenerator.hs | 4 +++- program/Test.hs | 5 ----- program/TestUtils.hs | 25 +++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/program/PMInstanceGenerator.hs b/program/PMInstanceGenerator.hs index 1143f61..97a546a 100644 --- a/program/PMInstanceGenerator.hs +++ b/program/PMInstanceGenerator.hs @@ -14,8 +14,10 @@ data ReviewerInfo = ReviewerInfo { } randomReviewerInfo numProps = do + -- "Older" reviewers are more likely to be expert on topics. + age <- mrandomR (0.5, 1.0) expns <- indRandomArray (0, numTopics-1) $ - withProb [(0.15, return 2), (0.4, return 1)] (return 0) + withProb [(0.15 * age, return 2), (0.4 * age, return 1)] (return 0) -- Samir: "Its often the case that each reviewer has a COI with say -- one proposal submitted either by their University (different faculty) -- or by a recent co-author." diff --git a/program/Test.hs b/program/Test.hs index 1530aa9..2e42be1 100644 --- a/program/Test.hs +++ b/program/Test.hs @@ -75,8 +75,3 @@ rrg2 = flowAnnotate rrg rdnFlowArray 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 diff --git a/program/TestUtils.hs b/program/TestUtils.hs index da68cf4..623391d 100644 --- a/program/TestUtils.hs +++ b/program/TestUtils.hs @@ -4,6 +4,7 @@ import Data.Array.IArray import Data.Graph.Inductive.Graph import Data.Graph.Inductive.Graphviz import Data.Graph.Inductive.Tree +import Data.List import System.IO import System.Random import System.Posix.IO @@ -11,7 +12,11 @@ import System.Posix.Time import System.Process import PMInstance import ProposalMatcher +import PMDefaults +import PMInstanceGenerator +import Evaluation import MonadStuff +import RandomizedMonad -- This module has stuff that is helpful for testing but isn't itself an example. @@ -76,3 +81,23 @@ goGraph theGraph = waitForProcess dotPid -- Then open the file. goFile fname + +-- Both-ways list difference +(/\) :: Eq a => [a] -> [a] -> ([a], [a]) +l1 /\ l2 = (l1 \\ l2, l2 \\ l1) + +-- Evaluation! +runEvaluation nr np = do + let inst = runRandom myGen $ randomInstance nr np + putStr (show inst ++ "\n") + let m0 = doMatching pmDefaults{loadTolerance = 0} inst + putStr ("Matching with load tolerance 0:\n" ++ show m0 ++ "\n") + let m1 = doMatching pmDefaults{loadTolerance = 1} inst + putStr ("Matching with load tolerance 1:\n" ++ show m1 ++ "\n") + putStr ("Differences:\n" ++ show (m0 /\ m1) ++ "\n") + let e0 = evaluateMatching pmDefaults{loadTolerance = 0} inst m0 + putStr ("Evaluation of first matching:\n" ++ show e0 ++ "\n") + let e1 = evaluateMatching pmDefaults{loadTolerance = 1} inst m1 + putStr ("Evaluation of second matching:\n" ++ show e1 ++ "\n") + putStr ("Evaluation differences:\n" ++ + show (sortedDiffEvaluations e0 e1) ++ "\n") -- 2.34.1