Revision 9f6dcdea hbal.hs

b/hbal.hs
73 73
    instFile   = optInstf
74 74
    instSet    = optInstSet
75 75
    masterName = optMaster
76
    silent a   = (optVerbose a) == 0
76
    silent a   = optVerbose a == 0
77 77

  
78 78
-- | Default values for the command line options.
79 79
defaultOptions :: Options
......
121 121
      (ReqArg (\ m opts -> opts { optMaster = m }) "ADDRESS")
122 122
      "collect data via RAPI at the given ADDRESS"
123 123
    , Option ['l']     ["max-length"]
124
      (ReqArg (\ i opts -> opts { optMaxLength =  (read i)::Int }) "N")
124
      (ReqArg (\ i opts -> opts { optMaxLength =  read i::Int }) "N")
125 125
      "cap the solution at this many moves (useful for very unbalanced \
126 126
      \clusters)"
127 127
    , Option ['v']     ["verbose"]
128
      (NoArg (\ opts -> opts { optVerbose = (optVerbose opts) + 1 }))
128
      (NoArg (\ opts -> opts { optVerbose = optVerbose opts + 1 }))
129 129
      "increase the verbosity level"
130 130
    , Option ['q']     ["quiet"]
131
      (NoArg (\ opts -> opts { optVerbose = (optVerbose opts) - 1 }))
131
      (NoArg (\ opts -> opts { optVerbose = optVerbose opts - 1 }))
132 132
      "decrease the verbosity level"
133 133
    , Option ['O']     ["offline"]
134 134
      (ReqArg (\ n opts -> opts { optOffline = n:optOffline opts }) "NODE")
......
196 196
formatOneline :: Double -> Int -> Double -> String
197 197
formatOneline ini_cv plc_len fin_cv =
198 198
    printf "%.8f %d %.8f %8.3f" ini_cv plc_len fin_cv
199
               (if fin_cv == 0 then 1 else (ini_cv / fin_cv))
199
               (if fin_cv == 0 then 1 else ini_cv / fin_cv)
200 200

  
201 201
-- | Main function.
202 202
main :: IO ()
......
216 216
  let offline_names = optOffline opts
217 217
      all_nodes = Container.elems fixed_nl
218 218
      all_names = map Node.name all_nodes
219
      offline_wrong = filter (\n -> not $ elem n all_names) offline_names
219
      offline_wrong = filter (flip notElem all_names) offline_names
220 220
      offline_indices = map Node.idx $
221 221
                        filter (\n -> elem (Node.name n) offline_names)
222 222
                               all_nodes
......
243 243
             (Container.size nl)
244 244
             (Container.size il)
245 245

  
246
  when (length csf > 0 && not oneline && verbose > 1) $ do
247
         printf "Note: Stripping common suffix of '%s' from names\n" csf
246
  when (length csf > 0 && not oneline && verbose > 1) $
247
       printf "Note: Stripping common suffix of '%s' from names\n" csf
248 248

  
249 249
  let (bad_nodes, bad_instances) = Cluster.computeBadItems nl il
250 250
  unless (oneline || verbose == 0) $ printf
251 251
             "Initial check done: %d bad nodes, %d bad instances.\n"
252 252
             (length bad_nodes) (length bad_instances)
253 253

  
254
  when (length bad_nodes > 0) $ do
254
  when (length bad_nodes > 0) $
255 255
         putStrLn "Cluster is not N+1 happy, continuing but no guarantee \
256 256
                  \that the cluster will end N+1 happy."
257 257

  
......
286 286
                         nmlen imlen [] oneline min_cv
287 287
  let (Cluster.Table fin_nl _ fin_cv fin_plc) = fin_tbl
288 288
      ord_plc = reverse fin_plc
289
      sol_msg = (if null fin_plc
290
                 then printf "No solution found\n"
291
                 else (if verbose > 2
292
                       then printf "Final coefficients:   overall %.8f, %s\n"
293
                            fin_cv (Cluster.printStats fin_nl)
294
                       else printf "Cluster score improved from %.8f to %.8f\n"
295
                            ini_cv fin_cv
296
                      ))::String
289
      sol_msg = if null fin_plc
290
                then printf "No solution found\n"
291
                else if verbose > 2
292
                     then printf "Final coefficients:   overall %.8f, %s\n"
293
                          fin_cv (Cluster.printStats fin_nl)
294
                     else printf "Cluster score improved from %.8f to %.8f\n"
295
                          ini_cv fin_cv
296
                              ::String
297 297

  
298 298
  unless oneline $ putStr sol_msg
299 299

  

Also available in: Unified diff