Type and functions for multiple pareto fronts
Dependencies
Change contents
- edit in src/Math/ParetoFront.hs at line 6
Strata, - edit in src/Math/ParetoFront.hs at line 8
stratum,getStrata, - replacement in src/Math/ParetoFront.hs at line 14
import Data.List (transpose)import Data.List (partition, transpose) - edit in src/Math/ParetoFront.hs at line 70
newtype Strata a = Strata [Front a] deriving (Show) - edit in src/Math/ParetoFront.hs at line 75
stratum :: a -> Strata astratum a = Strata [singleton a]fuse :: Debatable a => Front a -> Front a -> (Front a, Front a, Front a)fuse (Front a) (Front b) = letm = map (flip map b . weigh) am' = transpose ms = map (not . any (== Dominated)) ms' = map (not . any (== Dominates)) m'(f1, t1) = partition snd $ zip a s(f2, t2) = partition snd $ zip b s'in (Front $ map fst (f1 ++ f2), Front $ map fst t1, Front $ map fst t2) - replacement in src/Math/ParetoFront.hs at line 89
Front a <> Front b = letm = map (flip map b . weigh) am' = transpose ms = map (not . any (== Dominated)) ms' = map (not . any (== Dominates)) m'in Front $ map fst $ filter snd $ zip a s ++ zip b s'a <> b = let(r, _, _) = fuse a bin r - edit in src/Math/ParetoFront.hs at line 96
instance Debatable a => Semigroup (Strata a) wherea <> b = mconcat [a,b]instance Debatable a => Monoid (Strata a) wheremempty = Strata []mconcat = Strata . rebuild . transpose . map getStrata whererebuild [] = []rebuild ([] : r) = rebuild rrebuild ([x] : r) = x : rebuild rrebuild ((x : y : s) : r) = let(f, p, q) = fuse x yr' = push p $ push q rin rebuild ((f: s): r')push (Front []) r = rpush q [] = [[q]]push q (s : r) = ((q:s) : r) - edit in src/Math/ParetoFront.hs at line 116[2.1488]
getStrata :: Strata a -> [Front a]getStrata (Strata l) = l