Remove randomMap and randomRep definitions (obsoleted by RandomizedMonad).
[match/match.git] / program / InstanceGenerator.hs
CommitLineData
967c39ef
MM
1module InstanceGenerator where
2import Instance
3import System.Random
4import RandomizedMonad
5import Data.Array.IArray
6import ArrayStuff
7
967c39ef
MM
8numTopics = 20
9
10-- Expertise on each of the topics
11type ReviewerInfo = Array Int Double
12
13randomReviewerInfo = do
14 list <- sequence $ replicate numTopics $
15 withProb [(0.15, return 2), (0.4, return 1)] (return 0)
16 return $ listArray (0, numTopics-1) list
17
18-- One topic or two different topics
19data ProposalTopics = PTopic1 Int | PTopic2 Int Int
20
21--type ProposalAuthors = Maybe Int
22
23type ProposalInfo = (ProposalTopics, Wt)
24
25randomProposalTopics = do
26 t1 <- mrandomR (0, numTopics-1)
27 withProb [(0.5, return $ PTopic1 t1)] (do
28 t2 <- filterRandomized (/= t1) $ mrandomR (0, numTopics-1)
29 return $ PTopic2 t1 t2
30 )
31
32-- Add conflict of interest later.
33{--
34randomProposalAuthors = do
35 withProb [(0.5, return [])] (do
36 a1 <- mrandomR (0, numRvrs-1)
37 withProb [(0.5, return [a1])] (do
38 a2 <- filterRandomized (/= a1) $ mrandomR (0, numRvrs-1)
39 return [a1,a2]
40 )
41 )
42--}
43
44randomProposalInfo = do
45 topics <- randomProposalTopics
46 diff <- mrandomR (3, 5)
47 return (topics, fromInteger diff)
48
49expertnessToPref expertness = if expertness == 0 then 7
50 else if expertness == 1 then 5
51 else 3
52
53randomInstance :: Int -> Int -> Randomized Instance
54randomInstance numRvrs numProps = do
55 reviewerInfosList <- sequence $ replicate numRvrs $ randomReviewerInfo
56 -- reviewerProfs is an array of arrays.
57 -- A pair-indexed array might be better...
58 let reviewerInfos = listArray (0, numRvrs-1) reviewerInfosList :: Array Int ReviewerInfo
59 proposalInfosList <- sequence $ replicate numProps $ randomProposalInfo
60 let proposalInfos = listArray (0, numProps-1) proposalInfosList :: Array Int ProposalInfo
61 let loadA = funcArray (0, numRvrs-1) $ const 1
62 let prefA = funcArray ((0, 0), (numRvrs-1, numProps-1)) (\(i,j) ->
63 let
64 ii = reviewerInfos ! i
65 jj = proposalInfos ! j
66 topicPref = case fst jj of
67 PTopic1 t1 -> expertnessToPref (ii ! t1)
68 PTopic2 t1 t2 -> (expertnessToPref (ii ! t1) + expertnessToPref (ii ! t2)) / 2
69 in topicPref * snd jj - 4)
70 return $ Instance numRvrs numProps loadA prefA