From ab271fc10a22c7767714990a35074731621c5f5f Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Sat, 14 Mar 2009 12:35:04 +0100 Subject: [PATCH] Show the step counter in the solution list This patch changes the solution list to include a step counter so that it's more clear these are successive steps (in a definite order), and not just an unordered list of changes. --- src/Cluster.hs | 10 ++++++---- src/hbal.hs | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Cluster.hs b/src/Cluster.hs index 284904693..7b69ef5dc 100644 --- a/src/Cluster.hs +++ b/src/Cluster.hs @@ -573,8 +573,9 @@ printSolutionLine :: InstanceList -> Int -> Int -> Placement + -> Int -> (String, [String]) -printSolutionLine il ktn kti nmlen imlen plc = +printSolutionLine il ktn kti nmlen imlen plc pos = let pmlen = (2*nmlen + 1) (i, p, s, c) = plc @@ -588,8 +589,8 @@ printSolutionLine il ktn kti nmlen imlen plc = ostr = (printf "%s:%s" opri osec)::String nstr = (printf "%s:%s" npri nsec)::String in - (printf " %-*s %-*s => %-*s %.8f a=%s" - imlen inam pmlen ostr + (printf " %3d. %-*s %-*s => %-*s %.8f a=%s" + pos imlen inam pmlen ostr pmlen nstr c moves, cmds) @@ -612,7 +613,8 @@ printSolution il ktn kti sol = imlen = mlen_fn kti nmlen = mlen_fn ktn in - unzip $ map (printSolutionLine il ktn kti nmlen imlen) sol + unzip $ map (uncurry $ printSolutionLine il ktn kti nmlen imlen) $ + zip sol [1..] -- | Print the node list. printNodes :: [(Int, String)] -> NodeList -> String diff --git a/src/hbal.hs b/src/hbal.hs index 4d100e20d..b425f9265 100644 --- a/src/hbal.hs +++ b/src/hbal.hs @@ -72,7 +72,7 @@ iterateDepth ini_tbl max_rounds ktn kti nmlen imlen cmd_strs oneline = do let (sol_line, cmds) = Cluster.printSolutionLine ini_il ktn kti - nmlen imlen (head fin_plc) + nmlen imlen (head fin_plc) fin_plc_len upd_cmd_strs = cmds:cmd_strs unless (oneline || fin_plc_len == ini_plc_len) $ do putStrLn sol_line -- GitLab