diff --git a/src/MA/Functors/Powerset.hs b/src/MA/Functors/Powerset.hs index fdef686010147af4f5d215d81cb454ede98f164b..b3695d9df5ba8b4e8fd9bfe7e7e729fa97f2fd4d 100644 --- a/src/MA/Functors/Powerset.hs +++ b/src/MA/Functors/Powerset.hs @@ -39,7 +39,7 @@ powerset = FunctorDescription prefix ((L.symbol "P" <|> L.symbol "Ƥ") >> pure Powerset) } -data PowerWeight = PowerWeight {-# UNPACK #-} !Int {-# UNPACK #-} !Int +data PowerWeight = PowerWeight {-# UNPACK #-} !Bool {-# UNPACK #-} !Int deriving (Show,Eq) newtype PowerH3 = PowerH3 Word8 @@ -53,7 +53,7 @@ mkPowerH3 !a !b !c = PowerH3 $ set 0 a .|. set 1 b .|. set 2 c -- | No edge labels type instance Label Powerset = () --- | Tuple of (|edgesToC\S|, |edgesToS|) +-- | Tuple of (Edges to X\C, |edgesToC|) type instance Weight Powerset = PowerWeight -- | Does this state have at least one successor? type instance H1 Powerset = Bool @@ -77,7 +77,7 @@ instance ParseMorphism Powerset where instance RefinementInterface Powerset where init :: H1 Powerset -> [Label Powerset] -> Weight Powerset - init _ = PowerWeight 0 . length + init _ = PowerWeight False . length update :: [Label Powerset] -> Weight Powerset -> (Weight Powerset, H3 Powerset, Weight Powerset) @@ -85,8 +85,8 @@ instance RefinementInterface Powerset where let toS = length labels toCwithoutS = toC - toS - !weightToS = PowerWeight (toRest + toCwithoutS) toS - !h3 = mkPowerH3 (toRest > 0) (toCwithoutS > 0) (toS > 0) - !weightToCwithoutS = PowerWeight (toRest + toS) toCwithoutS + !weightToS = PowerWeight (toRest || toCwithoutS > 0) toS + !h3 = mkPowerH3 toRest (toCwithoutS > 0) (toS > 0) + !weightToCwithoutS = PowerWeight (toRest || toS > 0) toCwithoutS in (weightToS, h3, weightToCwithoutS) diff --git a/tests/MA/Algorithm/InitializeSpec.hs b/tests/MA/Algorithm/InitializeSpec.hs index c6001954b872aaab6b982bed38c145e535725ced..20de863ba09089b8b02d397a45ac49d9559f1bdf 100644 --- a/tests/MA/Algorithm/InitializeSpec.hs +++ b/tests/MA/Algorithm/InitializeSpec.hs @@ -69,7 +69,7 @@ lastWSpec = describe "returned lastW vector" $ do it "works with some edges" $ getLastW [True, True] [(0, 1), (0, 0), (1, 0)] - `shouldBe` [PowerWeight 0 2, PowerWeight 0 2, PowerWeight 0 1] + `shouldBe` [PowerWeight False 2, PowerWeight False 2, PowerWeight False 1] enc :: [h1] -> [(State, label, State)] -> Encoding label h1 diff --git a/tests/MA/Algorithm/SplitSpec.hs b/tests/MA/Algorithm/SplitSpec.hs index 1c0a7b58752300c679c40d1a4739be8f8c9a6837..e2e035fff2abd74374a29ba394957083e6480b97 100644 --- a/tests/MA/Algorithm/SplitSpec.hs +++ b/tests/MA/Algorithm/SplitSpec.hs @@ -127,10 +127,10 @@ updateBlockSpec = describe "updateBlock" $ do lw <- view (_1 . lastWL) >>= lift . V.freeze lift (lw & V.toList & mapM readSTRef) in res - `shouldBe` [ PowerWeight 2 1 - , PowerWeight 1 2 - , PowerWeight 1 2 - , PowerWeight 0 1 + `shouldBe` [ PowerWeight True 1 + , PowerWeight True 2 + , PowerWeight True 2 + , PowerWeight False 1 ] -- The idea here is that the edges from state 0 to block 1 cancel each other