tryBalance :: Table -- ^ The starting table
-> Bool -- ^ Allow disk moves
-> Bool -- ^ Only evacuate moves
+ -> Score -- ^ Min gain threshold
+ -> Score -- ^ Min gain
-> Maybe Table -- ^ The resulting table and commands
-tryBalance ini_tbl disk_moves evac_mode =
+tryBalance ini_tbl disk_moves evac_mode mg_limit min_gain =
let Table ini_nl ini_il ini_cv _ = ini_tbl
all_inst = Container.elems ini_il
all_inst' = if evac_mode
fin_tbl = checkMove node_idx disk_moves ini_tbl reloc_inst
(Table _ _ fin_cv _) = fin_tbl
in
- if fin_cv < ini_cv
+ if fin_cv < ini_cv && (ini_cv > mg_limit || ini_cv - fin_cv >= min_gain)
then Just fin_tbl -- this round made success, return the new table
else Nothing
, oMinScore
, oMaxCpu
, oMinDisk
+ , oMinGain
+ , oMinGainLim
, oDiskMoves
, oDynuFile
, oExTags
-> [MoveJob] -- ^ Current command list
-> Bool -- ^ Whether to be silent
-> Score -- ^ Score at which to stop
+ -> Score -- ^ Min gain limit
+ -> Score -- ^ Min score gain
-> Bool -- ^ Enable evacuation mode
-> IO (Cluster.Table, [MoveJob]) -- ^ The resulting table
-- and commands
iterateDepth ini_tbl max_rounds disk_moves nmlen imlen
- cmd_strs oneline min_score evac_mode =
+ cmd_strs oneline min_score mg_limit min_gain evac_mode =
let Cluster.Table ini_nl ini_il _ _ = ini_tbl
allowed_next = Cluster.doNextBalance ini_tbl max_rounds min_score
m_fin_tbl = if allowed_next
then Cluster.tryBalance ini_tbl disk_moves evac_mode
+ mg_limit min_gain
else Nothing
in
case m_fin_tbl of
hFlush stdout
iterateDepth fin_tbl max_rounds disk_moves
nmlen imlen upd_cmd_strs oneline min_score
- evac_mode
+ mg_limit min_gain evac_mode
Nothing -> return (ini_tbl, cmd_strs)
-- | Formats the solution for the oneline display
(fin_tbl, cmd_strs) <- iterateDepth ini_tbl (optMaxLength opts)
(optDiskMoves opts)
- nmlen imlen [] oneline min_cv (optEvacMode opts)
+ nmlen imlen [] oneline min_cv
+ (optMinGainLim opts) (optMinGain opts)
+ (optEvacMode opts)
let (Cluster.Table fin_nl fin_il fin_cv fin_plc) = fin_tbl
ord_plc = reverse fin_plc
sol_msg = if null fin_plc