diff --git a/AlgebraicDataflowArchitectureModel/models/StockManagement.model b/AlgebraicDataflowArchitectureModel/models/StockManagement.model index d3ed3f2..131b7ef 100644 --- a/AlgebraicDataflowArchitectureModel/models/StockManagement.model +++ b/AlgebraicDataflowArchitectureModel/models/StockManagement.model @@ -2,46 +2,45 @@ stock := nil shortage := nil } + +channel CIO_enter { + out arrival(s:Tuple, arrive(item:Str, num:Int)) == tuple(item, num) +} + channel CIO_req { out request(r:Tuple, req(item:Str, num:Int)) == tuple(item, num) } -channel CIO_enter { - out entering(e:Tuple, enter(item:Str, num:Int)) == tuple(item, num) -} - channel C1 { - in request(r, update1(r2)) == r2 - out stock(st:Map, update1(r2)) == if(le(snd(r2), lookup(st, fst(r2))), - insert(st, fst(r2), lookup(st, fst(r2)) - snd(r2)), - st) - out shortage(sh:Map, update1(r2)) == if(le(snd(r2), lookup(sh, fst(r2))), - sh, - insert(sh, fst(r2), lookup(sh, fst(r2)) + snd(r2))) + in arrival(ar, update1(ar2, st)) == ar2 + ref stock(st:Map, update1(ar2, st)) + out available(av:Tuple, update1(ar2, st)) == tuple(fst(ar2), snd(ar2) + lookup(st, fst(ar2))) } channel C2 { - in entering(e, update2(e2, st)) == e2 - ref stock(st, update2(e2, st)) - out shortage(sh, update2(e2, st)) == if(ge(snd(e2) + lookup(st, fst(e2)), lookup(sh, fst(e2))), - insert(sh, fst(e2), 0), - sh) + in available(av, update2(av2, sh)) == av2 + ref shortage(sh, update2(av2, sh)) + out deriver(dr:Tuple, update2(av2, sh)) == if(ge(snd(av2), lookup(sh, fst(av2))), + tuple(fst(av2), lookup(sh, fst(av2)), snd(av2) - lookup(sh, fst(av2))), + tuple(fst(av2), 0, snd(av2))) + out shortage(s, update2(av2, sh)) == if(ge(snd(av2), lookup(s, fst(av2))), + insert(s, fst(av2), 0), + s) } channel C3 { - in entering(e, update3(e2, sh)) == e2 - ref shortage(sh, update3(e2, sh)) - out stock(st, update3(e2, sh)) == if(ge(snd(e2) + lookup(st, fst(e2)), lookup(sh, fst(e2))), - insert(st, fst(e2), snd(e2) + lookup(st, fst(e2)) - lookup(sh, fst(e2))), - insert(st, fst(e2), snd(e2) + lookup(st, fst(e2)))) + in deriver(dr, update3(dr2)) == dr2 + out stock(st, update3(dr2)) == insert(st, fst(dr2), snd(snd(dr2))) + out shipping(sp:Tuple, update3(dr2)) == tuple(fst(dr2), fst(snd(dr2))) } channel C4 { - in entering(e, update4(e2, sh, st)) == e2 - ref shortage(sh, update4(e2, sh, st)) - ref stock(st, update4(e2, sh, st)) - out dispatching(d:Tuple, update4(e2, sh, st)) == if(and(gt(lookup(sh, fst(e2)), 0), ge(snd(e2) + lookup(st, fst(e2)), lookup(sh, fst(e2)))), - tuple(fst(e2), lookup(sh, fst(e2))), - null) -} - + in request(rq, update4(rq2, st)) == rq2 + ref stock(st, update4(rq2, st)) + out deriver(dr, update4(rq2, st)) == if(ge(lookup(st, fst(rq2)), snd(rq2)), + tuple(fst(rq2), snd(rq2), lookup(st, fst(rq2)) - snd(rq2)), + tuple(fst(rq2), 0, lookup(st, fst(rq2)))) + out shortage(sh, update4(rq2, st)) == if(ge(lookup(st, fst(rq2)), snd(rq2)), + sh, + insert(sh, fst(rq2), lookup(sh, fst(rq2)) + snd(rq2))) +} \ No newline at end of file