Type and functions for multiple pareto fronts

quickdudley
Feb 9, 2022, 12:56 AM
2BUBV6QXELYZZH5LDQ2LTR5BDQCLP2L5WJ2OPAZKXA2ZGZKUGZMQC

Dependencies

Change contents

  • edit in src/Math/ParetoFront.hs at line 6
    [2.94]
    [2.94]
    Strata,
  • edit in src/Math/ParetoFront.hs at line 8
    [2.107]
    [2.107]
    stratum,
    getStrata,
  • replacement in src/Math/ParetoFront.hs at line 14
    [2.141][2.141:170]()
    import Data.List (transpose)
    [2.141]
    [2.170]
    import Data.List (partition, transpose)
  • edit in src/Math/ParetoFront.hs at line 70
    [2.1042]
    [2.1042]
    newtype Strata a = Strata [Front a] deriving (Show)
  • edit in src/Math/ParetoFront.hs at line 75
    [2.1094]
    [2.1094]
    stratum :: a -> Strata a
    stratum a = Strata [singleton a]
    fuse :: Debatable a => Front a -> Front a -> (Front a, Front a, Front a)
    fuse (Front a) (Front b) = let
    m = map (flip map b . weigh) a
    m' = transpose m
    s = map (not . any (== Dominated)) m
    s' = 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
    [2.1144][2.1144:1369]()
    Front a <> Front b = let
    m = map (flip map b . weigh) a
    m' = transpose m
    s = map (not . any (== Dominated)) m
    s' = map (not . any (== Dominates)) m'
    in Front $ map fst $ filter snd $ zip a s ++ zip b s'
    [2.1144]
    [2.1369]
    a <> b = let
    (r, _, _) = fuse a b
    in r
  • edit in src/Math/ParetoFront.hs at line 96
    [2.1438]
    [2.1438]
    instance Debatable a => Semigroup (Strata a) where
    a <> b = mconcat [a,b]
    instance Debatable a => Monoid (Strata a) where
    mempty = Strata []
    mconcat = Strata . rebuild . transpose . map getStrata where
    rebuild [] = []
    rebuild ([] : r) = rebuild r
    rebuild ([x] : r) = x : rebuild r
    rebuild ((x : y : s) : r) = let
    (f, p, q) = fuse x y
    r' = push p $ push q r
    in rebuild ((f: s): r')
    push (Front []) r = r
    push 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