Changeset 24

Show
Ignore:
Timestamp:
07/27/08 00:25:57 (2 years ago)
Author:
thesz
Message:

Added problem from Omega test paper. It is considered solvable by our contraint handler. Going to recovering range conditions from a list of MIN/MAX pairs.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • fort/IConstr.hs

    r23 r24  
    3838vecC = Vec Map.empty 
    3939vec0 = vecC 0 
     40vec1 = vecC 1 
    4041vecV v = Vec (Map.singleton v 1) 0 
    4142vecCV c v 
     
    5758vecMinus a b = mergeVecs (-) a b         
    5859 
    59 vecFromCoefs c coefs = foldr vecPlus (vecC c) $ map (\(c,v) -> vecCV c v) coefs 
     60vecFromCoefs coefs = foldr vecPlus (vec0) $ map (\(c,v) -> vecScale c v) coefs 
     61vecFromCoefs' coefs = foldr vecPlus (vec0) $ map (\(c,v) -> vecCV c v) coefs 
    6062 
    6163vecConst (Vec _ c) = c 
     
    333335        return () 
    334336 
    335 ctxLE []     []  = return () 
    336 ctxLE (i:is) (j:js) = do 
     337ctxLT [i]    [j]  = insertIE (vecPlus i vec1) LE j 
     338ctxLT (i:is) (j:js) = do 
    337339                insertEQ i j 
    338                 ctxLE is js 
     340                ctxLT is js 
    339341        +++ do 
    340                 insertIE i LE j 
    341 ctxLE _ _ = error "context dimension mismatch in ctxLE" 
     342                insertIE (vecPlus i vec1) LE j 
     343ctxLT _ _ = error "context dimension mismatch in ctxLE" 
    342344         
    343345 
     
    363365--   do i=1,n 
    364366--     m[2,j]=m[i,2] 
     367-- ie, is there any read at [j',i'] that depends on write at [j,i] and [j,i] < [j',i'] 
    365368-- This means the following: 
    366369--  ranges as usual: 1<=i,j<=n 
     
    372375        let one = vecC 1 
    373376        betweens [i,j,i1,j1] one n 
    374         ctxLE [j,i] [j1,i1] 
     377        ctxLT [j,i] [j1,i1] 
    375378        insertEQ i        (vecC 2) 
    376379        insertEQ (vecC 2) j 
     380 
     381-- the problem from Omega test paper by Pugh. 
     382-- 7x + 12y + 31z = 17 
     383-- 3x + 5y + 14z = 7 
     384-- 1 <= x <= 40 
     385-- -50 <= y <= 50 
     386-- Should be solvable. 
     387otprob :: SolverM String () 
     388otprob = do 
     389        let [x,y,z] = map vecV ["x","y","z"] 
     390        between x (vec1) (vecC 40) 
     391        between y (vecC (-50)) (vecC 50) 
     392        insertEQ (vecFromCoefs [(7,x),(12,y),(31,z)]) (vecC 17) 
     393        insertEQ (vecFromCoefs [(3,x),(5,y),(14,z)]) (vecC 7) 
    377394 
    378395--------------------------------------------------------------------------------