-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCPL.hs
70 lines (59 loc) · 1.92 KB
/
CPL.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
module CPL where
import System
import CPUTime
import IOExts
import CPLBasic
import CPLTI
import CPLPattern
import BuiltinPatterns
import Array
import Numeric
--system--
import MovingAvg
--user created start--
import C1
import ExpMovingAvg
import Hill3
import Indt1
import Indt2
import Hill2
--user created end--
--------- for timing without interface -------------------------
doComp :: Pattern -> String -> IO ()
doComp pat cname
= do (tiPrim,b) <- loadTi cname
t1 <- getCPUTime
let insts = runVMC (solve (1,b) pat tiPrim) tiPrim 0
print insts
t2 <- getCPUTime
putStrLn ("CPU Time : " ++ showFFloat Nothing ((fromInteger (t2 Prelude.-t1))/1000000000000) " seconds.")
allComps :: Pattern -> String -> IO ()
allComps pat arg
= do
let filename = arg
content <- readFile filename
let companies = lines content
mapM_ (doComp pat) companies
print companies
print "CPL ... done!"
--------- end of timing ----------------------------------------
--------- for viewing with Java interface ---------------------
--------- for displaying pattern instances
browse :: String -> Pattern -> IO ()
browse cname pat
= do (tiPrim,b) <- loadTi cname
let insts = runVMC (solve (1,b) pat tiPrim) tiPrim 0
putStrLn ("_DIRECTIVE_BROWSE " ++ fun insts)
where fun lmss = let tmp = foldr (\l1 l2 -> (init.tail.show) l1 ++ ('%':l2)) "" lmss
in if null tmp then [] else cname ++ ('@':init tmp)
--------- for displaying indicators
evalDisplay func cname = do (tiPrim,b) <- loadTi cname
putStrLn ("_DIRECTIVE_TI " ++
show(cname) ++ "@" ++ show(b) ++ "@" ++
showTI(runVMCs func tiPrim [1..b]))
showTI xs = case xs of
[] -> ""
(a:x) -> case a of
Nothing -> "-1," ++ showTI(x)
Just b -> (show ((fromIntegral (round(b*100)))/100)) ++ ","++showTI(x)
------------------------------- end of interface ---------------------------