-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorig-search.tex
23 lines (23 loc) · 947 Bytes
/
orig-search.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
search :: forall placement
. SearchStrategy placement
-> Scorer placement
-> [Seed]
-> (Scored placement, History placement)
search strat scorer (s0:seeds) = runFrom seeds firstGen (History []) 0
where
firstGen = map scorer $ gen0 strat s0
runFrom :: [Seed] -> [Scored placement] -> History placement
-> Age -> (Scored placement, History placement)
runFrom (s1:s2:seeeds) oldPop oldHist age =
let trialPop = nextGen strat s1 scorer oldPop
trialHist = (winner, age) `hcons` oldHist
winner = minimum trialPop
(newPop, newHist) =
if accept strat s2 trialHist age then
(trialPop, trialHist)
else
(oldPop, oldHist)
in if quit strat newHist age then -- TODO quit must change: consider best-ever, convergence
(fst $ minimum (unHistory newHist), newHist)
else
runFrom seeds newPop newHist (age + 1)