-- * Types
NodeList
, InstanceList
+ , NameList
, Placement
, Solution(..)
, Table(..)
type NodeList = Container.Container Node.Node
type InstanceList = Container.Container Instance.Instance
+-- | The type used to hold idx-to-name mappings
+type NameList = [(Int, String)]
-- | A separate name for the cluster score type
type Score = Double
{-| Converts a placement to string format -}
printSolutionLine :: InstanceList
- -> [(Int, String)]
- -> [(Int, String)]
+ -> NameList
+ -> NameList
-> Int
-> Int
-> Placement
{-| Converts a solution to string format -}
printSolution :: InstanceList
- -> [(Int, String)]
- -> [(Int, String)]
+ -> NameList
+ -> NameList
-> [Placement]
-> ([String], [[String]])
printSolution il ktn kti sol =
zip sol [1..]
-- | Print the node list.
-printNodes :: [(Int, String)] -> NodeList -> String
+printNodes :: NameList -> NodeList -> String
printNodes ktn nl =
let snl = sortBy (compare `on` Node.idx) (Container.elems nl)
snl' = map (\ n -> ((fromJust $ lookup (Node.idx n) ktn), n)) snl
ac3 = (pdx, pnew):(sdx, snew):ac2
in ac3) nl il
--- | Compute the longest common suffix of a [(Int, String)] list that
+-- | Compute the longest common suffix of a NameList list that
-- | starts with a dot
-longestDomain :: [(Int, String)] -> String
+longestDomain :: NameList -> String
longestDomain [] = ""
longestDomain ((_,x):xs) =
let
"" $ filter (isPrefixOf ".") (tails x)
-- | Remove tails from the (Int, String) lists
-stripSuffix :: String -> [(Int, String)] -> [(Int, String)]
+stripSuffix :: String -> NameList -> NameList
stripSuffix suffix lst =
let sflen = length suffix in
map (\ (key, name) -> (key, take ((length name) - sflen) name)) lst
-> String -- ^ Instance data in text format
-> (Container.Container Node.Node,
Container.Container Instance.Instance,
- String, [(Int, String)], [(Int, String)])
+ String, NameList, NameList)
loadData ndata idata =
let
{- node file: name mem disk -}
-}
iterateDepth :: Cluster.Table -- ^ The starting table
-> Int -- ^ Remaining length
- -> [(Int, String)] -- ^ Node idx to name list
- -> [(Int, String)] -- ^ Inst idx to name list
+ -> Cluster.NameList -- ^ Node idx to name list
+ -> Cluster.NameList -- ^ Inst idx to name list
-> Int -- ^ Max node name len
-> Int -- ^ Max instance name len
-> [[String]] -- ^ Current command list