[modified option processing for  maxLoops and maxTiers
martin.hofmann@uni-bamberg.de**20100326124531] hunk ./src/Igor2/Data/IgorMonad.hs 14
-    setTarget, getTarget, addBgk, remBgk, getEvidence, tick, nextTier, 
-    loopCount, loopsCount, tierCount, isDebug, inEnhanced, ifIsSet, atMaxLoops, 
-    atMaxTiers, getPatComparison, background, targets, predicates, addIO, 
+    setTarget, getTarget, addBgk, remBgk, getEvidence, tick, tickT, 
+    loopCount, loopsCount, tierCount, isDebug, inEnhanced, ifIsSet, 
+     atMaxLoops, atMaxTiers, getPatComparison, background, targets, predicates, addIO, 
hunk ./src/Igor2/Data/IgorMonad.hs 205
-nextTier :: IM ()
-nextTier = get >>= \i@(Igor _ _ tc _ _) ->
-            llogNO(linebreak <> text "ALL CANDIDATES CLOSED, go to next tier") >>
-            put i{igor_tc = tc+1}
+tickT :: IM ()
+tickT = get >>= \i@(Igor _ _ tc _ _) -> put i{igor_tc = tc+1}
hunk ./src/Igor2/Data/IgorMonad.hs 216
--- | have we reached the maximu  tier threshold?
+-- | have we reached the maximum tier threshold?
hunk ./src/Igor2/Data/IgorMonad.hs 218
-atMaxTiers = liftM2 ((<=) . fromInteger) maxTiers tierCount
+atMaxTiers = liftM2 ((==).fromInteger) maxTiers tierCount
hunk ./src/Igor2/SynthesisEngine.hs 66
-    bnds  <-  mapM (simplify (scr_simplify conf)) $ hs                 
-    let hs' =  take (fromInteger . scr_maxTiers $ conf) bnds
-    when (scr_debug conf) (outputraw hs')
-    return . ((,) l) $ map hypos2decs hs'
+    bnds  <-  mapM (simplify (scr_simplify conf)) $ hs      
+    when (scr_debug conf) (outputraw bnds)
+    return . ((,) l) $ map hypos2decs bnds
hunk ./src/Igor2/SynthesisEngine.hs 74
---        | b = map $ concatMap $ if b then (liftM snd) .  simplifiedBindings else allBindings
-        
---    traceA = (\o@(c,d) -> (tp $ "LOOPS " ++ (show . loops $ c) ++ " CYCLES " ++ (show . cycles $ c) ) o )
---    traceB = (\h -> ( tp $ "LOOPS " ++ (show . loops . callings $ h)++ " CYCLES " ++ (show . cycles . callings $ h)  ) h )
+
hunk ./src/Igor2/SynthesisEngine.hs 90
-        waypointL $ text "STARTING SYNTHESIS for TARGET" <+> squotes (pretty n)
+        waypointL $ text "STARTING SYNTHESIS for TARGET" <+> 
+                    squotes (pretty n)
hunk ./src/Igor2/SynthesisEngine.hs 100
-doLoop hsp =  do
-    
-    tick
+doLoop hsp 
+    | isEmpty hsp = exhausted
+    | otherwise   = do
+      tick
+      
+      loopCount >>= \lc -> waypointM $ 
+                          text "Entering Rule-Advancement-Loop for the" <+> 
+                               int (lc) <> text ". time"
+      llogNO . (text "#Hypos:" <+>) . pretty . countHypos $ hsp
+      llogDE . (text "HSpace:" <+>) . pretty $ hsp 
hunk ./src/Igor2/SynthesisEngine.hs 111
-    loopCount >>= \lc -> waypointM $ 
-                        text "Entering Rule-Advancement-Loop for the" <+> 
-                        int (lc) <> text ". time"
-    llogNO . (text "#Hypos:" <+>) . pretty . countHypos $ hsp
-    llogDE . (text "HSpace:" <+>) . pretty $ hsp 
-    
-    getEvidence >>= \io -> llogDE ( linebreak <> text "IGOR initialised to:" <$> 
-                                   indent 2 (pretty io))
+      getEvidence >>= \io -> llogDE ( linebreak <> 
+                                     text "IGOR initialised to:" <$> 
+                                     indent 2 (pretty io))
hunk ./src/Igor2/SynthesisEngine.hs 115
-    debug <- isDebug
-    atMxL <- atMaxLoops   
-    let (hypos,hsp') = popHypos hsp
-    let (ejcts,cnds) = partition isFinished hypos
+      debug <- isDebug
+      atMxL <- atMaxLoops   
+      atMxT <- atMaxTiers
+      
+      let (hypos,hsp') = popHypos hsp
hunk ./src/Igor2/SynthesisEngine.hs 121
-    if (isEmpty hsp) then exhausted
-     else if (debug && atMxL) 
-          then llogNO (text "MaxLoops reached") >> stopWith hypos
-      else if (null ejcts) then continue cnds hsp'
-       else if debug then finishTier ejcts cnds hsp'
-        else do llogNO ( linebreak <> text "FIRST HYPOS FINISHED: reduce" <+>
-                         text "SearchSpace and finish tier!" <> linebreak)
-                finishTier ejcts cnds emptyHSpace      
-               
-finishTier ejcts [] hsp = do
-    debug <- isDebug
-    stop  <- liftM2 (||) atMaxTiers atMaxLoops
-    if (not debug) || stop then stopWith ejcts
-       else llogNO (linebreak <> 
-                    text "TIER FINISHED: eject finished hypos and continue." <>
-                    linebreak) >>
-            llogNO (pretty ejcts) >>
-            doLoop hsp >>= eject ejcts                        
-finishTier ejcts cnds hsp =continue cnds $ (pushHypos ejcts hsp)
-                          
+      if atMxL then llogNO (text "MaxLoops reached") >> stopWith hypos
+       else if (any isFinished hypos) then finishTier hypos hsp'
+             else continue hypos hsp'
+      
+-- Assumes at least one 'Hypo' to be finished! If we have reached maxTiers, 
+-- then prune the HSpace, and try to finish Hypos which are as good as the 
+-- finished ones. The best ones are pushed back unchanged, so they are on top 
+-- in the next loop iteration again.
+-- Otherwise if we are still under the maxTiers threshold and all best hypos 
+-- are finised, eject those and enter loop again with remaining HSpace. If there
+-- are still unfinished hypos, advance them and continue with best hypos pushed
+-- back.
+finishTier hypos hsp = do 
+           
+  atMxT  <- atMaxTiers
+  llogNO (linebreak <> text "FINISHED HYPOS, finish Tier:") 
+  case (partition isFinished hypos) of
+    (f,[]) -> if atMxT 
+             then do llogNO (text "Maximum tiers reached!")
+                     stopWith hypos
+             else do llogNO (text "TIER FINISHED: Eject finished and continue!")
+                     tickT >> doLoop hsp >>= eject hypos
+    (f,uf) -> if atMxT
+             then do llogNO (text "Prune and finish tier.")
+                     continue uf $ (pushHypos f emptyHSpace)
+             else do llogNO (text "Continue with unfinished.") 
+                     continue uf $ (pushHypos f hsp)
+   -- if still unfinished hypos, 
+
+-- advance the given hypos, push them back into HSpace, and do loop again  
hunk ./src/Igor2/SynthesisEngine.hs 155
-exhausted = llogNO( linebreak <> text "SEARCHSPACE EXHAUSTED - - STOP" <> 
-                    linebreak) >>
+exhausted = llogNO( linebreak <> 
+                    text "SEARCHSPACE EXHAUSTED - - STOP" <> 
+                    linebreak ) >>