Advertisement
kpfp_linux

EvoGIL: Driver contract

Oct 13th, 2013
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. type Individual = [Float]
  2. type Population = [Individual]
  3. type FitnessFun = Individual -> Float
  4.  
  5. class Driver d where
  6.   init                  :: Population
  7.                            -> ([Individual -> Float])  -- 'fitnesses', nie modyfikuje tego co dostaje
  8.                            -> d
  9.   population            :: d -> Population
  10.   steps                 :: d -> Iterator a -> Integer
  11.   get_indivs_inorder    :: d -> (Iterator Population, Int)  -- Konrad: IMHO teoretycznie zbędna bo istnieje
  12.                                                             -- `rank`, natomiast:
  13.                                                             -- 1) get_indivs_inorder driver = (rank x, f)
  14.                                                             --        where (x,f) = population driver
  15.                                                             --    na tyle proste, że nie ma problemu
  16.                                                             -- 2) możliwe optymalizacje?
  17.                                                             -- >> do konsultacji <<
  18.   rank                  :: d -> Iterator Population -> ([[Individual]], Int)
  19.                              -- populacja w kolejności od najlepszych do najgorszych (wg kryterium typu
  20.                              -- operator dominacji); zwraca info o ilości wywołań
  21.                              -- funkcji fitness.
  22.                              -- PS. Wywaliłem to, że ma być statyczna. Dlaczego? Bo functools.partial()
  23.                              -- nie zwraca klasy źródłowej…
  24.   finished              :: d -> Bool  -- czy obliczenia zakończone?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement