Commit 971bc7b0 authored by Hans-Peter Deifel's avatar Hans-Peter Deifel 🐢

wta: Only warn when transition count exceeds maximum

Changes the previous hard error into a warning. We now just cap the number of
transitions at the maximum which allows for easier bisection benchmarks that
start at a low number of states.
parent f7360b88
......@@ -16,10 +16,11 @@ import qualified Data.Map.Strict as M
import qualified Data.Set as S
import Data.Coerce
import Data.Ratio
import System.IO
import Types hiding ( spec )
import Probability
import IndexedTransition
import IndexedTransition ( IndexedTransition )
import qualified IndexedTransition
data EdgeConfig = ZeroFrequency Probability | NumTransitions Int
......@@ -126,14 +127,18 @@ genTransitions' :: Int -> Generator m (Vector (Vector (Transition m)))
genTransitions' numTransitions = do
wtaSpec <- asks spec
let n = numStates wtaSpec
m = IndexedTransition.maxIndex wtaSpec
maxT = IndexedTransition.maxIndex wtaSpec
-- FIXME Handle this case better. A nicer error output or something along this
-- line.
when (fromIntegral numTransitions > m) $ do
error $ "genTransitions: More transitions than possible requested"
transitions <- lift $ map (IndexedTransition.fromIndex wtaSpec) <$> uniqueTransitions numTransitions m
numTransitions' <- if (fromIntegral numTransitions > maxT) then do
let cap = IndexedTransition.fromIndexd maxT
lift $ hPutStrLn stderr ("warning: More transitions than possible requested. Capping at " <> show cap)
return (fromIntegral cap)
else do
return numTransitions
transitions <- lift $ map (IndexedTransition.fromIndex wtaSpec) <$> uniqueTransitions numTransitions' maxT
weightedTransitions <- (traverse.traverse.traverse) (const genMonoidValue) transitions
let byState = foldl' (\m (State s, t) -> M.insertWith (++) s [t] m) M.empty weightedTransitions
......
......@@ -11,7 +11,7 @@ import Data.Tuple
import Types
newtype IndexedTransition = Index Integer
newtype IndexedTransition = Index { fromIndexd :: Integer }
deriving newtype (Num, Eq, Ord)
deriving (Show)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment