-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsampling-infer.dats
46 lines (40 loc) · 1.19 KB
/
sampling-infer.dats
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
staload "rat.sats"
staload "flow.sats"
(**
Trying out a more general approach to see what I need to infer.
*)
extern fun
swap {n:pos} {p:rat | is_nat (Rational(n) * p)} (
strict_flow (int, n, p), strict_flow (int, n, p)
): (strict_flow (int, n, p), strict_flow (int, n, p))
extern fun
id {n:pos} {p:rat | is_nat (Rational(n) * p)} (
strict_flow (int, n, p)
): (strict_flow (int, n, p))
(**
So in the absence of explicit rates for imported nodes, the only things
I really need to infer are the rates of the local variables.
One thing that's missing from all this is some way to extract all the
computed rates during type checking so the tasks can be
constructed from the program.
*)
fun
sampling (
i: strict_flow (int, 500, Rational(0))
): [n:pos] [p:rat] (
strict_flow (int, n, p)
) = let
var vf : StrictFlow (int)
var vs : StrictFlow (int)
//
prval pfvf = set_clock (vf, 500, rational_pf (0, 1))
prval pfvs = set_clock (vs, 1500, rational_pf (0,1))
//
val (o, vf') = swap (i, flow_multiply_clock (flow_fby (5, vs), 3))
val (vs') = id (flow_divide_clock (vf, 3))
//
prval () = flow_future_elim (pfvf, vf, vf')
prval () = flow_future_elim (pfvs, vs, vs')
in
(o)
end